Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

determine whether a loading swf is stopped or playing??

Status
Not open for further replies.

theotrain

Programmer
Mar 5, 2003
150
MX
when you load an swf into a movie clip, if the download is slow it might pause. if it does i need to know when it pauses and when it resumes.

when you play a video, you've got events launched like NetStatusEvent--> "NetStream.Play.Start", and "NetStream.Buffer.Empty" to help you keep tabs on the status of the video. but the movie clip object doesnt seem to have any analogous events, so i need a workaround.

anybody deal with this before? any ideas?
 
im using the Loader object. only because i dont know any other way to do it in as3.

i had the idea that maybe i could see whether the framesLoaded was greater than the currentFrame of the swf. i supposed that if they were equal, that would mean the movie was stopped due to insufficient bandwidth, and if framesLoaded was greater, the movie ought to be playing.

so i went down that path and ran into some new snags.

firstly, the loader object doesnt really have framesloaded, only bytesLoaded, which is not as useful for what im looking to do.

secondly when i tried to access the loaded content to determine the currentFrame, i couldnt do that either. it seems you cant access the Loader.content timeline at all until the movie is fully loaded! that absolutely sucks if true. once you start the load, the swf starts playing... but that movie thats already begun to play is inaccessible (until it finished loading), as far as i can tell.

heres the code:

Code:
var ldr:Loader = new Loader();
var url:String = "loadtest-inner.swf";
var urlReq:URLRequest = new URLRequest(url);

ldr.contentLoaderInfo.addEventListener(ProgressEvent.PROGRESS, progressHandler);
ldr.contentLoaderInfo.addEventListener(Event.COMPLETE, completeHandler);

function progressHandler(event:ProgressEvent):void {
    MovieClip(ldr.content).stop();
    //fails here!!
    //(Cannot access a property or method of a null object reference.)
    }
}

function completeHandler(event:Event):void {
    MovieClip(ldr.content).stop();
    //works here!!
}

ldr.load(urlReq);
myHolder.addChild(ldr);

in my test, until the load is 100% complete, ldr.content is equal to null. i cant stop the movie, or get the currentframe (using "MovieClip(ldr.content).currentFrame") without an error. so the problem seems to become more intractable the longer i look at it.

what im actually doing is trying to synchronize videos and flash movies that are loaded into a host movie. so theres an flv loading and an swf loading, i need to keep them both playing together (give or take a few frames). ive got silent streaming sounds in my swfs to insure a constant framerate there.

if the video pauses to buffer during loading i need to stop the flash movie, and vice versa. thats the reason i need to know whether the flash movie has stopped (got stuck on a frame) during the loading process. if youve any ideas of a different way to attack the problem, im all ears. or eyes.

waiting for the whole thing to load so it can play smoothly is out.

thanks!
 
interesting idea, but if my swf needs to skip to a certain frame at a particular cue point, i dont think i can make it skip to that frame until the ENTIRE swf is loaded, at least if im using the loader object.

thats my problem. Loader.content is null until the movie is fully loaded. so i cant do myLoader.content.gotoAndStop(someLoadedFrame) even if that part is loaded, until its ALL loaded. so even if i was trying to trigger something from a cue point there would be the same problem i think... the swf part would have to be preloaded in its entirety.

that seems like a crazy limitation to me, im pretty sure in the days of MovieClip.LoadMovie you could affect the loading timeline prior to a complete load. Im having a hard time resigning myself to this fact.

if anyone can tell me I'm wrong i'd be very happy.
 
What I was suggesting is slightly different: you'd draw things on stage using script, controlled by FLV cue points. There would be no SWF to load.

That's what I'd do anyway. Other possibilities include combining the FLV and the SWF into one FLV (or SWF) so that there would be no sync/loading issues, or indeed load the SWF fully before start.

Kenneth Kawamoto
 
thanks guys.

for my purposes i'll have to resign myself to loading the swfs in their entirety beforehand. oh well, its not so terrible. they wont be very large, compared to the videos.

good to know you cant do it in as2 either. for some reason it makes me feel better.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top