Solved

Actionscript 2.0 Stop frames from advancing until video is loaded in Flash CS3

Posted on 2009-07-09
14
386 Views
Last Modified: 2013-11-11
I am using the following actionscript 2.0 on the first frame of my flash movie to not play the .flv until its 50% loaded.  This works great but the rest of the movie advances as that preloads.  How do I stop the advance of the flash movie as well until the .flv loads 50%?  

Can anyone update the actionscript below to also stop the advance of the flash movie please so I can see how its done?  FYI, I plan on having a movie clip on another layer saying LOADING... while this runs...
import mx.video.*;
 

var listenerObject:Object = new Object();
 

my_FLVPlybk.progressInterval = 001;

my_FLVPlybk.autoPlay = false;
 

listenerObject.progress = function(eventObject:Object) :Void {
 

var perc = Math.floor(eventObject.bytesLoaded * 100 / eventObject.bytesTotal);

//implement you loading visual representation here
 

if(perc == 50)

my_FLVPlybk.play();
 

}
 

my_FLVPlybk.addEventListener("progress", listenerObject);

my_FLVPlybk.load("final.flv");

Open in new window

0
Comment
Question by:pda4me
  • 7
  • 6
14 Comments
 
LVL 22

Expert Comment

by:rascalpants
Comment Utility

put a stop(); command on the frame.


rp
0
 

Author Comment

by:pda4me
Comment Utility
close, but that essentially stops the advance of the movie for good.  I think I need to adjust the code to stop and then play once its loaded.
0
 
LVL 22

Expert Comment

by:rascalpants
Comment Utility
oh, I guess i didnt' see that part of the question...

you need to add a new event listener...  


listenerObject.complete = function(eventObject:Object) :Void {
 
  my_FLVPlybk.play();
 
}
 
my_FLVPlybk.addEventListener("complete", listenerObject);



rp
0
 

Author Comment

by:pda4me
Comment Utility
I already have this in my original actionscript to a degree, I don't see where this will advance the frames?  I pasted this in, left the stop(); on the first frame and it did not work?  Can you send me what you mean in a sample using a updated version of my actionscript?

Thanks for your help.
0
 
LVL 22

Assisted Solution

by:rascalpants
rascalpants earned 100 total points
Comment Utility
0
 

Accepted Solution

by:
pda4me earned 400 total points
Comment Utility
Thanks for the attempt but that is essentially the same code I provided.  This is what ended up working for me, you will notice the stop(); and gotoplay(2) that ended up being added that did the trick.
stop();

import mx.video.*;

 

var listenerObject:Object = new Object();

 

my_FLVPlybk.progressInterval = 001;

my_FLVPlybk.autoPlay = false;

 

listenerObject.progress = function(eventObject:Object) :Void {

 

var perc = Math.floor(eventObject.bytesLoaded * 100 / eventObject.bytesTotal);

//implement you loading visual representation here

 

if(perc == 50)

my_FLVPlybk.play();

gotoAndPlay(2);

}

 

my_FLVPlybk.addEventListener("progress", listenerObject);

my_FLVPlybk.load("final.flv");

Open in new window

0
Why You Should Analyze Threat Actor TTPs

After years of analyzing threat actor behavior, it’s become clear that at any given time there are specific tactics, techniques, and procedures (TTPs) that are particularly prevalent. By analyzing and understanding these TTPs, you can dramatically enhance your security program.

 
LVL 22

Expert Comment

by:rascalpants
Comment Utility
ahhh, I must have misread the question then...

glad you figured it out...



rp
0
 
LVL 22

Expert Comment

by:rascalpants
Comment Utility
yeah, that is what I did...   the question title threw me off...

"Actionscript 2.0 Stop frames from advancing until video is loaded in Flash CS3"

I must have had that stuck in my brain... and ignored the 50% part.


rp
0
 

Author Comment

by:pda4me
Comment Utility
Cool, thanks.  Will do on assign points in the future.  Getting back into flash from a long hiatus (version 4.0) and I am going to need some support, so much has changed but for the better...so much more you can do with flash now!
0
 
LVL 22

Expert Comment

by:rascalpants
Comment Utility
yep, and I would highly recommend just jumping directly into AS 3.  Don't learn a programming model that is no longer the standarc (AS 2.0)

good luck

rp
0
 

Author Comment

by:pda4me
Comment Utility
Sounds good thanks.  How long has AS3 been around?  Is there anything new (AS4?) coming on the horizon soon?
0
 
LVL 22

Expert Comment

by:rascalpants
Comment Utility
I think about 1.5 years now...  I can't imagine Adobe rewriting the framework yet again, because it has had some significant improvements, and is much more like Java now.  Maybe in a year or so they will add some functionality and classes, but I don't forsee a complete switch in programming methodology any time soon.




rp
0
 

Author Comment

by:pda4me
Comment Utility
cool, thanks for the info!
0

Featured Post

Do You Know the 4 Main Threat Actor Types?

Do you know the main threat actor types? Most attackers fall into one of four categories, each with their own favored tactics, techniques, and procedures.

Join & Write a Comment

Suggested Solutions

This is intended to introduce all collision detection principles in flash, their strengths, weaknesses and workarounds. The main method for Collision Detection in flash is using hitTestObject. But unless you'll be pushing rectangular shapes without …
I have been doing hardcore actionscripting for some time; and needless to say I have faced a lot of problems in just understanding others' code rather than understanding what the code executes. A programmer's life can become hell when there are a lo…
The goal of the tutorial is to teach the user how to live broadcast using Flash Media Live Encoder and connecting it to YouTube to broadcast. Log into your Youtube account, choose live stream settings, start live stream from Flash Media Live Enc…
The goal of the tutorial is to teach the user how to set there setting in Adobe Flash Media Live Encoder and YouTube for optimal video and audio quality.

771 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

7 Experts available now in Live!

Get 1:1 Help Now