i’m trying out AS2.0 for the first time (yes, i’m behind… sigh) and i’m running into a problem with extending MovieClip.
in 1.0, i’m a big fan of dave yang’s setClass function, i would write a class and always include a MovieClip.prototype.create[ClassName] function so i could use it just as you would createEmptyMovieClip.
this was great because it let me place a movie clip on the stage, of whatever class i’d written.
function Grid(){
//grid stuff
}
Grid.prototype.__proto__ = MovieClip.prototype;
MovieClip.prototype.createGrid(name,level){
var g = this.createEmptyMovieClip(name,level);
g.setClass(Grid);
return g;
}
then i can go:
_root.someClip.createGrid(‘myGrid’,0);
and voila, a grid is created in someClip.
with 2.0, i’d like to use the new syntax, but still want to be able to place a clip on the stage of whatever class.
i’ve tried associating a clip which i create manually with the class, but that’s messy and creates 2 objects where i feel only 1 is necessary.
like this…
class Grid extends MovieClip {
private var _rows;
private var _cols;
private var _mc;
function Grid(rows:Number, cols:Number, parentClip:MovieClip, name:String, level:Number){
_rows = rows;
_cols = cols;
_mc = parentClip.createEmtpyMovieClip(name,level);
}
}
so _mc is a reference to a clip somewhere that the Grid instance would control.
is there a way to make
_root.someClip.myGrid = new Grid(args);
create a clip in _root.someClip named myGrid of class Grid?
or can i integrate AS2.0 into my comfortable old way and still reap the benefits (there are benefits, right?) of the new player?