Hierarchy
Level referencing
You know from the basic course that it’s possible to load one SWF file into another SWF as a level and make it a part of animation. You learned that default level is 0 and it may be many layers which are loaded one onto another accordingly to the number mentioned in the LoadMovieNum() action.
Now we will illustrate how levels are accessible programmatically through Flash movie hierarchy.
- Create a file with one animated movie symbol. In our example name of the file is “upperlevel.fla” and instance name of the movie symbol inside it - ”hammer”
- Publish this file into “upperlever.swf”
- Open another file and add four buttons to it – Load, Play, Stop and Unload
- Add this code to the buttons
- Load
on(release) { loadMovieNum("upperlevel.swf",5); } - Stop
on(release) { _level5.hammer.stop(); } - Play
on(release){ _level5.hammer.play(); } - Unload
on(release){ _level5.unloadMovie(); } - Publish and test the movie. You may see how external file is loaded ant them it’s content is referred through the _level from the root movie. In our example we referred an object inside the loaded file. If we need to access the main timeline of the loaded file it’s done simply like _level5.play();