1 Reply Latest reply on Sep 16, 2007 4:12 PM by Senor_Roberto

    Changing States inside a function

    leeng
      I want to change states based on the extension of a source file that I am reading from an XML file (ie., switching between a videoDisplay to show an .flv file or a SWFObject to show a .swf file). However, all the examples I've seen in changing states always uses the click method - eg., click = "currentState = 'newState'". I thought I could call a function in the click method - click = "myfunction();" and in the function call a change state after mu evaluations but I am not sure how to return the currentState or call a currentState method in the function.

      I thought currentState might be a property of application or I could return a string from the function with currentState = 'myState' but neither of those approaches seemed to work.

      I'd appreciate any clues, hints or info if this is possible.

      Thanks,
      Hoyt
        • 1. Re: Changing States inside a function
          Senor_Roberto
          Current state isn't a method, it's a property of the current component you're in. If you're in an mx:Script block, you should just be able to refer to it:

          <mx:Script>
          <![CDATA[
          function handleClick (event:Event) : void {
          // Do some stuff
          currentState = "someState";
          }
          ]]></mx:Script>

          <mx:Button label="Click me" click="handleClick(event)"/>