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

Home
Flex
1.Chart
2.Components
3.Container
4.Data Model
5.Development
6.Effects
7.Event
8.Graphics
9.Grid
10.Style
Flex » Event » Event ObjectScreenshots 
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
java2s.com  | Contact Us | Privacy Policy
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.