Hello, I’m trying to create a universal fla file (shell.fla) in which I can load any swf file and control it from buttons in the shell itself. The buttons being play, pause, rewind, magnify etc. I’ve done all this in AS2 and now I have to do it in AS3. See my website http://www.eudv.de/Pages/flash.html - E-Training - Motor to get a better idea of what I mean.
The shell file has three buttons so far with instances called playMovie, stopMovie changeMovie and a dynamic text field - movieNumber. It is bound to the class Shell. The swf files to be loaded are numerical 1.swf, 2.swf, 3.swf etc. If I can get playMovie, stopMovie to work I can then do the rest.
Here is my code so far for the class Shell.as:
package {
import flash.display.MovieClip;
import flash.events.MouseEvent;
import flash.events.Event;
import flash.display.Loader;
import flash.net.URLRequest;
public class Shell extends MovieClip {
var movie:MovieClip;
var N:uint;
public function Shell() {
N=0;
// Buttons to control the movieClip instance movie
playMovie.addEventListener(MouseEvent.CLICK, onPlayClick);
stopMovie.addEventListener(MouseEvent.CLICK, onStopClick);
//Button to change movieClip
changeMovie.addEventListener(MouseEvent.CLICK, onChangeClick);
//maybe not necessary?
addEventListener(Event.ENTER_FRAME, onEnterFrame);
}
private function loadHandler(event:Event) {
var movie:MovieClip=event.target.content;
addChild(movie);
movie.stop();
}
private function onChangeClick(event:MouseEvent):void {
N++;
//Dynamic text to show which swf file is running
movieNumber.text=N+".swf";
if (N>0) {
//loads the next swf file
var nextMovie:URLRequest=new URLRequest(N+".swf");
var swfLoader:Loader = new Loader();
swfLoader.contentLoaderInfo.addEventListener(Event.COMPLETE, loadHandler);
swfLoader.load(nextMovie);
}
}
public function onPlayClick(event:MouseEvent):void {
movie.play();
}
public function onStopClick(event:MouseEvent):void {
movie.stop();
}
public function onEnterFrame(event:Event):void {
}
}
}
The problem:
- How can I kill, unload, removeChild the preceding swf file which has been loaded? When I load a swf file it creates a new loader.
- On the onPlayClick and onStopClick buttons I get the following error message:
TypeError: Error #1009: Der Zugriff auf eine Eigenschaft oder eine Methode eines null-Objektverweises ist nicht möglich.at Shell/onPlayClick()
Has anybody got any ideas please?