I have recently become aware that i need to structure code in a more organised fashion. Is there anything wrong with this way of storing/retrieving info within objects? Any potential problems/limitations?
//mc instance name mc
//mc instance name mc1
function Myclass(x, y, a) {
this._x = x;
this._y = y;
this._alpha = a;
}
Myclass.prototype.onPress = function() {
trace(this._name);
};
function Mysubclass(x, y, a, targetX, sc) {
super(x, y, a);
this._xscale = this._yscale=sc;
this.targetX = targetX;
}
Mysubclass.prototype = new myclass();
Mysubclass.prototype.move = function() {
this._x += (this.targetX-this._x)/5;
if (Math.abs(this.targetX-this._x)<1) {
this._x = this.targetX;
delete this.onEnterFrame;
}
};
Mysubclass.prototype.onRelease = function() {
this.onEnterFrame = this.move;
};
mc.obj = new myclass(500, 400, 30);
mc1.obj = new mysubclass(200, 200, 50, 500, 50);
for (var prop in this) {
if (typeof (this[prop]) == "movieclip" && this[prop].obj) {
trace(this[prop].obj);
for (var prop1 in this[prop].obj) {
this[prop][prop1] = this[prop].obj[prop1];
}
}
}