How to Implement interface code separation in Flash Development

Source: Internet
Author: User

The development of "Flash development" has been roughly divided into two branches: FlashDesignerAnd flashProgramEmployeeHowever, designers do not understandCodeProgrammers do not understand design. How can they combine these two roles to implement code and interface separation? The following methods may be useful to you:

 

Actionscript3 allows external SWF to be directly embedded into the main class with the embed mark (of course, it can also be dynamically loaded with urlloader), which means that designers canCode-independentMaterials (such as buttons, images, and small animations) are designed to be stored in the library using Flash CS in their favorite way.

 

Then the programmer embeds the SWF containing (skin) material into the program code and creates the corresponding instance with the Code. In this way, the programmer uses flash Builder/flashdevelop for development, designers Use Flash CS for design.

 

Key points:

When the designer puts the material into the library, the class name must be specified so that the code can create instances of these classes.

 

As shown in, three basic clips (buttons, bitmaps, and movie clips) are stored in the library, which can be processed in the Code as follows:

Package {import flash. display. sprite; import flash. display. displayobject; import flash. display. simplebutton; import flash. events. mouseevent; import flash. display. movieclip; import flash. display. bitmapdata; import flash. display. bitmap; public class demo extends movieclip {[embed (Source = "skin.swf", symbol = "buttonpause")] private var buttonpause: Class; [embed (Source = "skin.swf ", symbol = "buttonplay")] privat E var buttonplay: Class; [embed (Source = "skin.swf", symbol = "logoimage")] private var logoimage: Class; [embed (Source = "skin.swf ", symbol = "testmovie")] private var testmovie: Class; Public Function demo () {Init ();} private function Init (): void {var btntest: simplebutton = new buttonpause () as simplebutton; trace (btntest, btntest is simplebutton); // demo_buttonpause0, trueaddchild (btntest); btntest. X = btntest. Y = 50; btntest. addeventlistener (mouseevent. click, btntestclick); var btntest2: simplebutton = new buttonplay () as simplebutton; trace (btntest2); // demo_buttonplay1addchild (btntest2); btntest2.y = 50; btntest2.x= 100; btntest2.addeventlistener (mouseevent. click, btntest2click); var bone density: bitmap = new logoimage () as bitmap; trace (bone density); // demo_logoimage2addchild (bone density); bone density. X = BMI. y = 200; var testmovie: movieclip = ne W testmovie () as movieclip; addchild (testmovie); testmovie. X = testmovie. y = 180; trace (testmovie); // demo_testmovie3} private function btntestclick (E: mouseevent): void {trace ("btntest has been clicked! ");} Private function btntest2click (E: mouseevent): void {trace (" btntest2 is clicked! ");}}}

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.