A Flash Developer Resource Site

Results 1 to 7 of 7

Thread: contentLoaderInfo Help

  1. #1
    Senior Member Shotsy247's Avatar
    Join Date
    Apr 2001
    Location
    Be there in a minute!
    Posts
    1,386

    contentLoaderInfo Help

    Hi All,

    I am trying to learn about the contentLoaderInfo property and have this code:

    Code:
    var thisLoader:Loader = new Loader();
    var loaderStat:TextField = new TextField();
    this.addChild(loaderStat);
    thisLoader.contentLoaderInfo.addEventListener(Event.OPEN, handleOpen);
    thisLoader.contentLoaderInfo.addEventListener(ProgressEvent.PROGRESS, handleProgress);
    thisLoader.contentLoaderInfo.addEventListener(Event.COMPLETE, handleComplete);
    thisLoader.load(new URLRequest("Sebastian.jpg"));
    thisLoader.x = 200;
    thisLoader.y = 200;
    thisLoader.scaleX = .05;
    thisLoader.scaleY = .05;
    this.addChild(thisLoader);
    
    function handleOpen(e:Event):void{
    	loaderStat.text = "Loading: 0%";
    }
    function handleComplete(e:Event):void{
    	removeChild(loaderStat);
    	loaderStat = null;
    }
    function handleProgress(e:ProgressEvent):void{
    	var percent:Number = e.bytesLoaded / e.bytesTotal * 100;
    	loaderStat.text = "Loading: "+percent+"%";
    }
    From what the book I'm reading tells me, this should update the loaderStat textField as the image loads, but it is not. It is only showing 0% loaded and then the loaded image a bit later, no progress.

    Where am I or the book going wrong here? I guess I'm looking for an upDateAfterEvent or something.

    Thank you in advance.

    _t
    I don't feel tardy.

  2. #2
    Senior Member
    Join Date
    Jan 2001
    Posts
    567
    Works ok for me. If you comment out the Event.COMPLETE you'll be able to see it finished at 100%, but it just may be too fast to see it count up. (If you're testing it locally you won't see it.)

    Do some traces to see if the ProgressEvent is triggering correctly for you.

  3. #3
    Senior Member Shotsy247's Avatar
    Join Date
    Apr 2001
    Location
    Be there in a minute!
    Posts
    1,386
    That's odd. When I simulate download I do see it too, but when I do not and the image is already cached it takes a moment to appear. It seems like .25 of a second anyway, so I thought I should see some loading going on during that time, but I guess the delay is something else.

    Thanks.

    _t
    I don't feel tardy.

  4. #4
    Mod cancerinform's Avatar
    Join Date
    Mar 2002
    Location
    press the picture...
    Posts
    13,448
    Have you tested on the server? That is the best test.
    - The right of the People to create Flash movies shall not be infringed. -
    | www.Flashscript.biz | Flashscript Biz Classes/Components |

  5. #5
    Senior Member Shotsy247's Avatar
    Join Date
    Apr 2001
    Location
    Be there in a minute!
    Posts
    1,386
    Not on the server yet. I'd like to get it working in the testing enviornment before I post to the server.

    Actually, I'm just trying to learn so I have no intention of posting to the server.

    _t
    I don't feel tardy.

  6. #6
    Mod cancerinform's Avatar
    Join Date
    Mar 2002
    Location
    press the picture...
    Posts
    13,448
    The reason why I said to test it on the server is because that is reliable. I never trust the download simulation.
    - The right of the People to create Flash movies shall not be infringed. -
    | www.Flashscript.biz | Flashscript Biz Classes/Components |

  7. #7
    Senior Member Shotsy247's Avatar
    Join Date
    Apr 2001
    Location
    Be there in a minute!
    Posts
    1,386
    Good point.

    Thanks.

    _t
    I don't feel tardy.

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