dcsimg
A Flash Developer Resource Site

Results 1 to 17 of 17

Thread: Preloader ActionScript

  1. #1
    Junior Member
    Join Date
    Oct 2001
    Posts
    17

    Preloader ActionScript

    Hi, I was trying to follow the tutorial for a basic preloader on this site

    http://www.flashkit.com/tutorials/In...a-33/more2.php

    I am using Flash MX and unfortunately I don't think the code that is used in the tutorial works in MX.


    It said to put the following into Frame 1 of the preloader scene:

    If Frame Is Loaded (MovieScene, 350)
    // if the last frame of the movie is loaded
    Go to and Play (MovieScene, 1)
    // go to and play the movie
    End Frame Loaded


    It then said to put this into the second frame:

    Go to and Play (preloadScene, 1)
    // keep looping in current scene to first keyframe until movie has loaded


    Does anyone know the MX translation of the code used?

    I would appreciate any help on this one!

    Thanks,

    Vgar
    www.vgarcraft.com

  2. #2
    Living Proof mave_the_rave's Avatar
    Join Date
    May 2002
    Location
    East Dulwich
    Posts
    1,006
    Try this :-
    Create your preloader page.
    place action script in last frame (key frame) of you preloader

    In first frame of preloader put a frame label called 'preloader'


    Code:
    MovieSize = _root.getBytesTotal(); 
    LoadedSize = _root.getBytesLoaded(); 
    PercentLoaded = LoadedSize / MovieSize 
    percent = Math.floor(PercentLoaded*100); 
    showPercent = percent + "  %";
    
    _root.growbar._xscale = percent 
    
    if (PercentLoaded < 1) { 
    gotoAndPlay("preload"); 
    } 
    else { 
    gotoAndPlay("moviestart"); 
     
    }
    use the line _root.growbar._xscale = percent
    if you want a progress indicator.
    make a rectangle with an instance name of growbar
    or whatever you want..



    //create the label 'moviestart' in the first frame of your actual movie
    ------------------------------------------
    the / percent = Math.floor(PercentLoaded*100); /
    gives you an integer and drops the 2 decimal points.


    create a dynamic text in a text box. with var set to showPercent
    Last edited by mave_the_rave; 11-21-2002 at 11:27 AM.
    If someone tells you it can't be done,
    it's probally because they don't know how.

  3. #3
    Junior Member
    Join Date
    Oct 2001
    Posts
    17
    Thanks a million Mave the Rave,

    Just one more question. Using this method, do I need to have both the preloader and the movie in the same scene?

    At the moment they are both on seperate scenes and it doesn't appear to want to move onto the actualy movie scene.

    Any ideas?


    Thanks,

    Vgar
    www.vgarcraft.com

  4. #4
    Living Proof mave_the_rave's Avatar
    Join Date
    May 2002
    Location
    East Dulwich
    Posts
    1,006
    Hi..
    Im fairly new to all this myself. I use this preloader.
    It can be adapted to your needs. I have not progressed
    passed one scene yet, Im sure if you persivere, you will
    suss it out.

    Please post back with your results.

    Did you actually have time to test it out between posts.
    If so, that was pretty fast.

    mave_the_rave.
    Last edited by mave_the_rave; 11-21-2002 at 11:28 AM.
    If someone tells you it can't be done,
    it's probally because they don't know how.

  5. #5
    Junior Member
    Join Date
    Oct 2001
    Posts
    17
    Yeah I tested it before I posted back. It seems to run through the preload up to 100% and then it starts it over again.
    I will try to put them both on the same scene and see what happens.

    I'm pretty new to this aswell so I really appreciate your help.

    I'll let you know how I get on now in a minute.

    Cheers,

    Vgar
    www.vgarcraft.com

  6. #6
    Junior Member
    Join Date
    Oct 2001
    Posts
    17
    Mave the Rave you are a life saver!!!!

    I but them both on the one scene and it works!!!!! yay!!!!!


    Thank you so much, that has been wrecking my head for ages!!!!
    I hope I can help you out sometime!


    Cheers,

    Vgar
    www.vgarcraft.com

  7. #7
    Living Proof mave_the_rave's Avatar
    Join Date
    May 2002
    Location
    East Dulwich
    Posts
    1,006
    Hi

    There was a typo in my post.

    should of read :-

    gotoAndPlay("moviestart"); not gotoAndStart("moviestart");

    I don't know how many time I have posted this with the error in.


    gotoAndPlay( scene, frame ) may be the answer to your
    multiple scene prob.
    If someone tells you it can't be done,
    it's probally because they don't know how.

  8. #8
    Junior Member
    Join Date
    Oct 2001
    Posts
    17
    Wierd, it still worked with your typo :-)

    The scene thing didn't work for me, but sure it is working the way you suggested and once its working I don't really mind what way it is sorted.
    I thought you had to have them on different scenes, but this way is fine!!!

    Finally it works! :-)
    www.vgarcraft.com

  9. #9
    Living Proof mave_the_rave's Avatar
    Join Date
    May 2002
    Location
    East Dulwich
    Posts
    1,006
    Originally posted by vgar
    Wierd, it still worked with your typo :-)

    The scene thing didn't work for me, but sure it is working the way you suggested and once its working I don't really mind what way it is sorted.
    I thought you had to have them on different scenes, but this way is fine!!!

    Finally it works! :-)
    Yea, on reflection, as there is no stop() action, when all bytes
    are loaded, it simply plays on through..
    If someone tells you it can't be done,
    it's probally because they don't know how.

  10. #10
    Junior Member
    Join Date
    Oct 2001
    Posts
    17
    Ah, I see. I'll have to keep an eye on that one!

    How long have you been playing about with Flash?
    www.vgarcraft.com

  11. #11
    Living Proof mave_the_rave's Avatar
    Join Date
    May 2002
    Location
    East Dulwich
    Posts
    1,006
    Originally posted by vgar
    Ah, I see. I'll have to keep an eye on that one!

    How long have you been playing about with Flash?
    About 9 months, but I don't have any time during the day as I work.
    And I'm an old git so the brain doesn't work too well. Takes a bit
    of time to sink in..

    I am amazed at the talent of some of the kids that post here.
    There are some guys in my local pub making music with Reason
    and SoundForge..

    Just does my head in. (that is the tecnology) Oh to be 20 again.....

    What did I do with all those years,?
    Last edited by mave_the_rave; 11-21-2002 at 12:21 PM.
    If someone tells you it can't be done,
    it's probally because they don't know how.

  12. #12
    Junior Member
    Join Date
    Oct 2001
    Posts
    17
    I know, some of them in here are total geniuses - its mad!

    I doubt you're that old!
    Where is your local pub? I wish I was in mine now, but unfortunately I'm in work!

    I'm only 19 myself!
    www.vgarcraft.com

  13. #13
    Living Proof mave_the_rave's Avatar
    Join Date
    May 2002
    Location
    East Dulwich
    Posts
    1,006
    Originally posted by vgar
    I know, some of them in here are total geniuses - its mad!

    I doubt you're that old!
    Where is your local pub? I wish I was in mine now, but unfortunately I'm in work!

    I'm only 19 myself!
    No mate , I'm afraid I'm '50'.

    I believe there may be someone older here at Flash Kit, but they
    may not wish to admit it.

    My pub is in E. Dulwich London SE.
    If someone tells you it can't be done,
    it's probally because they don't know how.

  14. #14
    Junior Member
    Join Date
    Oct 2001
    Posts
    17
    50 'aint that old! If you can still code then you're okay! :-)

    Your only across the water from me so, my local is in Dublin! (well, just outside of Dublin).
    www.vgarcraft.com

  15. #15
    Living Proof mave_the_rave's Avatar
    Join Date
    May 2002
    Location
    East Dulwich
    Posts
    1,006
    Originally posted by vgar
    50 'aint that old! If you can still code then you're okay! :-)

    Your only across the water from me so, my local is in Dublin! (well, just outside of Dublin).

    Thanks mate, you just made me feel 49 again

    Dublin ? Now that sounds like a place to drink..

    Anyway, time to go home. Nice chatting. Good luck with your
    coding. You have enough time to get really good and perhaps
    turn your skills to make some decent money.
    If someone tells you it can't be done,
    it's probally because they don't know how.

  16. #16
    Junior Member
    Join Date
    Oct 2001
    Posts
    17
    That's my plan anyways! Hope it works out the way I can picture it in my head!

    Anyways, it was nice chatting and thanks again for your help! Really appreciate it!

    I'm off to the pub for a loverly pint after work!

    Cya later,

    Vgar



    www.vgarcraft.com
    www.vgarcraft.com

  17. #17
    Junior Member
    Join Date
    Sep 2018
    Posts
    1
    Thanks mate, you just made me feel 49 again

Posting Permissions

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




Click Here to Expand Forum to Full Width

HTML5 Development Center