|
-
[RESOLVED] Main.swf to load and unload scene.swfs
Hello there.
I've just recently made the leap from AS2 to AS3 and after several days of reading the CS4 help and searching posts here, I'm still at a loss how to get my first AS3 project off the ground.
I'm working on an illustrated choose-your-own-path story with each step split into seperate swfs to speed up loading time.
I've got a main file loading a scene swf using...
import flash.display.*;
var screen:MovieClip = new MyMovieClip();
addChild(screen);
var request:URLRequest = new URLRequest("scene1.swf");
var loader:Loader = new Loader();
loader.load(request);
screen.addChild(loader);
The loading works fine (although I've just found a post that suggests I should wait until the swf loads before adding it as a child), but how would I then get the buttons in the loaded swf to tell the main swf which swf to load next?
I'm stumped firstly by that, and additionally by how I should then UNload the swfs. Is it not common practice to refer to objects by their '.name' in AS3? Should I be loading the swfs into an array?
If someone could offer just a snifter of assistance, I'd greatly appreciate it.
Cheers.
-
Resolved!
Hello again.
Ain't that always the way? Look and look and look. Ask a question and then find the answer. Bah!
Anyway.
For anyone who doesn't know (perhaps I should have posted this in the newbies section?) if you want to refer back to a variable or function in a swf that has loaded the swf containing the code you're editting (still following me?) you can do this...
MovieClip(parent.parent.parent).myVariable = x;
or
MovieClip(parent.parent.parent).myFunction();
Apparently, all the 'parents' are to back up out of the instance of the loader that loaded the swf to the stage of the loading swf (clear as mud, right?).
The other problem I was encountering was I was inadvertantly creating a new loader each time I loaded a new swf, so it turned out unnecessary to unload the contents of the loader. The new swf replaces the old.
If I can figure out how, I'll try and mark this thread as resolved.
Thanks for the indirect help, flashkit!
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|