Scroll ticker symbols across the screen and lets users adjust the speed with an HSlider control : Canvas « Components « Flex






Scroll ticker symbols across the screen and lets users adjust the speed with an HSlider control

Scroll ticker symbols across the screen and lets users adjust the speed with an HSlider control
    

<!--
Code from Flex 4 Documentation "Using Adobe Flex 4".

This user guide is licensed for use under the terms of the Creative Commons Attribution 
Non-Commercial 3.0 License. 

This License allows users to copy, distribute, and transmit the user guide for noncommercial 
purposes only so long as 
  (1) proper attribution to Adobe is given as the owner of the user guide; and 
  (2) any reuse or distribution of the user guide contains a notice that use of the user guide is governed by these terms. 
The best way to provide notice is to include the following link. 
To view a copy of this license, visit http://creativecommons.org/licenses/by-nc-sa/3.0/

-->



    <!-- layoutperformance/CallLaterTicker.mxml -->
<s:Application xmlns:fx="http://ns.adobe.com/mxml/2009"
    xmlns:mx="library://ns.adobe.com/flex/mx" xmlns:s="library://ns.adobe.com/flex/spark">
    <fx:Script> 
        [Bindable] 
        public var text:String = "SLAR:95.5....TIBA:42....RTF:34.15....AST:23.42"; 
        [Bindable] 
        public var speed:Number = 5; 
        public function initTicker():void { 
            theText.move( this.width+10, 0 ); // Start the text on the right side. 
            callLater(moveText); 
        } 
        public function moveText():void { 
            var xpos:Number = theText.x; 
            if( xpos-speed+theText.width < 0 ) { 
                xpos = this.width+10; // Start the text on the right side. 
            } 
            xpos -= speed; 
            theText.move(xpos,0); 
            callLater(moveText); 
        } 
        public function changeSpeed():void { 
            speed = speedSelector.value; 
        } 
      </fx:Script>
    <s:Panel title="Ticker Sample" width="400" height="200">
        <s:VGroup>
            <mx:Canvas creationComplete="initTicker()"
                horizontalScrollPolicy="off" backgroundColor="red" color="white"
                width="400">
                <mx:Label id="theText" text="{text}" y="0" />
            </mx:Canvas>
            <mx:HBox>
                <mx:Label text="Speed:" />
                <mx:HSlider minimum="1" maximum="10" value="{speed}"
                    id="speedSelector" snapInterval="1" tickInterval="1" change="changeSpeed()" />
            </mx:HBox>
        </s:VGroup>
    </s:Panel>
</s:Application>

   
    
    
    
  








Related examples in the same category

1.Put Button into a CanvasPut Button into a Canvas
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