简体   繁体   中英

Flash and _root and levels - Loading SWF into another SWF

I'm loading an old formula calculator into a new project I'm working on; pretty simple...

this.createEmptyMovieClip("calc_mc", 0);
loadMovie("calc.swf", calc_mc);

Everything's fine...But, these commands clear the 'hints' in the form fields in the original calc.swf

if (my_txt != null) {
    var mc = my_txt._name + "Hint";
    if (my_txt.length > 0) {
        _root[mc]._visible = false;
    } else {
        _root[mc]._visible = true;
    }
}
_root[this._name + "Hint"]._visible = false;

SWF works fine on it's own, but once it's loaded into the new project, the hints dont clear. I know _root is garbling it somewhere, but I can't figure it out. Much appreciated.

Once loaded in a new movie, _root references the Main Movie root timeline, so your _root commands fails on the loaded movie.

You should change them in a _parent ..... notation. For example if your _root command is 2 level nested in the loaded movie, you can refer to root as _parent._parent

or you can use this ugly solution:

_root.calc_mc..............

with this one the standalone swf will not work anymore.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM