Put Button into a Canvas : Canvas « Components « 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 » Components » CanvasScreenshots 
Put Button into a Canvas
Put Button into a Canvas
         
<?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.Scroll ticker symbols across the screen and lets users adjust the speed with an HSlider controlScroll ticker symbols across the screen and lets users adjust the speed with an HSlider control
2.Use Canvas to wrap ButtonsUse Canvas to wrap Buttons
3.Set vertical center and horizontal center for Button inside a CanvasSet vertical center and horizontal center for Button inside a Canvas
4.uses constraint rows and constraint columns to position three Button controls in a Canvas container:uses constraint rows and constraint columns to position three Button controls in a Canvas container:
5.Use Canvas to hold controlsUse Canvas to hold controls
6.A Canvas container with two vertical regions and two horizontal regions
7.A single constraint column that occupies 20% of the Canvas area
8.Canvas background color whiteCanvas background color white
9.Creating a Canvas container by using constraint-based layoutCreating a Canvas container by using constraint-based layout
10.Use a semitransparent Canvas container to highlight the data pointUse a semitransparent Canvas container to highlight the data point
11.Canvas containerCanvas container
12.Canvas RepositionCanvas Reposition
13.Change Canvas cornerRadius and borderStyleChange Canvas cornerRadius and borderStyle
14.Canvas border style solidCanvas border style solid
15.Add style name to CanvasAdd style name to Canvas
w__w__w.___j__a__v_a___2_s.___c__o__m | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.