Subscribe to RSS Subscribe to RSS

 

A few weeks ago, I started rewriting the V3 components from AS2 to AS3. Since I didn’t find any documentation from Adobe on how to create components for the new Flash CS3, I assumed it is done just like in the previous version of Flash. So I started working on AS3 version of LoaderProV3 component and managed to create a working version for AS3. I wrote a class and then, created the .swc file. So, I was happy that I managed to create my first Flash CS3 component, using AS3 coding. The loader does not have any assets so I didn’t bother with the fact that I could edit the assets for Adobe’s new Flash UI components simply by double clicking on the instance on stage.

The next component, how ever, required to do just that. It was a slider component with skinning possibilities, so the user should be able to edit the component’s assets on the stage. A created the component’s .swc file, but it didn’t work like the new Adobe components. After digging a bit through Adobe’s documentation I found out that Flash CS3 now supports .fla based components. Basically, you wouldn’t have .swc file, but a .fla file, containing all the component’s required classes and assets. Now, the big question: how on earth would you do that ? Adobe’s documentation doesn’t really say anything about component creation, only about how to skin the existing components.

I posted a question on one of Adobe’s forums, but it didn’t get answered. I don’t know, maybe I wasn’t clear enough or I just didn’t post it on the right forum. Anyway, I was able to find some valuable information on a few blogs. A step-by-step tutorial on how to build fla-based components for Flash CS3 can be found here (FlashBrighton) and here (you should read the comments too).

Currently, Flash CS3 supports two types of components: swc-based components and .fla based components. If your components don’t need any assets or skinning, probably the traditional .swc components will work just fine. These types of components are created exactly the same way as in Flash 8 or earlier. But if you create visual components, which are skinnable, you should probably choose the .fla based components, since the new way of editing assets is pretty convenient to everybody.

How to create a simple .fla component

In case of .fla based components for Flash CS3, there are a few more steps to follow:

 

  1. First, create your component’s class and .fla files. The .fla file must contain whatever assets you need for the visual part of the component, a component shim, a component avatar and the movie clip corresponding to your component (with the correct linkage id and class associated).
  2. In your .fla file create any artwork and skin clips you need for your component. Give them the linkage ids you need. Next, create an empty movie clip which will have the same name as your component. Don’t forget to give it a linkage id and associate your component’s class to it (Properties panel).

  3. The component’s avatar is basically the bounding box. To create this avatar, you need to create an empty clip and draw a rectangle into it at the x=0 and y=0 coordinates. Then, drag the avatar clip from the Library into the first frame of the movie clip corresponding to your component. This avatar must be the only clip/shape on the first frame of your component’s clip.

  4. The component shim is a compiled clip which has to have embedded into it all the classes your component needs. To create a component shim, you should open a new document and create as many empty clips in the Library as classes you need to embed (if you do not embed the classes into the component shim, you will have to give your component’s users the .fla file along with any .as file it uses). For each movie clip, you have to set in the Properties panel, the class to which it is associated (in case your component uses more than one class). Finally you’ll have to create one more clip and, in the Class edit box, of the Parameters panel, you should write a non-existing class name (you could use even “ComponentShim”, though, I belive it is better to use a different name for each component shim you create for your components). Convert the last clip into a compiled clip and copy it into your component’s .fla file. For any other details about the component shim, you should consult this article on www.flashbrighton.org.

  5. Next, on the second frame your component’s clip, you need to place all the assets of the component: movie clips for the different states of the component, different artwork you need, a focus rectangle (if your component needs one) and the component shim.

  6. Finally, right-click on the component’s clip and open the Component definition panel. Here, you need to set the main class of your component, check the Display in Components panel checkbox (otherwise it won’t appear in the Components panel) and set the Edit frame property to 2 (that way, when the user double clicks on your component, the contents of the second frame will be displayed – the component’s assets). In addition, you may set an icon for your component (click the button under the “Description” label and choose a predefined icon or your own custom one, or you can also use the [IconFile("iconName")] meta tag in your component’s class) and a live preview (if your component needs one).

  7. To set up a live preview from an external .swf file, you need to create a new .fla document which has the fl.livepreview.LivePreviewParent class as document class and place your component on the stage (which has the same height as your component) at the (0, 0) coordinates; next, create the .swf file and, in the original .fla file of your component, give the new .swf file as your component’s live preview, in the Component Definition panel (I usually choose Live preview with .swf file embedded in .fla file).

  8. After you have finished, you need to place the .fla file in the flash components folder

