Error Referencing Externally loaded SWF

家住魔仙堡 提交于 2019-12-25 03:08:42

问题


I'm loading an swf say "test.swf" which gets loaded in imageLoader , so I can get its content by :

imageLoader.content

So if I wanted one of the movieClips inside it I would do this :

imageLoader.content.testMovie.transform.colorTransform = someTransformation;

But when I do this, since the movie is not loaded the file is not compiled and gives me an error your referring to something that is not there. How else am I supposed to reference a content that will be loaded later?


回答1:


Wait till it is loaded. Listen to its complete event and access content from there.

imageLoader.contentLoaderInfo.addEventListener(Event.COMPLETE, onLoad);
function onLoad(e:Event):void
{
  MovieClip(imageLoader.content).testMovie.transform.colorTransform = someTransformation;
}

If testMovie is yet another dynamically loaded SWF, wait till it is loaded - listen to the complete event dispatched by testMovie.contentLoaderInfo.

Even better, if you have access to the loaded SWF, dispatch a custom event from there when testMovie is loaded and listen to it from the main SWF.




回答2:


You can't reference something that hasn't loaded. If you want to apply a transform you can do that on the parent clip but this might not be what you are after.



来源:https://stackoverflow.com/questions/2408527/error-referencing-externally-loaded-swf

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!