0

hi guys my problem is when i create a button in state 1 and click on it according to code it should make a group in another state named as expand. However according to my code it is still making group in current state 1. any guidance will be appreciated.

               mybutton.addEventListener(MouseEvent.CLICK, max);

public function max(event:MouseEvent):void
           {
               currentState = 'expand';
               var s:String;
               s = "abc";
               var myGroup:Group = new Group();
               myGroup.id = s;
               addElement ( myGroup );
               container_Class2(myGroup);

           }
Muhammad Umar
  • 11,391
  • 21
  • 91
  • 193
  • addElement( myGroup ) will add this VisualElement to the view hierarchy irrespective of the states and it will be visible in all your states. – M.D. Sep 26 '11 at 15:41

1 Answers1

0

currentState is just a property of your class, there is no such things as "creating something in a state". If you add an element to your class it will exist whatever the state is.

You can create an element as a child of a container which appears only in a specific state:

<s:Group id="expandContainer" includeIn="expand" />

...

expandContainer.addElement(myGroup);
Kodiak
  • 5,978
  • 17
  • 35