Box2D Forums

It is currently Tue May 21, 2013 11:47 am

All times are UTC - 8 hours [ DST ]




Post new topic Reply to topic  [ 5 posts ] 
Author Message
PostPosted: Thu Jul 05, 2012 1:30 am 
Offline

Joined: Thu Mar 01, 2012 9:31 am
Posts: 153
Using Flash CS4, all box2d assets are loaded on frame 1. This means that the preloader doesn't show up for a long time.
Is there a way to "move" those to frame 2? I wonder if CS5/CS6 can handle that better?

I also tried a few preloader options (Flex, FlashDevelop) but couldn't really get those working. There might be a few things that I haven't tried yet.


Top
 Profile  
 
PostPosted: Thu Jul 05, 2012 6:35 am 
Offline

Joined: Tue Apr 17, 2012 12:08 am
Posts: 118
Have you tried changing the default load frame by going to File->Publish Setting then choosing Flash Tab and then at the very top choose Settings in front of Script->Actionscript3 , then in second box write 2 in place of one, then in your time line create a blank frame in front of all frames, put your preloader in the very first layer and in the first frame and below it all layers have an empty first frame, this way your preloader will load first and assets later .....


Jin


Top
 Profile  
 
PostPosted: Thu Jul 05, 2012 11:08 am 
Offline

Joined: Thu Mar 01, 2012 9:31 am
Posts: 153
Yes, I did that and my assets load fine on the second frame. It's the boxt2d scripts that load on first. I even checked with the 'Generate size report'. I wonder if it is because those are linked within the swc that somehow forces it to frame 1.


Top
 Profile  
 
PostPosted: Thu Jul 05, 2012 5:46 pm 
Offline

Joined: Thu Mar 01, 2012 9:31 am
Posts: 153
Finally found a solution that worked: http://stackoverflow.com/questions/5452 ... -bytearray

I did see many solutions for creating separate Preloader and Main classes which seemed to work with Flex and FlashDevelop. But Flash IDE couldn't find the "Main" variable when referred to it with getDefinitionByName("Main") in the Preloader class. The trick was to refer to Main class but not in the Preloader nor even the timeline (even on frame 2 or afterwards) because then everything referred to in Main would end of frame one. Instead of that: "on frame 2 of your movie, place an empty MovieClip. Inside this MovieClip, place a reference to your Main class by putting this code: var dummy:Main;"

"Simple"

The funny thing is, I do exactly the same thing for sounds :o


Top
 Profile  
 
PostPosted: Fri Jul 06, 2012 12:26 am 
Offline

Joined: Tue Apr 17, 2012 12:08 am
Posts: 118
Hi thanks for posting the solution, i have not used box2d so far , but preloader are always a tricky part for games development.... this will surely help many ....


Jin


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 5 posts ] 

All times are UTC - 8 hours [ DST ]


Who is online

Users browsing this forum: No registered users and 2 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Powered by phpBB® Forum Software © phpBB Group