Skip navigation
LifetimeLearnerM
Currently Being Moderated

Preloader Not Working Properly

Apr 24, 2013 9:09 AM

I know, another Preloader post. I was asked to problem solve why a preloader sometimes shows up, but mostly doesn't, leaving the viewer confused as to why they are staring at a blank page for a long time, waiting for something to happen. Problem is, I am not very knowledgable in flash.

 

Below is the code I was asked to work with.The client wanted the entire site to preload; opening animation and videos throughout the site. My boss actually ended up piecing this code together, but is also not a flash guru, so he is out of ideas.

 

I don't really know what the issue is, and most of the tutorials I looked up deal with a different code.

 

 

stop(); var nc:NetConnection = new NetConnection(); nc.connect(null); var ns:NetStream = new NetStream(nc); var videoPlayer:Video = new Video(); videoPlayer.attachNetStream(ns) ns.play("http://www.missionpublicaffairs.com/MPA-031813.flv"); ns.pause(); var SWFtotal:int; var VIDEOtotal: int; var AVGtotal: int; function checkLoad():void { trace("Video Bytes Loaded: " + ns.bytesLoaded); trace("SWF Bytes Loaded: " + this.stage.loaderInfo.bytesLoaded); SWFtotal = int(((this.stage.loaderInfo.bytesLoaded/this.stage.loaderInfo.bytesTo tal)*100)); VIDEOtotal = int(((ns.bytesLoaded/ns.bytesTotal)*100)); AVGtotal = int(((SWFtotal + VIDEOtotal)/2)) //MattText.text = "Video Loaded: " + VIDEOtotal + "%"; //SWFText.text = "SWF Bytes Loaded: " + SWFtotal + "%"; TotalText.text = "Total Loaded: " + AVGtotal + "%";           if ((ns.bytesLoaded == ns.bytesTotal) && (this.stage.loaderInfo.bytesLoaded == this.stage.loaderInfo.bytesTotal)) {           clearInterval(myInterval);           this.gotoAndPlay(2); } } var myInterval:uint = setInterval (checkLoad, 200);

 

The site link is here, if needed. Again, sometimes it shows, sometimes not. Please let me know if you need anything answered in order to give me pointers. Thanks in advance.

 

M!

 
Replies
  • kglad
    72,322 posts
    Jul 21, 2002
    Currently Being Moderated
    Apr 24, 2013 9:26 AM   in reply to LifetimeLearnerM

    add this to your code:

     

    ns.client=this;

    function onXMPData(e:*):void{

    }

     
    |
    Mark as:
  • kglad
    72,322 posts
    Jul 21, 2002
    Currently Being Moderated
    Apr 24, 2013 9:56 AM   in reply to LifetimeLearnerM

    you can place that code anywhere ns is defined.

     

    test by uploading your published swf.

     
    |
    Mark as:
  • kglad
    72,322 posts
    Jul 21, 2002
    Currently Being Moderated
    Apr 24, 2013 1:55 PM   in reply to LifetimeLearnerM

    you're welcome.

     
    |
    Mark as:

More Like This

  • Retrieving data ...

Bookmarked By (0)

Answers + Points = Status

  • 10 points awarded for Correct Answers
  • 5 points awarded for Helpful Answers
  • 10,000+ points
  • 1,001-10,000 points
  • 501-1,000 points
  • 5-500 points