Sozialcyke
01-31-2004, 04:18 PM
I'm trying to make my life easier by learning OOP (Object Oriented Programming) for Actionscript. So far, it has just made it more complicated.
I'm trying to create a menu system for my website. Here's the coding I have so far:
//menuItemClass constructor
function menuItemClass() {
}
menuItem.prototype = new MoveClip();
menuItem.prototype.ini(angle) {
this.angle = angle;
this.baseH = this._height;
this.baseW = this._width;
}
menuItem.prototype.move(tarAngle) {
//Complicated movement calculations I won't bore you with;
}
Object.registerClass("menuItem",menuItemClass);
_root.attachMovie("menuItem","menuItem1",1);
gallery = _root.menuItem1;
gallery.ini(0);
gallery.move(45);
Bascially, menuItemClass() is a subclass of MovieClip(). The ini() function of menuItemClass initializes the instance's location (since I don't know how to pass arguments to the constructor from inside of the attachMovie() function), and move() moves the instance to a specific spot on the stage based on some calculations. The only problem is it doesn't work. The menuItem instance gets attached to _root, but it just sits at (0,0) on the Stage.
I should point out that I'm using Flash MX with AS1, not Flash MX 2004 with AS2. I found the tutorial on Macromedia's Developer.net that explains how to do this in AS2.
Any help, or a pointer towards a reference, would be much appreciated.
Thanks in advance.
I'm trying to create a menu system for my website. Here's the coding I have so far:
//menuItemClass constructor
function menuItemClass() {
}
menuItem.prototype = new MoveClip();
menuItem.prototype.ini(angle) {
this.angle = angle;
this.baseH = this._height;
this.baseW = this._width;
}
menuItem.prototype.move(tarAngle) {
//Complicated movement calculations I won't bore you with;
}
Object.registerClass("menuItem",menuItemClass);
_root.attachMovie("menuItem","menuItem1",1);
gallery = _root.menuItem1;
gallery.ini(0);
gallery.move(45);
Bascially, menuItemClass() is a subclass of MovieClip(). The ini() function of menuItemClass initializes the instance's location (since I don't know how to pass arguments to the constructor from inside of the attachMovie() function), and move() moves the instance to a specific spot on the stage based on some calculations. The only problem is it doesn't work. The menuItem instance gets attached to _root, but it just sits at (0,0) on the Stage.
I should point out that I'm using Flash MX with AS1, not Flash MX 2004 with AS2. I found the tutorial on Macromedia's Developer.net that explains how to do this in AS2.
Any help, or a pointer towards a reference, would be much appreciated.
Thanks in advance.
