Flash CS3 - Flash CS4

Free tutorials and scripts for all.
Actionscript 3.0

Preloader for beginners

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 ...


Go Back   Forum Flash CS3 Flash CS4 > Flash CS3 Flash CS4 > Flash English > Tutorials

Register FAQ Members List Calendar Search Today's Posts Mark Forums Read
  8 links from elsewhere to this Post. Click to view. #1 (permalink)  
Old 27-09-07, 10:19
Administrator
 
Join Date: Jul 2007
Location: Cesena
Posts: 4,535
Rep Power: 6
Flep is on a distinguished road
Preloader for beginners

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:
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);
}
Let"s analyse the code:

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:
Attached Files
File Type: zip preloader_beginners.zip (1.77 MB, 395 views)

__________________

 


I recommend: Essential Actionscript 3.0

- I do not reply technicians pvt messages. Open a thread !
- Non rispondo ai messaggi privati con domande tecniche. Apri una discussione sul forum !

Last edited by Flep; 28-08-08 at 06:33..
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote

  #2 (permalink)  
Old 21-10-07, 04:58
Junior Member
 
Join Date: Oct 2007
Posts: 3
Rep Power: 0
surferguy is on a distinguished road
Re: Preloader for beginners

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?
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #3 (permalink)  
Old 21-10-07, 08:16
Administrator
 
Join Date: Jul 2007
Location: Cesena
Posts: 4,535
Rep Power: 6
Flep is on a distinguished road
Re: Preloader for beginners

Hi,
if you are loading an SWF, it can't play before it has been completely loaded.
__________________

 


I recommend: Essential Actionscript 3.0

- I do not reply technicians pvt messages. Open a thread !
- Non rispondo ai messaggi privati con domande tecniche. Apri una discussione sul forum !
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #4 (permalink)  
Old 22-10-07, 01:00
Junior Member
 
Join Date: Oct 2007
Posts: 3
Rep Power: 0
surferguy is on a distinguished road
Re: Preloader for beginners

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.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #5 (permalink)  
Old 22-10-07, 09:37
Administrator
 
Join Date: Jul 2007
Location: Cesena
Posts: 4,535
Rep Power: 6
Flep is on a distinguished road
Re: Preloader for beginners

Have you a link to show me about that script please ?
__________________

 


I recommend: Essential Actionscript 3.0

- I do not reply technicians pvt messages. Open a thread !
- Non rispondo ai messaggi privati con domande tecniche. Apri una discussione sul forum !
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #6 (permalink)  
Old 23-10-07, 03:26
Junior Member
 
Join Date: Oct 2007
Posts: 3
Rep Power: 0
surferguy is on a distinguished road
Re: Preloader for beginners

Here is a link of a website that uses it , Invasion Tokyo
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #7 (permalink)  
Old 23-10-07, 07:07
Administrator
 
Join Date: Jul 2007
Location: Cesena
Posts: 4,535
Rep Power: 6
Flep is on a distinguished road
Re: Preloader for beginners

Those are FLV videos.
You can use the FLVPlayback component of Flasch CS3 to do that.
__________________

 


I recommend: Essential Actionscript 3.0

- I do not reply technicians pvt messages. Open a thread !
- Non rispondo ai messaggi privati con domande tecniche. Apri una discussione sul forum !
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #8 (permalink)  
Old 08-12-07, 13:09
Member
 
Join Date: Dec 2007
Posts: 42
Rep Power: 0
appi is on a distinguished road
Re: Preloader for beginners

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.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #9 (permalink)  
Old 08-12-07, 13:15
Administrator
 
Join Date: Jul 2007
Location: Cesena
Posts: 4,535
Rep Power: 6
Flep is on a distinguished road
Re: Preloader for beginners

Perhaps you need to use the playWhenEnoughDownloaded property:
Adobe - Developer Center : Controlling Flash video with FLVPlayback programming
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #10 (permalink)  
Old 08-12-07, 14:51
Member
 
Join Date: Dec 2007
Posts: 42
Rep Power: 0
appi is on a distinguished road
Re: Preloader for beginners

mmmmmmm! I done it. It gives me the following error:

1046: Type was not found or was not a compile-time constant: VideoEvent.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote

Reply

Bookmarks

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is On
Trackbacks are On
Pingbacks are On
Refbacks are On
Forum Jump

Similar Threads

Thread Thread Starter Forum Replies Last Post
Flash CS3 Preloader guidox Flash Italiano 7 27-09-08 12:50
Actionscript for beginners - Tutorial 2 - The Array Flep Actionscript for beginners - tutorials 1 08-07-08 07:17
preloader for mp3? inzipid Actionscript 3.0 newbies 3 13-11-07 21:54
Preloader su timeline zebraapois Actionscript 3.0 base 4 26-10-07 08:54
Preloader ulisse46 Actionscript 3.0 avanzato 17 14-08-07 17:48


All times are GMT. The time now is 14:54.

Powered by vBulletin version 3.7.4
Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.2.0 RC4
Forum SiteMap