If you ever tried below code to load Flash(*.fla/*.swf) in Flex 2,you know <mx:SWFLoader /> tag ’s pretty limited.
- <mx:SWFLoader source="@Embed(source=sample.swf')" id="swf" x="0" y="0" width="400" height="580"/>
Then I tried another way like below source code,but I god the Error #1034–That can’t be converted from flash.display::Loader@ae341a1 to mx.core.IUIComponent.
- var re:URLRequest = new URLRequest("sample.swf");
- var loadDHoader = new Loader();
- loadDHoader.load(re);
- tile.addChild(loadDHoader);
I’ve spent time to fix it and found that the flash file can be loaded with below source code.
- var re:URLRequest = new URLRequest("sample.swf");
- var loader:SWFLoader = new SWFLoader ();
- loader.addEventListener(Event.COMPLETE, completeHandler);
- loader.load(re);
- function completeHandler(event:Event){
- addChild(loader);
- }
I’m not sure whether it is correct or not but hope will be helpful. BTW I found darronschall.com have supplied a better solution at here.

February 23rd, 2008
Ntt.cc 








Posted in
Tags: 
RSS Feed
Email Feed
[...] How to load Flash File in Flex 2 (0) [...]