-
Senior Member
showing SWF based on framesloaded!
Hello all,
I have this SWF which has a video embedded in it. Video took around 1200 frames (4 Megs). My traget is to progressively load frames i.e. once 100 frames are loaded display them and as soon as further 100 frames are loaded keep them displaying else show a loader to user.
Can this be done in flash ?
Note. I have my code ready to load the full SWF before displaying it to the user but my plan is not make teh user wait till whole file is loaded, instead play whatever is loaded in the browser.
Last edited by vinayak.kadam; 07-25-2011 at 06:30 AM.
As ever,
Vinayak Kadam
-
i believe you should be able to add that to the loaded movie.. there is a framesloaded property to use... you can maybe set a variable and store a value for where the movie can play to...
ie
addEventListener(Event.ENTER_FRAME, onEnterFrame);
var playTo:int = 0;
onEnterFrame(e:Event):void {
if (this.framesloaded == this.totalFrames) {
// fully loaded, remove listener
} else {
// not fully loaded
playTo = Math.floor(this.framesloaded/100)*100;
}
then get it to play ... the other thing you might want to look at, to have it dynamically stop at a target frame is addFrameScript
http://blog.newmovieclip.com/2007/04...-in-flash-cs3/
Last edited by cultcreative; 07-25-2011 at 09:19 AM.
-
Senior Member
thanx for ur reply but as per your code file will be displayed to user only after it is fully loaded whereas I want to display the file when some percentage of frames is loaded....like 205 or 30%.
-
why would it only be displayed at the end? what i am suggesting is making a progressive loader.. adding addFrameScript to add stops of frames in iterations of 100
-
Senior Member
Can I please request you to add some more details regarding how to implement this one ?
Thanks in advance for your kind consideration.
-
Senior Member
I had a look at the example but really cannot make out how to implement this in my context...
-
ok, I realized yesterday that there might be an easier way to do it..
adding something like the following to the first frame of the main timeline should do the trick.. it adds a function that is called on every frame (EnterFrame), and then checks to see the amount of frames loaded... if it is done it removes itself, if it isn't done it gets the total number of frames loaded and rounds it down to the nearest hundred.. if the current frame is lower than that rounded number it will play, otherwise it will stop
addEventListener(Event.ENTER_FRAME, onEnterFrame);
var playTo:int = 0;
function onEnterFrame(e:Event):void {
if (this.framesloaded == this.totalFrames) {
// fully loaded, remove listener
removeEventListener(Event.ENTER_FRAME, onEnterFrame);
} else {
// not fully loaded
playTo = Math.floor(this.framesloaded/100)*100;
}
if (this.currentFrame < playTo) {
play();
} else {
stop();
}
}
-
Senior Member
Thanx a lot for ur reply...I will look into this and then get back to you...
Tags for this Thread
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|