+ Reply to Thread
Page 1 of 4 1 2 3 ... LastLast
Results 1 to 10 of 40

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

  1. #1
    Administrator Living At The FlepStudio! Flep is on a distinguished road
    Join Date
    Jul 2007
    Posts
    5,762
    Rep Power
    11

    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

  2. #2
    Junior Member Settled In surferguy is on a distinguished road
    Join Date
    Oct 2007
    Posts
    3
    Rep Power
    0

    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?

  3. #3
    Administrator Living At The FlepStudio! Flep is on a distinguished road
    Join Date
    Jul 2007
    Posts
    5,762
    Rep Power
    11

    Re: Preloader for beginners

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

  4. #4
    Junior Member Settled In surferguy is on a distinguished road
    Join Date
    Oct 2007
    Posts
    3
    Rep Power
    0

    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.

  5. #5
    Administrator Living At The FlepStudio! Flep is on a distinguished road
    Join Date
    Jul 2007
    Posts
    5,762
    Rep Power
    11

    Re: Preloader for beginners

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

  6. #6
    Junior Member Settled In surferguy is on a distinguished road
    Join Date
    Oct 2007
    Posts
    3
    Rep Power
    0

    Re: Preloader for beginners

    Here is a link of a website that uses it , Invasion Tokyo

  7. #7
    Administrator Living At The FlepStudio! Flep is on a distinguished road
    Join Date
    Jul 2007
    Posts
    5,762
    Rep Power
    11

    Re: Preloader for beginners

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

  8. #8
    Member Settled In appi is on a distinguished road
    Join Date
    Dec 2007
    Posts
    42
    Rep Power
    0

    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.

  9. #9
    Administrator Living At The FlepStudio! Flep is on a distinguished road
    Join Date
    Jul 2007
    Posts
    5,762
    Rep Power
    11

    Re: Preloader for beginners

    Perhaps you need to use the playWhenEnoughDownloaded property:
    Adobe - Developer Center : Controlling Flash video with FLVPlayback programming

  10. #10
    Member Settled In appi is on a distinguished road
    Join Date
    Dec 2007
    Posts
    42
    Rep Power
    0

    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.

+ Reply to Thread
Page 1 of 4 1 2 3 ... LastLast

LinkBacks (?)

  1. 03-12-08, 15:29
  2. 22-11-08, 08:34
  3. 11-07-08, 18:48
  4. 09-06-08, 15:13
  5. 26-02-08, 10:45
  6. 18-02-08, 19:20
  7. 14-10-07, 20:27
  8. 03-10-07, 06:39

Similar Threads

  1. Actionscript for beginners - Tutorial 2 - The Array
    By Flep in forum Actionscript for beginners - tutorials
    Replies: 4
    Last Post: 09-10-11, 08:08
  2. Flv preloader
    By finalday in forum Actionscript 3.0 avanzato
    Replies: 10
    Last Post: 19-11-10, 22:00
  3. Preloader
    By raffaraffa in forum Flash English
    Replies: 2
    Last Post: 03-02-09, 19:17
  4. Preloader
    By guidox in forum Flash Italiano
    Replies: 7
    Last Post: 27-09-08, 11:50
  5. Preloader
    By ulisse46 in forum Actionscript 3.0 base
    Replies: 17
    Last Post: 14-08-07, 16:48

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts