Hi There,
I’m trying to build an attachmovie class so I can add a child movieclip from the library and define the x and y coords using only one line of as in the fla
Here is my fla code:
var newMovie:AttachClip = new AttachClip(“movie_mc”, 10, 10);
And here is my as code:
package {
import flash.display.*;
import flash.utils.getDefinitionByName;
// create class
public class AttachClip extends MovieClip {
// define vars
var movieName:MovieClip;
var movieX:Number;
var movieY:Number;
function AttachClip(movieVal:String, movieX:Number, movieY:Number) {
var movieDefinition = getDefinitionByName(movieVal);
movieName = new movieDefinition;
movieName.x = movieX;
movieName.y = movieY;
addChild(movieName);
}
}
}
The trouble is that it is not adding the child to the stage, now I have a feeling that I need to tell flash where to add the child to but I cant figure out how to reference the stage from the as file, any thoughts?
Thanks,
Bob