Hello everyone, I’m pretty new in CS3 and this being my first post, i’ll just be quick (if I can…). My first question is a pretty noobish one, i’ve just started using .as files. **How do I export the working swf **? It seems when I export the swf like I usually do, it doesn’t recognize the external .as files. Sorry, but I can’t seem to find any documentation on using .as files in the help or on the net. I pretty much figured out everything except this exporting bit. Do I have to use an external program ? None of the publish settings seem to affect this… so how do I do it?
Now to the code question. I’ll just set up the context. I have an external class that extends the movieclip class, i put an instance of the class on the stage using addChild. Now, I want to remove this object when I press a button and put a new one in it’s place (the ideea is that the graphics contain some random stuff generated in the class constructor). It seems pretty simple… yet it dosen’t work.
var myObject:myClass = new myClass();
addChild(myObject);
myButton.addEventListener(MouseEvent.CLICK, remove);
function remove(e:Event): void {
removeChild(myObject);
var myObject:myClass = new myClass();
addChild(myObject);
}
In the remove function, without the last two lines, the code removes the object on the stage, then at the second click on the button, it returns an error, saying: “The supplied DisplayObject must be a child of the caller.” It’s ok, so he’s trying to remove the object but it’s not on stage anymore. Then I add the last 2 lines, even on the first click on the button the output says: “Parameter child must be non-null.” and I guess he’s talking about addChild(myObject). So ok, i comment the last addChild line, and still the same error.I guess there’s a conflict in using the same object name? But then how do I release an object from the memory. I’m kind of lost here.