A Flash Developer Resource Site

Page 1 of 2 12 LastLast
Results 1 to 20 of 38

Thread: Actionscript 3 Preloader Problem

  1. #1
    The New Guy
    Join Date
    Nov 2007
    Posts
    67

    Actionscript 3 Preloader Problem

    Hi Guys

    Got a tough one here!

    I've created a pre loader for a game which has been written in AS3.
    However, the preloader doesn't show up until the entire game has been loaded (which kinda defeats the object of a preloader!)

    The problem is, I have a lot of linked assets in the library which I create instances of during runtime.

    I've tried switching off "Export on first frame" for every linked asset and set the document's settings to "Export classes in frame 2" but the whole thing goes bananas and I just get a boat load of compile errors (<--- anyone know why this happens?!!)

    I've tried putting the assets on a blank frame in the timeline. This works for movieclips, but then I'm stuck when it comes to sound and music (which are large and need to be embedded into the library due to music copyright issues - I can't distribute the mp3s as they're royalty free music files!). This method could work if I could figure out how to sort out the sounds/music.

    I really don't want to create a separate pre-loader or have any external assets/files because I intend to distribute this game all over the web and it would be better to have just one protected SWF file.

    I'm really stuck and don't know what to do.

    Does anyone have any ideas?? Any help would be appreciated. Thanks!

  2. #2
    Senior Member cancerinform's Avatar
    Join Date
    Mar 2002
    Location
    press the picture...
    Posts
    13,449
    Click on the Flashscript classes link in my footer. The package contains a simple preloader script and also a component. You can create a 100frames movieclip, which is located in the library and which will play during preloading the movie.

    I don't know the problem with your preloader unless there is too much to load for the preloader, which defeats its sense.
    - The right of the People to create Flash movies shall not be infringed. -

  3. #3
    Junior Member
    Join Date
    Sep 2007
    Location
    kent, uk
    Posts
    20

    same problem f-zero

    Hi F-zero i have the same problem and have searched the web for weeks trying to find a solution.what a lot of people dont understand is doing the addchild preloader is (a) not practicle for games and (b) too bleedin slow.
    what me u and god knows how many people want to find out is because the sound files are bigger than anything else in the library we need these to be inside frame 2 or above so it keeps frame 1s size to a minimum so the preloader displays early and before any body sais it, we dont want to load sounds from the url so if any one can shed some light on this problem im sure many cs3/as3 coders would be greatfull.

  4. #4
    Senior Member
    Join Date
    Jul 2006
    Location
    Australia
    Posts
    167

    External Preloader?

    What about an external preloader?

    You can use the Loader and LoaderInfo Class to make one if you can't get the inbuilt preloader to run before the whole movie is loaded.

    Simply make a loader swf, and load the main swf file using the above mentioned classes.

    I don't have any examples of this, but I am trying it at the moment (newly learnt AS3)
    Ben a.k.a. Flash Geek
    Need Help? Get It Within 24 hours. If you don't have one of these messenger clients, just email me at my msn address below:
    Msn: ben" at "benmartinstudios" dot "com"

  5. #5
    Senior Member cancerinform's Avatar
    Join Date
    Mar 2002
    Location
    press the picture...
    Posts
    13,449
    The preloader script in the Flashscript classes can do that also (under imagepreloader). Alternatively there is a Loaderclass script, which can attach a 100frames animation.

    Click on the corresponding link:
    http://flashscript.biz/flashas3/biz/index.html
    - The right of the People to create Flash movies shall not be infringed. -

  6. #6
    Senior Member
    Join Date
    Jul 2006
    Location
    Australia
    Posts
    167
    Quote Originally Posted by cancerinform
    The preloader script in the Flashscript classes can do that also (under imagepreloader). Alternatively there is a Loaderclass script, which can attach a 100frames animation.

    Click on the corresponding link:
    http://flashscript.biz/flashas3/biz/index.html
    Your components are very well made Is there a way to do something every x% the loader reaches in actionscript?
    Ben a.k.a. Flash Geek
    Need Help? Get It Within 24 hours. If you don't have one of these messenger clients, just email me at my msn address below:
    Msn: ben" at "benmartinstudios" dot "com"

  7. #7
    Senior Member cancerinform's Avatar
    Join Date
    Mar 2002
    Location
    press the picture...
    Posts
    13,449
    Thanks. You could use a 100frames animation and add what you want to add in every frame. I don't know instantly how to do it by script.
    - The right of the People to create Flash movies shall not be infringed. -

  8. #8
    Senior Member
    Join Date
    Jan 2008
    Posts
    150
    The way it was explained to me was that a .swf doesn't play it's first frame until the entire .swf file has been loaded into the browser, which makes sense since your code might tell it to go to a particular frame but if that frame didn't exist yet there would be problems.

    For a preloader to work you're going to have to have your .swf load something- it can't do anything before "it" is in the browser.

  9. #9
    Junior Member
    Join Date
    Sep 2007
    Location
    kent, uk
    Posts
    20

    a?

    shokushu who ever told you that was wrong m8.

  10. #10
    The New Guy
    Join Date
    Nov 2007
    Posts
    67
    Hi guys, thanks for all the responses so far!

    I can't believe this problem exists - I mean this is ridiculous!
    I learn AS3 so that my life will be easier (and believe me it HAS been so far coming from a game coding POV), we're encouraged by Adobe to make full use of the new language and yet we're stuck in the dark ages when it comes to creating the most fundamental element of any flash file which is a working preloader.
    And whats worse is that Adobe have no help whatsoever regarding this particular issue on their website.

    I'm estimating my final SWF file size to be between 4 - 8 Mb. I can't have people looking at a blank screen, thinking it doesn't work.

    Surely there must be some hack to "interrupt" the application before it initialises and somehow force it to load the preloader first??

    My preloader (1st frame) doesn't contain any classes which have been created on the fly, so I'm not using any addChild commands. Besides a bunch of initialisation commands/variables and a hardcoded XML sheet, the only thing there is the preloader functions. The classes don't come into play until frame 2 and above.

    I think if I don't find the solution by the time I finish the game then I might as well go ahead and make a separate swf loader. Its the next best thing I guess.

    But seriously, if anyone has any ideas on how to solve this, I would really appreciate the help! (and I'm sure theres a lot of other frustrated souls who would appreciate this knowledge too!)

  11. #11
    Junior Member
    Join Date
    Sep 2007
    Location
    kent, uk
    Posts
    20

    Any Takers

    Still no awnser to this problem,there must be someone on these forums that knows the awnser ?

    Is there no flash 9 written game on the web with a preloader all in one swf ?

    This is the million pound question.

  12. #12
    trace("AKA: Biro Barna");
    Join Date
    Oct 2007
    Location
    RO.Timişoara
    Posts
    1,403
    Ok, I'm not sure about this one but maybe it's not enough to declare your classes on frame 3 or above. Just for testing, try setting the export code to frame 3... If remember in AS 2.0 you had to export most of the actions from frame 1 or 2 in order to show the preloader in time, I'm not sure if this will work in any ways but it's worth a try.



    | Windows MSN: birobarna [at] hotmail [dot] com | Skype: barna.biro |
    WebLog: http://blog.wisebisoft.com/ |
    | Software Developer / Flash & Flex Developer | Student ( Computer Science ) | Interested in: Sharing Knowledge |
    |
    Romanian Adobe Flash, Flex, AIR Forum: http://www.flashforum.ro/
    | By perseverance the snail reached the ark. |


  13. #13
    Member
    Join Date
    Aug 2004
    Location
    -
    Posts
    35
    you can read about it here.

  14. #14
    Senior Member cancerinform's Avatar
    Join Date
    Mar 2002
    Location
    press the picture...
    Posts
    13,449
    Quote Originally Posted by Bash_321
    you can read about it here.
    This is only when the root of the movie originates from a class extending a Sprite. A movie with frames has a timeline and the root originates from the MovieClip class. here is a typical preloader in frame 1 for that:

    http://www.flashscript.biz/flashas3/...preloader.html

    For Sprite derived movies without timeline you need to create a parent movie and load it like this class is for:

    http://flashscript.biz/flashas3/biz/index.html

    Preloader - imageloader.
    - The right of the People to create Flash movies shall not be infringed. -

  15. #15
    Member
    Join Date
    Aug 2004
    Location
    -
    Posts
    35
    Quote Originally Posted by cancerinform
    This is only when the root of the movie originates from a class extending a Sprite. A movie with frames has a timeline and the root originates from the MovieClip class. here is a typical preloader in frame 1 for that:

    http://www.flashscript.biz/flashas3/...preloader.html

    For Sprite derived movies without timeline you need to create a parent movie and load it like this class is for:

    http://flashscript.biz/flashas3/biz/index.html

    Preloader - imageloader.
    yes, you are right.
    But for your first method to work you need to export your assets not to frame one,
    otherwise this will make the preloader show up only when they are loaded,
    and as f-zero says he cannot do that because he gets compile errors.

    and the second method requires an external container swf, and this is not very suitable for distributing a game all over the web.

    the link i posted earlier is a litlle more complex, but removes both problems.

  16. #16
    The New Guy
    Join Date
    Nov 2007
    Posts
    67
    Quote Originally Posted by Bash_321
    you can read about it here.
    Thanks Bash_321. I actually found that link not so long ago whilst searching around for a solution to this problem. The guy who runs that blog seems to have solved the AS3 preloader problem but I can't seem to make a head or tail of what he's done. Unless I'm mistaken, it appears to be some kind of hack which interrupts the application before it initializes itself.

    Can anyone explain it? Perhaps even post a tiny quick working example?

    As mentioned before, I'd appreciate any help on this!

    Thanks!

  17. #17
    Senior Member
    Join Date
    Jan 2008
    Posts
    150
    I'm a little bit insulted that pepsicoder had the nerve to tell me I'm wrong without knowing anything about how to actually do this and then when someone does turn up something it's a hack to get around what I explained.

    I'm certainly not infallible but if you're going to say someone is wrong about something at least explain why.

  18. #18
    trace("AKA: Biro Barna");
    Join Date
    Oct 2007
    Location
    RO.Timişoara
    Posts
    1,403
    ^ Just chill, don't take everything that hard. Flaming won't help any of us, people have different opinions, try to ignore the ones you don't like and carry on.



    | Windows MSN: birobarna [at] hotmail [dot] com | Skype: barna.biro |
    WebLog: http://blog.wisebisoft.com/ |
    | Software Developer / Flash & Flex Developer | Student ( Computer Science ) | Interested in: Sharing Knowledge |
    |
    Romanian Adobe Flash, Flex, AIR Forum: http://www.flashforum.ro/
    | By perseverance the snail reached the ark. |


  19. #19
    trace("AKA: Biro Barna");
    Join Date
    Oct 2007
    Location
    RO.Timişoara
    Posts
    1,403
    PS: thanks Joachim for changing the name of the forum to AS 3.0
    Really cool, keep up the good work everyone.



    | Windows MSN: birobarna [at] hotmail [dot] com | Skype: barna.biro |
    WebLog: http://blog.wisebisoft.com/ |
    | Software Developer / Flash & Flex Developer | Student ( Computer Science ) | Interested in: Sharing Knowledge |
    |
    Romanian Adobe Flash, Flex, AIR Forum: http://www.flashforum.ro/
    | By perseverance the snail reached the ark. |


  20. #20
    Senior Member
    Join Date
    Jan 2008
    Posts
    150
    Saying something like "they couldn't have just dropped the export to frame capability from AS2" would have been a lot more useful than "that's wrong."

    If someone explains why I'm wrong instead of just saying that I am then I need to know more about how things work to decide that they are the ones who are wrong. Without that explanation it's a mystery as to whether or not they know better than I do and I'm completely in the dark about whether I should accept or reject what they said.

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