A Flash Developer Resource Site

Results 1 to 4 of 4

Thread: testing progress bar

  1. #1
    Member
    Join Date
    Oct 2008
    Posts
    48

    testing progress bar

    Hello

    I followed some tutorial on how to make a progress bar using actionscript 3 (I'm a beginner).

    Is there any way so that I can test the result of progress bar on local machine (where it obviously doesnt have to load any resources to take any time) ?

    Would like to see the result and play with it a bit to get more familiar.

    Many thanks in advance!

  2. #2
    Total Universe Mod jAQUAN's Avatar
    Join Date
    Jul 2000
    Location
    Honolulu
    Posts
    2,429
    while in test movie, go to View -> Download Settings -> 14.4 then View -> Simulate Download.

  3. #3
    Member
    Join Date
    Oct 2008
    Posts
    48
    Thanks a lot!

  4. #4
    Member
    Join Date
    Oct 2008
    Posts
    48
    Althought I set the download simulation to the slowest option, it will only hold empty screen for a while and then print 100% text.

    Heres the code I use (as a main class):

    Code:
    package {
        
    import flash.events.*
    import flash.display.Sprite;
    import flash.text.*
    
    public class Base extends Sprite {
    	private var loadBar:Sprite;
    	private var _tf:TextField;
    	private var _fmt:TextFormat;
    
    	public function Base() {
    	    preload();
    	}
    
    	private function preload() {
    	    this.loaderInfo.addEventListener(Event.COMPLETE, initApplication);
    	    this.loaderInfo.addEventListener(ProgressEvent.PROGRESS, showProgress);
    		
    	    with (this.graphics) {
    			beginFill(0xFFFFFF)
    			drawRect(10,stage.stageHeight-50,300,10)
    	    }
    		
    	    loadBar = new Sprite()
    	    addChild(loadBar)
    
    	    _fmt = new TextFormat("_sans", 11, 0xCCCCCC);
    	    _tf = createText();
    	    addChild(_tf);
    	    _tf.x = 9
    	    _tf.y = stage.stageHeight - 40
    	    
    	}
    	private function showProgress(e:ProgressEvent):void {
    	    var percent:Number = Math.round((e.bytesLoaded / e.bytesTotal )*100 );
    	    
    		trace(percent + " %");
    
    	    with (loadBar.graphics) {
    			clear()   
    			beginFill(0x000000)
    			drawRect(10,stage.stageHeight-50,3*percent-2,8)
    			endFill()
    	    }
    
    	    _tf.text = "Loading: "+ percent + " %"
    	}
    	private function initApplication($e:Event):void {
    	    this.graphics.clear()
    	    loadBar.graphics.clear()
    		
    	    _tf = null
    	    new Application()
    	}
    	
    	private function createText():TextField {
    	    var t:TextField = new TextField();
    	    t.width = 0;
    	    t.height = 0;
    	    t.autoSize = TextFieldAutoSize.LEFT;
    	    t.selectable = false;
    	    t.defaultTextFormat = _fmt;
    		return t;
    	}
    }
    Any idea what am I doing wrong?

    Many thanks for help!

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  




Click Here to Expand Forum to Full Width

HTML5 Development Center