I wrote this article ages ago, and it was originally had “for CS3” in the title I think, but they took it out when I told them it didn’t really need to be updated for CS3. It has oodles of information in it about the User Interface AS3 components included with Flash Authoring.

http://www.adobe.com/devnet/flash/articles/creating_as3_components.html

So this is hardly like hot off the press news, but this article is useful and I fully expect I will reference it in my posts so that I can avoid typing all that stuff again.

13 Comments

  1. Eldes says:

    Congratulations! Excellent article!

    However, the properties that I set using the metatag Inspectable does not appear in Component Inspector (even after you generate the SWC and reload the panel Components).

    Is there any hint/tip?

  2. jeff says:

    Eldes: I can make some guesses as to what your issue might be. First make sure you are dragging the component from the component panel into a new FLA when you want to test the properties. Don’t try dragging the SWC component into the FLA that you used to generate the SWC. If you have a FLA that you are working with that already has an older version of the component, after you create a new one and refresh the component panel, you still need to drag the component into your library and click OK in the dialog asking if you want to replace the old version. Finally you might be testing in the FLA which you used to make the component, which you can do, but in this case to get the inspectable properties to appear you need to right click on the symbol in the library, select component properties, put the name of your class in the class field in that dialog and click OK. I hope one of those things is your problem!

  3. Eldes says:

    Jeff, thank you for reply. I have done all those things but nothing solved.
    Worst: my first component that I developed works fine, but the second don’t.

    I have: generate the SWC; refreshed the Component panel (reload command); dragged in other FLA for test (replacing the old version); and the property don’t appear in Component Inspector yet.

    When I find the solution for this problem, could I post here?

    Thank you again.

    (sorry for my bad English)

  4. Jeremy says:

    Hey Jeff –

    I followed your excellent article and I have a question for you. My component works great – it just draws a few things with colors that are specified as parameters, and has a text field whose text comes from a parameter.

    The only problem is that live preview barely works. I can see the component as it appears with its default parameters, but when I update an instance’s parameters in the component inspector, the element on the stage does not change to reflect the new parameter values. Do you have any idea what I could be missing? It’s surprising because the parameters work fine when I view the movie; they just don’t work in design mode (Flash CS4). I’ve been searching all day and the documentation on these things is a bit lacking!

    Thanks,
    Jeremy

  5. Basel says:

    Thanks for the great work put in compiling this article.

    I have done everything! My component works great in my original fla. Live Preview works like a charm.

    However,… Copying my component to a new fla creates this strange preview (phantom)… once you change any property… it does not show anything.. the component compiles great but the preview does not show…

    Also, i tried packaging the component into and mxp.. it worked and showed in the components panel but could never show live preview.. what have i missed.

    Is there some REAL documentation on the structure of uiComponent class.

    Pleaaaaaaaaase help… my hair is really getting thinner by the minute!

  6. Steve says:

    Hi Jeff,

    I couldn’t find the downloadable files for the introduction that you talk about in the second installment of the series.

    Could you tell me where I might find them.

    Thanks,

    Steve

  7. jeff says:

    Steve, the downloadable files for this article should be linked to other parts of the article. I know there are files linked to parts 2 and 3, for example, but i guess none linked to the introduction, part 1.

  8. Claudio says:

    Excellent article, Jeff! (There should be a whole book about this topic)

    I have a problem, though. I’m basing my component on the Label, and when I clean up my library and replace the Label symbol with the ComponentShim (part 5), my component simply stops displaying – not only in Live Preview. No error or warning is generated, which makes me think that I’m missing some very subtle step here.

    Thanks in advance.

  9. Claudio says:

    I think the problem was due to the fact that I had set up properties (getters and setters) for width and height (without having read through the article entirely and learned how to do it properly).

    Thanks anyway!

  10. Quasimodem says:

    Hi Jeff, many thanks for your excellent articles, deep Flash explanations are a rare find on the internet 🙂

    I’ve been wrestling lately with what appears to be a bug in Flash that prevents me from specifying an enumeration on any of my [Inspectable] elements within a CollectionItem. For example, within your ItemExample.as, if I modify the “stringData” property’s metadata to:

    [Inspectable(defaultValue=”string”, enumeration=”value1,value2″)]

    Flash incorrectly saves the values I put into any Collection that contains CollectionItems of this type.

    If I save my file to .xfl, I observe the following:

    The format of the element’s “defaultValue” property looks to be something like:
    (stringData, 5, string, value1,value2)
    … PropertyName, PropertyType, DefaultPropertyValue, PossiblePropertyValues, …

    I’m guessing the commas in “value1,value2” are confusing the parser, as Flash is unable to repopulate my data correctly when I re-open my .xfl (or .fla). Adding new CollectionItems to the Collection breaks things even further, as the “numberData” property appears to now be called “value2”, and so on, everything shifted to the right by one.

    I’m not too hopeful for finding a workaround to this problem, it looks like something only somebody with access to the parser source can fix 🙂 But if you can think of any secret hacks to get around this, I would love to hear them!

  11. Quasimodem says:

    Oops I realized that my XML snippet got purged from the previous post, let’s try again:

    < Inspectable name=”dataSource” variable=”dataSource” category=”” verbose=”0″ defaultValue=”fl.example.CollectionExample, fl.example.ItemExample, id, 3, id, 5, , , stringData, 5, string, value1,value2, numberData, 6, 0.0, , 1, id0, value1, 0.0″ type=”Collection”/ >

  12. jeff says:

    @quasimodem it does appear that it is not possible to set up an enumeration list inside a CollectionItem. Sorry about that! Wish I could give you a clever work around, but there is not one at this time as far as I know.

  13. Quasimodem says:

    Hi Jeff, thanks for the info about enumerations in Collections. I saw a recent CS5.5 patch note go by about “…fixes for opening and saving some Flash Professional files”. I wonder if this is related?

    I’ve got another Collections mystery I’m trying to solve – I’d like to add some default data to a Collection so that Flash’s Values dialog (when editing the collection from the Component Parameters view) is pre-populated with a few entries.

    Unfortunately, it looks like the [Collection] metadata tag doesn’t have a “defaultValue” attribute to set. Likewise, adding an entry to the property in question in my class’ constructor doesn’t do what I want either.

    Is this another dead-end or do you know of a way to accomplish this? Many thanks again!