March 3, 2008 - Comments Off on Controlling Loaded SWFs from the Base Timeline in AS3

Controlling Loaded SWFs from the Base Timeline in AS3

code.jpg

I stumbled onto a new problem that switching to Actionscript 3 has caused me. The basics of it are trying to control timelines or movieclips of swfs I loaded into another movie. In the past with actionscript 2 the way I'd work things was create a base flash file and from there load the bits and pieces (other swfs) that made up the flash site. There are a few reasons behind this thought: On one hand your base file stayed pretty small in file size and loaded quickly; on another the visitor only downloads the portions of the site need (instead of downloading the whole shebang). Think modular like legos. No need for the whole bucket of parts when 5 to 6 pieces complete the space cruiser.

Anyway, the old method in AS2 was easy you simple targeted the movieclip you loaded the swf file into and then could easily control the timeline or have the objects to do whatever you wanted them to (_root.holder_mc.some_mc.play()). In AS3 it's not the same.

I've created a simple file of how I've figured out how to do it. The short and easy of it is you have to create an object that's defined by the loader that you create to load your swf file into. Once you look at the sample files it'll make more sense.

The ZIP contains 3 flash movies "the_base.swf", "soundfx.swf", and "buttons.swf." The "the_base.swf" basically loads the other two files and contains all the actionscript that controls the other two movies.

base_mc_controls_loaded_swfs.zip

Published by: marc in Tutorials

Comments are closed.