I was wondering about using the action script to load the video only to a % rather than completely loading before playing. I've tried to read the action script terms to replace Event.COMPLETE but not really sure which one would work?
This is a discussion on Preloader for beginners within the Tutorials forums, part of the Flash English category; Some of you would say"finally! FlepStudio has thought about its kind users, beginners with Flash CS3. After having noticed the ...
Some of you would say"finally!
FlepStudio has thought about its kind users, beginners with Flash CS3.
After having noticed the difficulties of certain users to the first approach with Flash CS3, after having read some comments of the articles that explain how to load an external SWF and of the tutorial Preloader, FlepStudio has realized a preloader for beginners. I do not think that you can find easier then that one.
This article will show you how to simply load an external SWF and, as always, the source files are included. No use of Class or file .as!
Everything is placed on the Timeline. Follow me and I will show you how"
I create a FLA and save it as "main.fla", inside which I place on stage a MovieClip with an instance name "preloader_mc".
First of all, let"s think about the fact that this preloader will be visible during the loading of the external SWF and then, once the loading finished, it will have to disappear.
I open the action panel and write:
Let"s analyse the code:Code:preloader_mc.stop(); preloader_mc.visible=false; var swf:String='http://www.flepstudio.org/swf/principianti/preloader/test.swf'; var richiesta:URLRequest=new URLRequest(swf); var loader:Loader=new Loader(); loader.contentLoaderInfo.addEventListener(Event.OPEN,inizia); loader.contentLoaderInfo.addEventListener(ProgressEvent.PROGRESS,inCaricamento); loader.contentLoaderInfo.addEventListener(Event.COMPLETE,completato); loader.load(richiesta); function inizia(e:Event):void { preloader_mc.visible=true; preloader_mc.play(); } function inCaricamento(e:ProgressEvent):void { var percentuale:uint=(e.bytesLoaded/e.bytesTotal)*100; preloader_mc.loader_txt.text=percentuale.toString()+' %'; } function completato(e:Event):void { preloader_mc.stop(); preloader_mc.visible=false; addChild(loader); }
I stop the Timeline of "preloader_mc"
preloader_mc.stop();
I render "preloader_mc" visible
preloader_mc.visible=false;
I create a variable "swf" which contains the url of the SWF to be loaded
var swf:String='http://www.flepstudio.org/swf/principianti/preloader/test.swf';
I create an URL request to which I pass the value of the variable "swf"
var richiesta:URLRequest=new URLRequest(swf);
I create a Loader
var loader:Loader=new Loader();
I add the listeners to the Loader"s property contentLoaderInfo which will listen to the 3 events during the loading: EventOPEN (loading started), ProgressEvent.PROGRESS (loading in process) and EventCOMPLETE (loading finished). At each events, a function will be called: inizia(), inCaricamento(),completato().
loader.contentLoaderInfo.addEventListener(Event.OP EN,inizia);
loader.contentLoaderInfo.addEventListener(Progress Event.PROGRESS,inCaricamento);
loader.contentLoaderInfo.addEventListener(Event.CO MPLETE,completato);
I tell the Loader to load the request "richiesta"
loader.load(richiesta);
in this function I render "preloader_mc" visible and start its Timeline function inizia(e:Event):void
{
preloader_mc.visible=true;
preloader_mc.play();
}
in this function I calculate the percent loaded and view it via a dynamic text field include in "preloader_mc"
function inCaricamento(e:ProgressEvent):void
{
var percentuale:uint=(e.bytesLoaded/e.bytesTotal)*100;
preloader_mc.loader_txt.text=percentuale.toString( )+' %';
}
last, I stop the "preloader_mc" Timeline, render it invisible and add to the stage (using the method addChild) the Loader which now contains the external SWF function completato(e:Event):void
{
preloader_mc.stop();
preloader_mc.visible=false;
addChild(loader);
}
Source files:
Last edited by Flep; 28-08-08 at 05:33.
I was wondering about using the action script to load the video only to a % rather than completely loading before playing. I've tried to read the action script terms to replace Event.COMPLETE but not really sure which one would work?
Hi,
if you are loading an SWF, it can't play before it has been completely loaded.
Thanks for responding. There has to be some way to accomplish loading to say about 10% and then starting the swf progressive load. I've done it using a prebuilt preloader in a seperate software package. You can specificy the % of the clip loaded before playback begins. I was hoping to do this myself in CS3 without having to use the outside vendors preloader package. The package was based on AS2.
Have you a link to show me about that script please ?
Here is a link of a website that uses it , Invasion Tokyo
Those are FLV videos.
You can use the FLVPlayback component of Flasch CS3 to do that.![]()
Flep,
I am here again... looking from preloaders for my videos
I used an .as file to code the FLVPlayback component and I attached to the stage of the main flash movie. Whilst the FLVPlayback component downloads the whole movie .... I can only play a percent of its beginning.
I wonder if you know why this happens?
Thanks in advance.
Perhaps you need to use the playWhenEnoughDownloaded property:
Adobe - Developer Center : Controlling Flash video with FLVPlayback programming
mmmmmmm! I done it. It gives me the following error:
1046: Type was not found or was not a compile-time constant: VideoEvent.
Bookmarks