How to Use SWC In Flex

Source: Internet
Author: User

Before talking about how to import SWC In Flex, let's talk about SWC first. SWC is a file format in which flash ide exports data to and from the database. It is composed of SwF + XML. If you are not familiar with how to make flash, you can familiarize yourself with the materials used to make SWF Using Flash IDE. Now I will only talk about how to successfully export SWC in flash.

Before exporting SWC in flash, you need to create an export link for the components in your flash library. Select the component you want to export, right-click it, and select Properties. Then, select export in the Action column and export in the 1st frame. Class Name: name of the class to be generated in flex. It is recommended that the default name be the component name. Note that the first letter is capitalized.

After creating the export link, the next step is how to export the SWC file. You can export SWC files in two ways. One is to select and right-click the component to be exported to export the SWC library file. Note: This is exported as a library instead of a component. Therefore, you can create multiple component links and select a component for export. Other components will be exported. However, as long as you make a component connection, it can be generated in flex.

The second method is SHIFT + Ctrl + F12. In the pop-up Line Selection Panel, select the flash tab and select the export SWC file option. The internal mechanism for SWC export is the same as the above one.

Now let's talk about how to use SWC files in flex. Create an ActionScript project in flex, select a project in the navigation bar, select the ActionScript build path, select the library path, select Add SWC, and import the swc library path generated above, OK. OK! Added successfully.

The following describes how to generate components in the SWC library just imported in the ActionScript project. You can simply create a new component class name that I mentioned in flash and add it to the display list. Run F11. OK ~~ Is it easy? Okay, let's take the first step towards making a flex game in Ria ~!

 

As we all know, the components provided in Flash greatly facilitate developers' use and improve development efficiency. Flash allows custom (self-developed) components, that is, you can extract your own applications or modules and make them into SWC components for use by other developers, it is really convenient for many developers (especially those who are not familiar with Flash Action Script Programming, such as designers and animation producers). In a team, the component development mode is also a good way to facilitate collaborative work.

In Flash CS3, you can easily create SWC components. Read this article:

Http://www.richbox.net/blog? P = 255

The following uses creating a circular component as an example to show how to easily create a SWC component in Flash cs4:

1. First open flash cs4, switch to the "Developer" view, find the project panel, and create a project

2. Create a FLA document named "circulardemo. fla"

3. Use a drawing tool to draw a circle and convert the graph into a movie clip named Circular

4. Return to the project panel and create an Action Script class circular. Be sure to bind it to the movie clip created in step 3. You can set it as follows:

5. paste the following code into the new class to replace the original code.

[ActionScript]

Package {
Import flash. display .*;
Import flash. Geom. colortransform;
Public class circular extends movieclip {
Protected var bgcolor: uint;
Private var S: colortransform = new colortransform ();
Public Function circular (){
Super ();
Trace ("Circular is created ");
}
[Inspectable (type = "color", defaultvalue = "#000000")]
Public Function get backgroundcolor (): uint {
Return bgcolor;
}
Public Function set backgroundcolor (value: uint): void {
Bgcolor = value;
S. Color = bgcolor;
Transform. colortransform = s;
}
}
}

[/ActionScript]

6. Find the circular movie clip on the library panel, right-click and select "component definition", enter circular in the class column, and check the option ,:

7. click OK, the preparation is complete, and then return to the library panel, find circular, right-click and choose "Export SWC file" to export the SWC file. Save the file in the default path, it should be saved in the Custom component folder. This component will appear in the component Panel later.

8. Close the current file, restart flash cs4, create a FLA document, and select the standard components directory in the component panel to expand it. The SWC component we just created is displayed.

9. Drag this component to the scene and change the background color in the component property panel. Check whether the color of the component in the scene has changed?

10. Now a simple SWC component has been created. You can develop richer and more available components based on this principle.

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.