Pass a string and Event object to method : Event Object « Event « Flex






Pass a string and Event object to method

Pass a string and Event object to method
           
<?xml version="1.0"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml">
    <mx:Script>
        public function runMove(dir:String, e:Event):void {
            if (dir == "up") {
                moveableButton.y = moveableButton.y - 5;
            } else if (dir == "down") {
                moveableButton.y = moveableButton.y + 5;
            } else if (dir == "left") {
                moveableButton.x = moveableButton.x - 5;
            } else if (dir == "right") {
                moveableButton.x = moveableButton.x + 5;
            }
        }
      </mx:Script>
    <mx:Canvas height="100%" width="100%">
        <mx:Button id="moveableButton"
            label="{moveableButton.x.toString()},{moveableButton.y.toString()}"
            x="200" y="200" width="80" />
    </mx:Canvas>
    <mx:VBox horizontalAlign="center">
        <mx:Button id="b1" label="Up" click='runMove("up",event);' width="50" />
        <mx:HBox horizontalAlign="center">
            <mx:Button id="b2" label="Left" click='runMove("left",event);' width="50" />
            <mx:Button id="b3" label="Right" click='runMove("right",event);' width="50" />
        </mx:HBox>
        <mx:Button id="b4" label="Down" click='runMove("down",event);' width="50" />
    </mx:VBox>
</mx:Application>

   
    
    
    
    
    
    
    
    
    
    
  








Related examples in the same category

1.Cast Event object for only property accessCast Event object for only property access
2.Pass a string and the Event object to the runMove() methodPass a string and the Event object to the runMove() method
3.Define object type as EventDefine object type as Event
4.Access SecurityErrorEvent object's text propertyAccess SecurityErrorEvent object's text property
5.Disables interactivity for events on the first and third PlotSeries objectsDisables interactivity for events on the first and third PlotSeries objects
6.Create event objectCreate event object
7.Event Object PropertiesEvent Object Properties
8.Event type and textEvent type and text
9.Event typeEvent type
10.Log event information to TextAreaLog event information to TextArea