Learning Flex – Lesson 3, Part II

View States

note – this all changes for Flex 4 (Gumbo) containers.

States are defined within a States tag. Each State has a name specified. Within the State tag, you can change object properties, add or remove child objects.

To set a property, use SetProperty target=”{id of object}” name=”name of property” value=”new prop value“.

To add a child, the relativeTo property specifies the parent container, the positon attribute (before,after,firstChild,lastChild – default) specifies where the child will be placed. The child object can then be defined before the closing AddChild tag.

To remove a child, the target attribute is used to specify the id of the child to be removed.

Objects are only added or removed while the application is in that state, changing state to something else will switch back to the parent state as a baseline.

To change the state in the application, set this.currentState=”state name” (this references the application object and currentState is an attribute for it). Setting the current state to empty string (“”) sets the application to the initial or default state.

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: