Use SWC In Flex to achieve better interface code separation

Source: Internet
Author: User

I wrote an article "How to Implement interface code separation in Flash development" a few days ago. In the comments, Mr. G gave a better suggestion: SWC. I tried it today, it's really better than embed SWF! At the same time, I would like to express my gratitude to Mr. Xiao-G!

Take the control of the Video Player for example:

We usually put some general control buttons in the library by using the IDE interface of Flash CS.

If you follow the embed SWF method, you need to manually useCodeCreate instances of each type of Button, control the location one by one, and then addchild; in fact, this type of button always appears together in actual scenarios, it is better to put them together (like the custom controls in Asp.net) as a whole.

OK. Then, create a movieclip for controlbuttonbar in the database.

Note: In controlbuttonbar, specify a name for each button instance (so that the button can be referenced in the Code)

Export the file as a SWC File

 

The exported SWC file name can be written at will. I will save it as "controlbuttonbar. SWC ", the interface is partially done, you can turn off Flash CS, and then enable flex builder to create a project (I am used to using the ActionScript project ), right-click the project and choose Properties> ActionScript buildpath> libarypath> Add SWC

Select the SWC file you just exported, and click OK to observe the project. In referrnced libraries, you can see the reference to this SWC (just like viewing the reference in vs.net ).ProgramSet)

After these steps are completed, you can enjoy them in the Code:

How is it? This is no worse than vs.net.

 

Note: SWC feels like a user-defined control in. net.

 

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.