Pagina 1 di 2 1 2 ultimoultimo
Visualizzazione dei risultati da 1 a 10 su 14
  1. #1

    problema assurdo con variabile

    Ciao a tutti,
    non capisco perchè non funziona questo che vi sto per spiegare:
    ho una variabile dichiarata nella root:
    codice:
    var pippo=1
    la voglio utilizzare all'interno di un movieclip, e la richiamo così:
    codice:
    _root.pippo
    Come mai non mi funziona?

  2. #2
    Temo che l'eventuale problema risieda in un'altra parte perchè quella è la sintassi corretta!
    Al limite prova a riaprire Flash e a rimettere solo questo in un nuovo file...ogni tanto può capitare che Flash si becchi l'influenza.

  3. #3
    Bo bo non riesco a capire!!

  4. #4
    Allora, vi riporto il codice e vi spiego la situazione:
    codice:
    var asasa = _root.prova;
    trace(asasa); 
    #initclip
    ImageFader = function () { this.__init__();};
    ImageFader.prototype = new MovieClip();
    // ** init class ** //
    ImageFader.prototype.__init__ = function() {
        this._xscale = 100;
        this._yscale = 100;
        this.bounding_box.unloadMovie();
        this._fader_.unloadMovie();
        this._dataProvider = new Array();
        this._count = 0;
        this._depth = 1;
        this._isLoaded = -1;
        if (this._S_) {
            clearInterval(this._S_);
        }
        var asasa = _root.prova;
        trace(asasa); 
        if (this._xmlfile != "") {
            this.loadXML(this._xmlfile+asasa);
        }
    };
    // *** load the external xml ** //
    ImageFader.prototype.loadXML = function(x) {
        var _xml = new XML();
        _xml.ignoreWhite = true;
        _xml.path = this;
        _xml.load(x);
        _xml.onLoad = function() {
            for (var a = 0; a<this.firstChild.childNodes.length; a++) {
                var _trans = this.firstChild.childNodes[a].attributes.TRANSITION;
                var _pause = this.firstChild.attributes.PAUSE;
                var _img = this.firstChild.childNodes[a].firstChild.nodeValue;
                this.path._dataProvider.push({img:_img, transition:_trans, pause:_pause});
            }
            this.path.startFading();
            delete this;
        };
    };
    // ** start fading procedure ** //
    ImageFader.prototype.startFading = function() {
        if (this._dataProvider.length>0) {
            this.makeFader(true);
        }
    };
    // ** load images ** //
    ImageFader.prototype.makeFader = function(first) {
        this._isLoaded = -1;
        this._tmp = this.attachMovie("ImageLoader", "ImageLoader"+this._depth, this._depth++);
        this._old1 = this['ImageLoader'+(this._depth-1)];
        this._old2 = this['ImageLoader'+(this._depth-2)];
        this._tmp.loadHandler("isLoaded", this._count);
        this._tmp.autoStart = false;
        this._tmp.transition = this._dataProvider[this._count].transition;
        this._tmp.loadImage(this._dataProvider[this._count].img);
        this._t1 = getTimer();
        this.onEnterFrame = function() {
            this._t2 = getTimer();
            if ((this._t2-this._t1)>this._dataProvider[this._count].pause || first == true) {
                if (this._isLoaded == this._count || this._isLoaded == 1 && this._count == 0) {
                    delete this.onEnterFrame;
                    this._tmp.start();
                    this._old1.fadeOut();
                    this._old2.removeMovieClip();
                    if (this._count+1<this._dataProvider.length) {
                        this._count++;
                        this.makeFader();
                        return;
                    } else {
                        if (this._loop == true) {
                            this._count = 0;
                            this.makeFader();
                        }
                    }
                }
            }
        };
    };
    // ** which has been loaded ? ** //
    ImageFader.prototype.isLoaded = function(num) {
        this._isLoaded = num;
    };
    Object.registerClass("ImageFader", ImageFader);
    #endinitclip
    Il primo trace mi visualizza il valore della variabile mentre il secondo da undefined, non riesco a capire il perchè.
    Sapete darmi una spiegazione?

  5. #5
    Prova a mettere nel secondo:
    var _root.asasa = _root.prova;
    trace(_root.asasa);

  6. #6
    codice:
    var asasa = _root.prova;
    trace(asasa);
    #initclip
    ImageFader = function () { this.__init__();};
    ImageFader.prototype = new MovieClip();
    // ** init class ** //
    ImageFader.prototype.__init__ = function() {
        this._xscale = 100;
        this._yscale = 100;
        this.bounding_box.unloadMovie();
        this._fader_.unloadMovie();
        this._dataProvider = new Array();
        this._count = 0;
        this._depth = 1;
        this._isLoaded = -1;
        if (this._S_) {
            clearInterval(this._S_);
        }
        var asasa = _root.asasa = _root.prova;
        trace(_root.asasa);
        if (this._xmlfile != "") {
            this.loadXML(this._xmlfile+asasa);
        }
    };
    // *** load the external xml ** //
    ImageFader.prototype.loadXML = function(x) {
        var _xml = new XML();
        _xml.ignoreWhite = true;
        _xml.path = this;
        _xml.load(x);
        _xml.onLoad = function() {
            for (var a = 0; a<this.firstChild.childNodes.length; a++) {
                var _trans = this.firstChild.childNodes[a].attributes.TRANSITION;
                var _pause = this.firstChild.attributes.PAUSE;
                var _img = this.firstChild.childNodes[a].firstChild.nodeValue;
                this.path._dataProvider.push({img:_img, transition:_trans, pause:_pause});
            }
            this.path.startFading();
            delete this;
        };
    };
    // ** start fading procedure ** //
    ImageFader.prototype.startFading = function() {
        if (this._dataProvider.length>0) {
            this.makeFader(true);
        }
    };
    // ** load images ** //
    ImageFader.prototype.makeFader = function(first) {
        this._isLoaded = -1;
        this._tmp = this.attachMovie("ImageLoader", "ImageLoader"+this._depth, this._depth++);
        this._old1 = this['ImageLoader'+(this._depth-1)];
        this._old2 = this['ImageLoader'+(this._depth-2)];
        this._tmp.loadHandler("isLoaded", this._count);
        this._tmp.autoStart = false;
        this._tmp.transition = this._dataProvider[this._count].transition;
        this._tmp.loadImage(this._dataProvider[this._count].img);
        this._t1 = getTimer();
        this.onEnterFrame = function() {
            this._t2 = getTimer();
            if ((this._t2-this._t1)>this._dataProvider[this._count].pause || first == true) {
                if (this._isLoaded == this._count || this._isLoaded == 1 && this._count == 0) {
                    delete this.onEnterFrame;
                    this._tmp.start();
                    this._old1.fadeOut();
                    this._old2.removeMovieClip();
                    if (this._count+1<this._dataProvider.length) {
                        this._count++;
                        this.makeFader();
                        return;
                    } else {
                        if (this._loop == true) {
                            this._count = 0;
                            this.makeFader();
                        }
                    }
                }
            }
        };
    };
    // ** which has been loaded ? ** //
    ImageFader.prototype.isLoaded = function(num) {
        this._isLoaded = num;
    };
    Object.registerClass("ImageFader", ImageFader);
    #endinitclip
    Ho cambiato così e mi da lo stesso problema!!

  7. #7
    Ma se metti:
    //var asasa = _root.asasa = _root.prova;
    trace(_root.asasa);

    ...cioè mettendo solo il trace e non la definizione, cosa succede?? Ti legge la variabile che hai definito nella prima riga?

  8. #8
    Mi da sempre undefined.

  9. #9
    Ma _root.prova a cosa è uguale??

  10. #10
    Nel primo fotogramma ho nella root ho:
    codice:
    var prova=1;
    var asasa=1;

Permessi di invio

  • Non puoi inserire discussioni
  • Non puoi inserire repliche
  • Non puoi inserire allegati
  • Non puoi modificare i tuoi messaggi
  •  
Powered by vBulletin® Version 4.2.1
Copyright © 2025 vBulletin Solutions, Inc. All rights reserved.