A Flash Developer Resource Site

Results 1 to 3 of 3

Thread: Loader issues

  1. #1
    anyone else hear that? flashpipe1's Avatar
    Join Date
    Jan 2003
    Location
    Upstate NY
    Posts
    1,930

    Loader issues

    Alright, I've inherited someone else's code and everything seems to be working pretty good, but, sometimes (and it's not consistent), the pages that are loaded into the shell seem to "fail" while loading. On a faster connection, I have no problems. On a slow connection, the page will start loading, go up to a certain percent (different for different pages) and then stop. If I refresh the shell and go back to that page, it will stop at the same loading amount. If I re-upload the swf file to the server, it usually fixes itself. If I try to access that page from another machine, it doesn't freeze at the same point and, often, doesn't freeze at all. Can't consistently reproduce it or fix it, but it's making me crazy so, was wondering if anyone sees anything in the loading code that might cause that? Here it is:

    Code:
    var loader:Loader = new Loader();
    var pcent:Number;
    
    function loadLesson(slide:int){
    	CurrentSlide = slide;
    	unloadSwf();
    	loader.load(new URLRequest(Slides[CurrentSlide]));
    	loader.contentLoaderInfo.addEventListener(ProgressEvent.PROGRESS, loadProgress);	loader.contentLoaderInfo.addEventListener(Event.COMPLETE,loadComplete);	
    }
    
    function loadProgress(e:Event){
    	loading.visible = true;
    	pcent = (loader.contentLoaderInfo.bytesLoaded / loader.contentLoaderInfo.bytesTotal)*100;
    	loading.bar.scaleX = (loader.contentLoaderInfo.bytesLoaded / loader.contentLoaderInfo.bytesTotal);
    	if(Math.ceil(pcent)>1){
    		loading.perc.text = Math.ceil(pcent).toString() + "%";
    	}
    }
    Love like you've never been hurt, live like there's no tomorrow and dance like nobody's watching.

  2. #2
    . fruitbeard's Avatar
    Join Date
    Oct 2011
    Posts
    1,785
    Hi,

    If you can attach the *.fla perhaps I can take a look and help.

  3. #3
    . fruitbeard's Avatar
    Join Date
    Oct 2011
    Posts
    1,785
    Hi again,

    Maybe try using the whole of the clip loader code.
    I had to guess at certain things for testing.

    PHP Code:
    import flash.events.Event;
    import flash.events.IOErrorEvent;
    import flash.events.ProgressEvent;

    import flash.display.Sprite;
    import flash.display.Loader;
    import flash.display.MovieClip;

    import flash.net.URLRequest;

    var 
    loader:Loader = new Loader();
    var 
    loadArea:MovieClip;
    var 
    pcent:Number;

    var 
    slide:int 1;
    var 
    CurrentSlide:Number;
    var 
    Slides:Array = new Array("1.swf","2.swf");

    loadLesson(1);

    function 
    loadLesson(slide:int):void
    {
        
    CurrentSlide slide;
        
    //unloadSwf();
        
    loader.contentLoaderInfo.addEventListener(Event.OPEN,loadStart);
        
    loader.contentLoaderInfo.addEventListener(ProgressEvent.PROGRESS,loadProgress);
        
    loader.contentLoaderInfo.addEventListener(Event.COMPLETE,loadComplete);
        
    loader.contentLoaderInfo.addEventListener(IOErrorEvent.IO_ERROR,loadError);
        
    loader.load(new URLRequest(Slides[CurrentSlide]));
    }

    function 
    loadStart(e:Event):void
    {
        
    loading.visible true;
    }

    function 
    loadProgress(e:ProgressEvent):void
    {
        
    pcent Math.floor((e.bytesLoaded e.bytesTotal) * 100);
        
    loading.bar.scaleX pcent 100;
        
    loading.perc.text String(pcent) + "%";
    }

    function 
    loadComplete(e:Event):void
    {
        
    pcent 0;

        
    loading.bar.scaleX pcent;
        
    loading.perc.text "";
        
    loading.visible false;

        
    loadArea MovieClip(loader.content);

        
    addChild(loadArea);

        
    loader.contentLoaderInfo.removeEventListener(Event.OPEN,loadStart);
        
    loader.contentLoaderInfo.removeEventListener(ProgressEvent.PROGRESS,loadProgress);
        
    loader.contentLoaderInfo.removeEventListener(Event.COMPLETE,loadComplete);
        
    loader.contentLoaderInfo.removeEventListener(IOErrorEvent.IO_ERROR,loadError);
    }

    function 
    loadError(e:IOErrorEvent):void
    {
        
    trace(e);

    Last edited by fruitbeard; 10-27-2014 at 11:40 PM.

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