Hi everyone,
I’ve been playing around with custom classes.
My objective was to create a custom class (Testing) that would create a box when an instance of the class is created. I’ve tried three different approaches, however only (3) seems to be showing up.
I’m just curious why (1) or (2) doesn’t work?
Also is there a better approach than (3)? Since at the moment it’s been created on _root. I hope the box can only be accessible through the instance. Since I’d like to incorporate the whole idea of public, private, encapsulation, etc.
Any opinions or suggestions would be most helpful.
regards,
Mike
// AS2 testing line creation in classes.
class Testing extends MovieClip {
// Constructor
function Testing() {
// (1)
// Doesn't work
// Nothing shows up.
/*
lineStyle(2, 0xff0000, 100);
moveTo(0,0);
lineTo(0,200);
lineTo(200,200);
lineTo(200,0);
lineTo(0,0);
*/
// (2)
// Doesn't work
// Nothing shows up.
/*
this.createEmptyMovieClip("abc",this.getNextHighestDepth());
abc.lineStyle(2, 0xff0000, 100);
abc.moveTo(0,0);
abc.lineTo(0,200);
abc.lineTo(200,200);
abc.lineTo(200,0);
abc.lineTo(0,0);
*/
// (3)
// Works, but I don't think it's the best approach.
/*
var tmp = _root.createEmptyMovieClip("abc",_root.getNextHighestDepth());
tmp.lineStyle(2, 0xff0000, 100);
tmp.moveTo(0,0);
tmp.lineTo(0,200);
tmp.lineTo(200,200);
tmp.lineTo(200,0);
tmp.lineTo(0,0);
*/
}
}