In case Flash no longer exists; a copy of this site is included in the Flashpoint archive's "ultimate" collection.

Dead Code Preservation :: Archived AS3 works from wonderfl.net

プログレスバーのテスト

Get Adobe Flash player
by tepe 08 Jun 2012
/**
 * Copyright tepe ( http://wonderfl.net/user/tepe )
 * MIT License ( http://www.opensource.org/licenses/mit-license.php )
 * Downloaded from: http://wonderfl.net/c/37U1
 */

package {
    import flash.display.Sprite;
    import flash.events.*;
    import flash.text.*;
    public class FlashTest extends Sprite {
        private var tf:TextField = new TextField();
        private var pb:progressBar =new progressBar();
        public function FlashTest() {
            // write as3 code here..
            graphics.beginFill(0);
            graphics.drawRect(0,0,466,466);
            graphics.endFill();
            addChild(pb);
            pb.x = 133;
            pb.y = 200;
            addChild(tf);
            tf.textColor=0xffffff;
            tf.x = 200;
            tf.y = 240;
            addEventListener(Event.ENTER_FRAME,onFrame);
        }
        private var cnt:int=0;
        private var max:int=1000;
        private function onFrame(e:Event):void{
            if(cnt<max)cnt++;
            pb.update(cnt/10);

            tf.text = cnt.toString()+" / "+max.toString();
        }

    }
}
import flash.display.*;
import flash.events.*;
class progressBar extends Sprite{
    private var color1:uint = 0x223388;//青
    private var color2:uint = 0x4488ff;
    private var _width:Number = 200;
    private var _height:Number = 20;
    private var _pt:Number = 0;
    private var _max:Number = 100
    public function progressBar(){
        update();
    }
    public function reSize(width:Number,height:Number):void{
        if(0<width)_width=width;
        if(0<height)_height=height;
    }
    public function set max(n:Number):void{
        _max=n;
    }


    public function update(par:Number=0):void{
        _pt = par;
        if(_pt<0)_pt=0;
        else if(_max<_pt)_pt=_max;
        
        
        graphics.clear();
        graphics.beginFill(color1);
        graphics.drawRect(0,0,_width,_height);
        graphics.endFill();
        
        graphics.beginFill(color2);
        graphics.drawRect(0,0,_width/1*(_pt/_max),_height);
        graphics.endFill();
    }


}