[Windows 2000/XP] Documents and Settings\userName\Local Settings\Application Data\Adobe\Flash CS3\language\Configuration\Components

or

Program Files\Adobe\Adobe Flash CS3\en\Configuration\Components\ - this path works too.

Fla based complex components that contain other components

In case you develop a component that makes use of other components embedded in it (the case of Adobe’s TextArea component which is composed of the TextArea component and the UIScrollBar component), one problem arises.

I’ll give you an example:

If you create a scroll bar component you need to put it into the flash components path to be able to access it from the Components panel. Next, you decide to create a TextArea component which uses the scroll bar component (it will be embedded into the TextArea .fla file). After you finish developing the component, you copy the .fla file to the flash components path. Next time you start Flash CS3, in the Components panel, you will see one TextArea component and two scroll bar components.

This happened to me while I was working on a similar component (it uses another component previously developed by me). I looked into the new Adobe UI components sources and it looks like all the UI components are placed into a single .fla file. Looks like this is the case if you develop visual components that contain other visual components and you want your users to be able to edit the assets by double clicking on the component. This will take them into the second frame of the component, where all the assets are, along with instances of the other components you need. Next, they are able to double click on those components too, to edit their assets. This would be the correct way to customize the component assets but it comes with the previously mentioned cost: you would have to deploy your component along with the other components it uses with a single .fla file. So, if someone would like one of your components used by that complex one that you’ve created, he/she would have to get the .fla file of your complex component, along with all the components it uses.

A work around this inconvenience would be to include the other components into the compiled clip of the component shim, so your component will still have access to those other components but your component’s users wouldn’t be able to directly edit the assets of the other components.

9 Responses to “Create .fla components for Flash CS3”

  1. spender says:

    it’s weird that adobe are leaving it to the community to unpick this new component model, so thanks for sharing your findings. i wonder when adobe will see fit to give us an official line on this?

  2. Alin says:

    Thank you for writing. We’ve discovered many things during the development of the V3 components. The community is a big help always. There are few useful info on Adobe but we hope that we will be able to release the AS 3.0 version working as the CS3 components are.

  3. negush says:

    Indeed, it’s a pity that Adobe left out this (important) part of their documentation. Maybe they would like the ActionScript developers to switch from Flash to Flex… ok… but what about the Flash users ? In case of Flash CS3, most of them are (or will be) probably designers, since Flash is more designer oriented than programmer oriented and Flex is more programmer oriented than designer oriented (at least this is how me and a few other colleagues believe). Anyway, if this would be the case, those designers would need plenty of third party components, since Flash CS3 comes with only a few UI and media components. Who would write those components ? How will they learn to correctly create fla based components for Flash CS3 ?

  4. Serkan Buldan says:

    Yup its good that im not the only one who couldnt find any documentaion about components, good work mate.

  5. alindogar says:

    I’m sure that sooner or later we will figure out how to build components for Flash CS3 designers. And I’m sure that the community will find solutions to this issue. However, any suggestions, ideas and messages will be appreciated :).

  6. Darren Ortiz says:

    I was wondering if by using this method to create a component in CS3 if I would be forced to export as version 9. I would love to be able to build a component in the CS3 authoring environment but I can’t be restricted to using version 9 as a publish setting.

    Thanks! Great article.

  7. negush says:

    Well, Darren, if you create components using Flash CS3 and ActionScript 3.0, you won’t be able to use them in older versions of Flash. But you can still create ActionScript 2.0 components using Flash CS3 and install them in Flash 8 (I’ve already tried it).

  8. negush says:

    Finally, Adobe did post a report on how to create fla based components for Flash CS3. Here’s the link to the page: http://www.adobe.com/devnet/flash/articles/creating_as3_components.html

  9. I am facing a problem with component development where my component contain other components. After pasting my fla file to Components folder, Flash shows other components which are used in my component. I tried your workaround but it doesn’t works for me. Could you please explain a bit on how not to display the default components which are used in my component.

    What I have done:
    I created a Component Shim for my component by
    1.creating a blank MovieClip
    2.naming its class as MyComponentShim
    3.then converted it to Compiled clip
    4. Rename as MyComponentShim
    5. Replace default Component Shim with the one I created above and then compile my component again.
    6. Paste it to Components Folder.

    Please help me with this. I don’t want to display the default components used by my Component.

    Looking forward to your response.


    Chetan Sachdev


Leave a Reply