Skip to main content
Known Participant
September 8, 2008
Question

Compiler Keywords

  • September 8, 2008
  • 3 replies
  • 815 views
I had a question about some compiler options in AS3. I've already googled this and I can't really find anything on it.

There are a bunch of seeming "annotations" that I'm finding as I'm exploring Flex and Flash CS3 components, of which, here are a few:
[Inspectable], [Bindable], [Event], [Embed], [Style] and a few others that I can't think of off the top of my head.
My question is what are these tags and where can I find documentation on them? My understanding is limited to the [Event] and [Embed] tags, and I'm not so sure that I understand those completely. I'm assuming the [Event] tag is strictly for ASDoc to find the types of events that can be dispatched from a class so they can be included in documentation. I know that the [Embed] tag specifies a file to be embedded in the application just as a asset can be embedded in a fla's library. So, where can I find the documentation on the others? Also, do they all apply in certain scenarios and not others? Like, is [Bindable] only applicable in Flex projects? Is there Adobe documentation available for these commands?

- TK
This topic has been closed for replies.

3 replies

rfkrocktkAuthor
Known Participant
September 9, 2008
So is [Bindable] simply an event listener?
So I could define my own implementation of a collection which dispatches data change events when an item is added, removed, invalidated, etc? Is that it? Can I bind strings together or other simple items?
So I can totally implement my own data binding system just through AS3's event system? Would I be able to use the [Bindable] meta tag or do all my binding through code?
I'm aware that I can use Flex classes in AS3 without using MXML. I'm just trying to get a feel for data bindings and where they're applicable and where they're not.

- TK
Inspiring
September 9, 2008
The basic principal of [Bindable] is that an event gets dispatched when a datacollection has changed. This comes from the ListCollectionView, the super class of the ArrayCollection in the Flex framework:

[Event(name="collectionChange", type="mx.events.CollectionEvent")]

A subscribed listener (in Flex set by the dataprovider property of a component) receives this event and redraws.

I don't know the exact inner workings of the [Bindable] compiler directive so I don't know if you can use the directive in your own implementation. But if you download the open source Flex framework you can probably study that.

If your custom object can receive the datachange event and it has a mechanism to update its state accordingly... well, you have a form of binding. Trick is to achieve it using such a simple directive as [Bindable].
rfkrocktkAuthor
Known Participant
September 9, 2008
So [Bindable] is not applicable or usable at all in strict AS3?
**EDIT** Also, can I improvise my own sort of data bindings in AS3? IE: is it possible for me to create my own data binding system?
Inspiring
September 9, 2008
No, [Bindable] can also be used when you develop components and you are using components that support databinding (remember, you can either set the property in the component inspector (the [Inspectable]) or declare a property explicitly to be [Bindable]). BTW, when you are using the Flex framework, you can also create AS only projects. I use Flexbuilder or FDT for development and compile all projects with the Flex SDK.
Inspiring
September 9, 2008
Yes, you can. Being Bindable simply means that the datacollection is broadcasting a message that is has changed. The subscribed listener receives the message and 'redraws'.
Inspiring
September 9, 2008
Here http://www.adobe.com/support/documentation/en/flash/ you will find an overview of available documentation and in the Programming ActionScript 3.0 pdf you will probably find the documentation you are looking for.

Yes, [Bindable] is applicable in the Flex framework. It has - for instance - special datacollections (like ArrayCollection) that broadcast messages when they are updated to subscribed listeners.

>>I'm assuming the [Event] tag is strictly for ASDoc
No, you let other classes (objects) know that the class can send out specific events, so you subscribe to them in other objects. Think of it as adding a property to your object. Just as with any other property, the compiler needs to know of them. Also, in an API you want other developers to know which events can be broadcasted by your object.

The [Embed] directive is a great one. It enables you to have a library of assets in a compiled swf (or a set of swc's) and from that point on, you can compile with IDE's like Flexbuilder, FD and FDT, from the command line or with ANT. Really great because you don't code in one application and build in the Flash IDE, because of the speed of the mxmlc and fcsh compilers. Great too if you want to seperate tasks between designers and developers.