PDA

View Full Version : splitting a large project into modular swfs


Jas_The_Ace
09-05-2008, 12:45 PM
I have written a suite of 5 games which run in projector mode. I would like to know if this is good practice:

I divided the project up into separate swfs - one for the main menu, and one for each game. I use a single loader object to load the different swfs. Each time I load a swf it replaces the previous one.

I built it this way because a single swf took too long to compile.
Also, I thought I would be able to migrate to AS3 one module at a time.

Is this good practice? Is it feasible?

spooks
09-08-2008, 05:30 PM
I'm wondering this as well.

Jas_The_Ace
09-08-2008, 11:39 PM
Are you using Loader class in AS3?

What problems have you encountered / do you foresee?

Assertnfailure
09-09-2008, 03:52 AM
Yeah, it definitely is.
You don't need to load all the games into the same projector, especially if the games use a lot of resources. Plus you don't want to have to recompile the projector every time you change the games, do you?

Jas_The_Ace
09-11-2008, 12:46 AM
Thanks Assert that's very reassuring

My game uses one projector exe that has one Loader. The loader only holds one swf at a time, so if you change game it just replaces the old one.

Interesting idea to turn all the games into projectors but thats a lot of Meg.

My probelm is that some of the games are in AS2 and they do some strange things when you load them from AS3.

Has anyone elase had experience of this?

Assertnfailure
09-12-2008, 10:55 PM
Thanks Assert that's very reassuring

My game uses one projector exe that has one Loader. The loader only holds one swf at a time, so if you change game it just replaces the old one.

Interesting idea to turn all the games into projectors but thats a lot of Meg.

1) You don't have to turn all the games into projectors. Just create one projector interface that lets you swap between games (and then just compile the games as swf files).

2) You can prevent filesize overhead by compiling common classes/assets into the main projector. For class files, Flex Builder 3 has a means of doing this for you...otherwise you'd probably have to write some compiler directives to handle that sort of thing.

maskedMan
09-16-2008, 05:30 PM
One of the biggest things you'll have to watch out for when migrating to AS3 is that each module will have to be absolutely meticulous about cleaning up after itself when it's unloaded. Leave no listener un-removed, and leave no timeline, interval, Timer object, or SoundChannel playing. Read up on some of the articles written on the topic by Colin Moock and Grant Skinner for just exactly what to watch out for.

Jas_The_Ace
09-26-2008, 11:31 AM
Thanks Masked Man. This looks very important.

Could you please post a link to Colin Moock's. I read Grant Skinner's 3 Acticles, but I'm still waiting for the 4th one.

Can anybody please tell me how the garbage collector works when AS3 loads an AS2 movie and then unloads it?

maskedMan
09-26-2008, 04:27 PM
Here is the link to Colin Moock's article. It's by no means as exhaustive as Grant Skinner's writings, but it provides a handy checklist.

http://www.moock.org/blog/archives/000279.html

EDIT:

Also, this is another Skinner article on the topic, written after the original 3

http://www.gskinner.com/blog/archives/2008/04/failure_to_unlo.html

kbrouill
10-08-2008, 01:19 PM
I am doing a similar thing. I created a projector and it loads one swf at a time, depending on what button the user presses. The problem that I am having is that I cannot pass parameters to the loaded swf. When my main program was a swf file, I could pass parameters when I loaded. Anyone know how to pass parameters when a projector loads a swf?

Here is the request I am making:

requeststring = "MyProgram.swf?gh=1&htmlh=10&stgt=" + gtargument[j];

kbrouill
10-08-2008, 04:07 PM
I found the answer to my question. Here is how you do it:

Create a listener for the load complete:

myloader.contentLoaderInfo.addEventListener(Event. COMPLETE, onLoaded);

In the onLoaded routine, set up some variables for the loaded swf

function onLoaded(e:Event) {
var loadedSwf:* = e.target.content;
loadedSwf.loaderstgt = "test";
}

In your swf that is loaded, pick up the variable off of the root

if (root.loaderstgt != null)
this.stgt = root.loaderstgt;
}