flash on 2011-2-1

by vizio360
♥2 | Line 71 | Modified 2011-02-01 08:07:35 | MIT License
play

ActionScript3 source code

/**
 * Copyright vizio360 ( http://wonderfl.net/user/vizio360 )
 * MIT License ( http://www.opensource.org/licenses/mit-license.php )
 * Downloaded from: http://wonderfl.net/c/kWDP
 */

package {
    import flash.display.Sprite;
    public class FlashTest extends Sprite {
         
        public function FlashTest() 
        {
            // write as3 code here..
            //var t:Track = new Track();
            //t.settaStringa("culo");
            //addChild(t);
            
            var next:Sprite = getButton(0xFF0000);
            var prec:Sprite = getButton(0x00FF00);
            //TODO 
            //add navigation buttons to scroll the list
            //and scroll the list :)
            
            var items:Vector.<Track> = new Vector.<Track>();
            
            for (var i:int = 0; i < 13 ; i++)
            {
                var trackTmp:Track = new Track();
                trackTmp.settaStringa("item "+i);
                items.push(trackTmp);
            }
            
            var list:TrackList = new TrackList();
            addChild(list);
            
                        
            list.tracks = items;
            
            
            list.show();
              
            
            
            
        }
        
        private function getButton(color:int):Sprite
        {
            var btn:Sprite = new Sprite();
            btn.graphics.beginFill(color, 1);
            btn.graphics.drawCircle(0,0, 40);
            btn.graphics.endFill();
        }

    }
}
import flash.text.TextField;
import flash.display.Sprite;

internal class TrackList extends Sprite
{
    public var tracks:Vector.<Track>;
    
    
    public function show():void
    {
        var midStageY:Number = this.stage.stageHeight / 2; 
        var gap:int = 10;
        var nextTrackX:Number = this.stage.stageWidth/2 - ((Track.LARGHEZZA + gap ) * (tracks.length/2));
        
        for (var i:int = 0; i < tracks.length; i++)
        {
             var track:Track = tracks[i];
             track.y = midStageY - track.height;
             track.x = nextTrackX + gap;
             nextTrackX += track.width + gap;
             addChild(track);
             
        }

    }

    
}


internal class Track extends Sprite
{
    private var myTF:TextField;
    
    public static var LARGHEZZA:int = 82;
    public static var ALTEZZA:int = 76;
    
    public function Track()
    {
        myTF = new TextField();
        myTF.width = 70;
        addChild(myTF);
        myTF.text = "cacca";
        graphics.beginFill(0xCBCBCB, 1);
        graphics.drawRect(0,0, LARGHEZZA, ALTEZZA);
        graphics.endFill();
        
    }
    
    public function settaStringa(str:String):void
    {
        myTF.text = str;
    }
    
    public function select():void
    {
        
    }
    

}

Forked