ACTIONSCRIPT3 allows the external SWF to be embedded directly into the main class with the Embed tag (of course, dynamically loaded with Urlloader)
Yang over the original banyan tree
Source: http://yjmyzz.cnblogs.com
Key points:
When designers put footage into the library, be sure to specify the class name so that the code can create instances of those classes.
As shown, there are three basic materials (buttons, bitmaps, movie clips) placed in the library, which can then be handled in the code:
1 Package2 {3 4 ImportFlash.display.Sprite;5 ImportFlash.display.DisplayObject;6 ImportFlash.display.SimpleButton;7 Importflash.events.MouseEvent;8 ImportFlash.display.MovieClip;9 ImportFlash.display.BitmapData;Ten ImportFlash.display.Bitmap; One A - Public classDemoextends MovieClip - { the[Embed (Source ="skin.swf", symbol ="Buttonpause")] - Private varButtonpause:class; - -[Embed (Source ="skin.swf", symbol ="Buttonplay")] + Private varButtonplay:class; - +[Embed (Source ="skin.swf", symbol ="Logoimage")] A Private varLogoimage:class; at -[Embed (Source ="skin.swf", symbol ="Testmovie")] - Private varTestmovie:class; - - - Public functionDemo () in { - init (); to } + - Private functionInit ():void the { * varBtntest:simplebutton =NewButtonpause () as SimpleButton; $Trace (Btntest,btntest is SimpleButton);//demo_buttonpause0,truePanax Notoginseng AddChild (btntest); -Btntest.x = Btntest.y = 50; the Btntest.addeventlistener (Mouseevent.click,btntestclick); + A varBtntest2:simplebutton =NewButtonplay () as SimpleButton; theTrace (BTNTEST2);//Demo_buttonplay1 + AddChild (btnTest2); -BTNTEST2.Y = 50; $btntest2.x = 100; $ Btntest2.addeventlistener (Mouseevent.click,btntest2click); - - the varBmd:bitmap =Newlogoimage () as Bitmap; -Trace (BMD);//Demo_logoimage2Wuyi AddChild (BMD); theBmd.x = BMD.Y = 200; - Wu varTestmovie:MovieClip=NewTestmovie () asMovieClip; - AddChild (Testmovie); Abouttestmovie.x = TESTMOVIE.Y = 180; $Trace (Testmovie);//Demo_testmovie3 - - } - A Private functionBtntestclick (e:mouseevent):void + { theTrace"Btntest was clicked!"); - } $ the Private functionBtntest2click (e:mouseevent):void the { theTrace"BtnTest2 was clicked!"); the } - } in the}
Embed in AS3