dcsimg
A Flash Developer Resource Site

Page 2 of 2 FirstFirst 12
Results 21 to 38 of 38

Thread: Actionscript 3 Preloader Problem

  1. #21
    The New Guy
    Join Date
    Nov 2007
    Posts
    67
    Guys, I think we need to focus here. This thread is getting a little heated for no reason, and we're not getting anywhere.

    This problem needs to be addressed - not just for myself, but for the other coders out there who go through the effort of learning AS3 and are then put off due to problems like this one.

    I'm so used to AS3's power and flexibility now that I simply cannot go back to the old ways. I'm sure I speak for a lot of people out there.

    Everybody has been helpful so far and some good stuff has been posted. But we're still nowhere near solving this issue. I know I ranted about Adobe earlier but out of honesty don't believe that a company as well respected as Adobe would release a development environment, encourage you to use the new language, and then cripple the most fundamental element of a flash movie, which is a pre loader that actually shows the progress before everything has loaded.

    As mentioned before my game is for web delivery to multiple sites, so separate assets and a separate pre loader is not ideal (considering the fact that some sites only allow you to upload 1 single swf).

    There's got to be a simple solution out there for this - I just know it.

  2. #22
    Mod cancerinform's Avatar
    Join Date
    Mar 2002
    Location
    press the picture...
    Posts
    13,448
    Ok, the article on the BIT-101 Blog describes the situation for Flex, where the movie has no timeline. Basically what it describes is to introduce frames, which usually are not allowed in Sprite-based objects. If you use Flash you don't have that problem, because you can create movies with frames. The main problem is export in frame1, which can be unchecked, although in AS2 it gave problems with components sometimes.
    - The right of the People to create Flash movies shall not be infringed. -
    | www.Flashscript.biz | Flashscript Biz Classes/Components |

  3. #23
    Senior Member
    Join Date
    Jan 2008
    Posts
    150
    Don't get me wrong, I can see that the way I learned it was a simplification and pretty much just incorrect. It's just unfortunate that I had to get that info from the links posted instead of the person telling me I was wrong.

    -but, to help move this back to the topic:
    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?!!)
    The link explaining it in Flex doesn't help because that's in flex. We need to figure out why those errors are there.

    So basically,
    If you use Flash you don't have that problem,
    except that he does have a problem.

    Can somebody put together something in Flash that preloads like this for us so we can at least see if there's an obvious difference between it and what he's doing?

  4. #24
    Mod cancerinform's Avatar
    Join Date
    Mar 2002
    Location
    press the picture...
    Posts
    13,448
    If we don't see the fla or a sample fla demonstrating the errors we can discuss for weeks without any further progress. The solution for Flex is not necessarily Flex specific. It is specific for Sprites. It, however, shows what you need: a timeline with two frames.
    - The right of the People to create Flash movies shall not be infringed. -
    | www.Flashscript.biz | Flashscript Biz Classes/Components |

  5. #25
    Senior Member
    Join Date
    Jan 2008
    Posts
    150
    Alright, can you link us your .fla f-zero?

  6. #26
    Junior Member
    Join Date
    Feb 2008
    Posts
    1

    This could be the reason

    Are you testing the preloader within Flash (Test Movie:CTRL+Enter) with an MP3 file on the local drive?

    Something like:

    Code:
    var sound:Sound = new Sound();
    var request:URLRequest = new URLRequest("my_song.mp3");
    ...
    sound.load(request);
    Because if you do, the preloader will not work properly, no matter if you try to simulate the download with the "Simulate Download" function of the debugger. The preloader will only appear (briefly) when the MP3 has totally been loaded, leaving you puzzled and wondering what you did wrong.

    If you try to test the same code -- and I'm assuming the preloader itself is working properly -- with an MP3 from the internet it should work as expected.

  7. #27
    The New Guy
    Join Date
    Nov 2007
    Posts
    67
    Hi Guys

    Thanks for all the replies and all the offers for help.
    I think you're right. I need to post an FLA so people can see whats
    going on.

    But just before I do, theres one more thing I want to try.
    I was looking at cancerinform's tutorials regarding the AS3 preloaders.
    A friend of mine was looking at these and said it might be a possible
    solution to my problem (hes a computer science type guy). I want to
    give this a go and see what happens.
    I've tried to follow the preloader tutorial but had little success and I'm
    not sure how to go about using the classes (I tried them before but had
    little success).

    Cancerinform, can you please help me here? Perhaps a quick explanation on how to use the classes or perhaps if you could post a small FLA which uses them, would be awesome! Thanks.

  8. #28
    Senior Member
    Join Date
    Jan 2008
    Location
    UK
    Posts
    269
    I've been following this thread with interest, as I've been struggling with the same thing - getting a preloader working with a game I've written in AS3, (with sounds), which keeps everything in one .swf file, with no need to load any external files. The question was asked above, has anyone actually managed this - well after quite a lot of struggling - yes, I think I have. It uses the method of putting the preloader onto frame one with some actionscript (which I found around here somewhere, forgive me as I can't remember who it was written by - perhaps it was cancerinform). The actionscript compares the bytesLoaded with the bytesTotal for the stage. You then drag everything from the library onto frame two, and then on frame three, you get rid of it all and have your main program script, which creates objects from the library dynamically. I will try and get a .fla posted tomorrow to show an example.
    Last edited by _Ric_; 02-03-2008 at 03:16 PM.

  9. #29
    Knows where you live
    Join Date
    Oct 2004
    Posts
    944
    Uh... You can do it the same way it was done in AS2.0...

    Frame 1:
    Code:
    var p:Number = root.loaderInfo.bytesLoaded / root.loaderInfo.bytesTotal * 100;
    trace (p);
    this.percent.text = p.toString();;
    if (p > 99) {
    	gotoAndStop(4);
    }
    Frame 2:
    Code:
    gotoAndPlay (1);
    Place all your exported assets on frame 3, dont export them on frame 1.
    Last edited by 691175002; 02-03-2008 at 03:48 PM.
    The greatest pleasure in life is doing what people say you cannot do.
    - Walter Bagehot
    The height of cleverness is to be able to conceal it.
    - Francois de La Rochefoucauld

  10. #30
    Mod cancerinform's Avatar
    Join Date
    Mar 2002
    Location
    press the picture...
    Posts
    13,448
    The use of the biz classes is very simple. Put them in the same folder as the fla file you are using. Here is an example for the preloader component:

    http://flashscript.biz/test/test/pre...ader_comp.html

    Here you can download the example:

    http://flashscript.biz/test/test/pre...ad_example.zip

    For it to function you need to download the biz classes as well and place the classes into the folder. Then test movie.

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

    All classes are documented with an example.

    EDITED (7.30 pm): I have added an mp3 file, since that seems to cause problems for some and it is all fine. Check the link for the movie.
    Last edited by cancerinform; 02-03-2008 at 11:24 PM.
    - The right of the People to create Flash movies shall not be infringed. -
    | www.Flashscript.biz | Flashscript Biz Classes/Components |

  11. #31
    Senior Member
    Join Date
    Jan 2008
    Location
    UK
    Posts
    269
    Here is a link to the .fla which shows an example of my preloader. As I mentioned, it's self contained, and seems to work fine with sounds as well. Note that I created a separate movie clip to contain the sounds (with one sound on each layer), and dragged this movie clip, as well as all other linked assets, onto the stage in frame 2. All linked assets have the 'export in frame 1' box unchecked. Any questions, just ask.

    http://www.andromedus.com/misc/rics%20preloader.zip

  12. #32
    The New Guy
    Join Date
    Nov 2007
    Posts
    67

    Preloader Challenge

    OK guys.

    I've knocked up a quick fla demonstrating the problem I'm having.
    I can't post the actual game I'm working on because its far too big.

    This test FLA contains one single embedded asset which is linked as a class. Its added to the stage as an instance using actionscript (which is how I do pretty much everything).

    I know theres a way to get round this by manually placing sounds and images on an unused frame and unchecking "export on 1st frame" but if you saw the size of my game you would realise thats almost impossible. I need to get round this problem without placing things on stage manually, but if the worst comes to the worst then I may have to employ that method.

    Theres a preloader in this FLA but if you simulate a download and set the speed to something low, you will see that nothing happens until the whole thing has loaded.

    OK guys, check out the FLA and if you can help me out with this problem then I'll be very grateful! Thanks!

    PS: Cancerinform - I tried using your preloader class but it gave me the same result. I may have done it wrong though - I'm not sure.
    Attached Files Attached Files

  13. #33
    Mod cancerinform's Avatar
    Join Date
    Mar 2002
    Location
    press the picture...
    Posts
    13,448
    I see the problem. This is very similar to the problem in former flash versions with components. The only thing you can do is load into an empty movie. I made an example and also change the preloader script. This is the only way you can do it if you do not place every item on the timeline.

    http://flashscript.biz/test/test/pre...er_parent.html

    http://flashscript.biz/test/test/pre...reloaderfk.zip
    - The right of the People to create Flash movies shall not be infringed. -
    | www.Flashscript.biz | Flashscript Biz Classes/Components |

  14. #34
    The New Guy
    Join Date
    Nov 2007
    Posts
    67
    Thanks for that! I've managed to get a pre-loader working which loads an external swf file, but I've still had no luck with the integrated single-file version. I even tried importing the main swf into the library of the preloader and it didn't work. Theres got to be a solution for this out there somewhere. I just know it.

    But anyway, for now I'm having to place things on stage manually for all my small games and for my main project I'm just gonna have to use an external preloader and manually email a zip file to the webmaster of any flash games site who normally only allow you to upload a single swf.

    Heres me, hoping there is someone out there reading this, who can help solve this issue!

  15. #35
    Junior Member
    Join Date
    Mar 2008
    Posts
    1
    Original poster,

    I was having the same problem as you. When attempting to preload all frames after the first using loaderInfo and unchecking "export in first frame", I would get compiler errors, specifically:

    Code:
    ReferenceError: Error #1065: Variable TeamClip is not defined.
    	at AboutContent/TeamDown()
    If this is the problem you are having, the solution is simple but tedious. As some above posters mentioned, you need to copy all the library items that are having the aforementioned errors to the frame where you use them. Since most of my library items are being instantiated via ActionScript, this is not done automatically.

    My project is two frames: one for the preloader, and one for the main content. I created a second layer for my scene called "preloaded items" and pasted all the items (mainly movieclips) from my library onto this layer in frame 2. Then I made it invisible. Voila, no more errors.

    You can see the result here: http://cuir.hopto.org/riverpulse/riverpulse.html

  16. #36
    Senior Member
    Join Date
    Mar 2003
    Location
    UK
    Posts
    109
    I've done it the way entechie suggested and the way I've always done it in AS2 but to be honest, it's ugly and I agree that Adobe should have given us a more elegant way in AS3 ... ha well, the rest of AS3 is pretty cool at least.

  17. #37
    Junior Member
    Join Date
    May 2008
    Posts
    12

    Links not working

    I've made a little preloader in AS3 that works.

    It shows a 'spinning circles' animation with the % loaded underneath.

    Problem is it's a standalone preloader and uses the loader function to load in the main SWF.

    The main SWF file contains links to websites, which work fine if I don't use the preloader, but just don't do anything if I do use the preloader, any ideas guys ?

    I think the problem maybe in my "completed" handler below:


    function completed(e:Event):void
    {
    ring.visible=false;
    textbox.visible=false;
    addChild(loader);
    }

  18. #38
    Junior Member
    Join Date
    May 2008
    Posts
    12
    Quote Originally Posted by pete0766
    I've made a little preloader in AS3 that works.

    It shows a 'spinning circles' animation with the % loaded underneath.

    Problem is it's a standalone preloader and uses the loader function to load in the main SWF.

    The main SWF file contains links to websites, which work fine if I don't use the preloader, but just don't do anything if I do use the preloader, any ideas guys ?

    I think the problem maybe in my "completed" handler below:


    function completed(e:Event):void
    {
    ring.visible=false;
    textbox.visible=false;
    addChild(loader);
    }

    Ignore that that, I was being a plank, I was loading the swf from a subdomain of the domain it was in, cross domain error!

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