开发者

Loaded swf doesn't appear when referencing one of its control by string

I have in main:

var MyLoader:Loader = new Loader();
    MyLoader.contentLoaderInfo.addEventListener(Event.COMPLETE, finishLoading);
    MyLoader.load(new URLRequest("MySWF.swf开发者_运维技巧"));         
    MyZone.addChild(loader);

And in MySWF:

    this["aSlider"].addEventListener(SliderEvent.CHANGE,OnSliderChange);

then MySWF doesn't show up on stage whereas with

    aSlider.addEventListener(SliderEvent.CHANGE,OnSliderChange);

it does appear.

I need to use this["aSlider"] because of this

http://blog.ickydime.com/2008/07/as3-notes-automatically-declare-stage.html

as pointed by https://stackoverflow.com/users/562566/ascension-systems to my previous question.


If you're turning off 'automatically declare instances', then you must declare the slider as a public property in your class, named the same as your stage instance. So in mySWF.as, add this after your private variable declarations:

public var slider:Slider;

The instance exists on the stage, but it must be declared before it can be used. Try to avoid the myClass['myObject'] notation as it will reduce the error checking and code completion capabilities of editors like Flash Builder and FDT.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