Visualizzazione dei risultati da 1 a 5 su 5

Discussione: [flash] probelma root

  1. #1

    [flash] probelma root

    ragazzi una domanda stupida

    mettiamo che io ho del codice actnioscript su on mc nel mio stage che mettiamo si chiami con nome istanza pippo.

    adesso se prendo pippo e lo metto all'interno di un altro mc di nome pluto il codice actionscript di pippo non funziona più perchè cambia la root

    come devo modificare l'actionscript di pippo una volta che si trova dentro mc pluto?

  2. #2
    Utente di HTML.it L'avatar di and80
    Registrato dal
    Mar 2003
    Messaggi
    15,182
    Io ti consiglio in generale di non usare mai dei riferimenti assoluti nel codice. Salvo rari casi non ce n'è la necessità.
    Riguardo al tuo problema puoi provare ad aggiungere nel tuo codice (quello dentro al clip) this._lockroot=true come prima riga e probabilmente basta questo.

  3. #3
    ciao and grazie per la dritta e per la risposta

    ho provato ma non funziona

    io ho un mc menu e nel suo interno ho questo codice
    codice:
    this._lockroot=true ;
    MovieClip.prototype.animate = function ()
    {
        this.gotoAndStop(1);
        this.onRollOver = function ()
        {
            this.playTo(this._totalframes);
            this._onRollOver();
        };
        this.onRollOut = function ()
        {
            this.playTo(1);
            this._onRollOut();
        };
        this.onReleaseOutside = this.onRollOut;
    };
    MovieClip.prototype.playTo = function (frame)
    {
        if (this.onEnterFrame != undefined)
        {
            delete this.onEnterFrame;
        } // end if
        this.onEnterFrame = function ()
        {
            if (frame == this._currentframe)
            {
                delete this.onEnterFrame;
            }
            else if (frame < this._currentframe)
            {
                this.gotoAndStop(this._currentframe - 1);
            }
            else
            {
                this.gotoAndStop(this._currentframe + 1);
            } // end else if
        };
    };
    MovieClip.prototype.goTo = function (xpos, ypos)
    {
        if (this.onEnterFrame != undefined)
        {
            delete this.onEnterFrame;
        } // end if
        var xdone = false;
        var ydone = false;
        this.onEnterFrame = function ()
        {
            if (Math.abs(ypos - this._y) > 5.000000E-001)
            {
                this._y = this._y + (ypos - this._y) / 9;
            }
            else
            {
                ydone = true;
            } // end else if
            if (Math.abs(xpos - this._x) > 5.000000E-001)
            {
                this._x = this._x + (xpos - this._x) / 9;
            }
            else
            {
                xdone = true;
            } // end else if
            if (xdone && ydone)
            {
                delete this.onEnterFrame;
                this._x = xpos;
                this._y = ypos;
                this.onGoFinish();
            } // end if
        };
    };
    Stage.align = "TL";
    Stage.scaleMode = "noScale";
    Stage.showMenu = false;
    loader_mc._x = Math.round((Stage.width - loader_mc._width) / 2);
    stop ();
    if (xml == undefined)
    {
        xml = "data.xml";
    } // end if
    var xmlOb = new XML();
    xmlOb.ignoreWhite = true;
    xmlOb.onLoad = function ()
    {
        _root.menu.onEnterFrame = function ()
        {
            if (_root.menu.getBytesLoaded() == _root.menu.getBytesTotal())
            {
                delete _root.menu.onEnterFrame;
                play ();
            } // end if
        };
    };
    xmlOb.load(xml);
    2 fotogramma
    codice:
    this._lockroot=true ;
    stop ();
    var dat = new Array();
    var n = xmlOb.firstChild.firstChild;
    while (n != null)
    {
        if (n.nodeName == "file")
        {
            var cob = new Object();
            for (var i in n.childNodes)
            {
                var m = n.childNodes[i];
                cob[String(m.nodeName)] = String(m.firstChild.nodeValue);
            } // end of for...in
            dat.push(cob);
        } // end if
        n = n.nextSibling;
    } // end while
    mask_mc._width = Stage.width;
    mask_mc._height = Stage.height;
    hit_mc._width = Stage.width;
    hit_mc._height = Stage.height;
    hit_mc._alpha = 0;
    container_mc.setMask(mask_mc);
    var cm = container_mc;
    var erxi;
    var erxf;
    var j = 0;
    while (j < dat.length)
    {
        var d = cm.getNextHighestDepth();
        var ct = cm.attachMovie("thumbnail", "t" + j, d);
        ct.animate();
        ct._y = 12;
        ct.pic_mc.picHolder_mc.loadMovie(dat[j].image);
        ct.ref_mc.picHolder_mc.loadMovie(dat[j].image);
        ct.label_mc.label_txt;
        ct.label_mc.label_txt.autoSize = "center";
        ct.label_mc.label_txt.wordWrap = false;
        ct.label_mc.label_txt.multiline = false;
        ct.label_mc.label_txt.text = dat[j].title;
        if (j == 0)
        {
            erxi = Math.round((ct.label_mc.label_txt._width - 58) / 2);
            if (erxi < 0)
            {
                erxi = 0;
            } // end if
        } // end if
        if (j == dat.length - 1)
        {
            erxf = Math.round((ct.label_mc.label_txt._width - 58) / 2);
            if (erxf < 0)
            {
                erxf = 0;
            } // end if
        } // end if
        ct._x = erxi + 12 + 43 * j;
        ct.__url = dat[j].url;
        ct.onRelease = function ()
        {
            getURL(this.__url, "");
            trace (this.label_mc.label_txt.text);
        };
        ct._onRollOver = function ()
        {
            this.swapDepths(this._parent.getNextHighestDepth());
        };
        ++j;
    } // end while
    var w = 24 + erxi + erxf + 43 * dat.length;
    trace (w);
    container_mc._x = Math.round((Stage.width - w) / 2);
    _root.onMouseMove = function ()
    {
        if (!hit_mc.hitTest(_root.menu._xmouse, _root.menu._ymouse, true) || w <= hit_mc._width)
        {
            return;
        } // end if
        var _loc2 = _root.menu._xmouse < 64 ? (64) : (_root.menu._xmouse > hit_mc._width - 64 ? (hit_mc._width - 64) : (_root.menu._xmouse));
        _loc2 = _loc2 - 64;
        var _loc4 = hit_mc._width - w;
        var _loc3 = Math.floor(_loc2 * _loc4 / (hit_mc._width - 128));
        container_mc.goTo(_loc3, 0);
    };
    se metto i componenti contenuti in menu nello stag funziona tutto altrimenti non va

  4. #4
    Utente di HTML.it L'avatar di and80
    Registrato dal
    Mar 2003
    Messaggi
    15,182
    Nel codice che hai postato non ci sono chiari riferimenti a _root.
    Potresti aggiungere "this" a tutti i percorsi, ma non so se risolveresti qualcosa, bisognerebbe proprio vedere come è strutturato questo clip e dove si trova il codice per tirarci fuori qualcosa.

  5. #5
    grazie per la risposta and sei stato gentile
    dai un occhiata a questo appena puoi

    http://forum.html.it/forum/showthrea...readid=1327560

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.