The embed in AS3

Source: Internet
Author: User

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.