Hi there
I’m new to AS3.0. I know Java and some C++ so I think I can handle OOP good enough. But Flash is just something different.
Some years ago, in AS2.0, I created a simple button (think of that as a SimpleButton as in AS3.0). There is a dynamic textfield with instance name “displayText” in it. The idea is that I can reuse the button by just changing the action and text of the button.
In AS3.0, I’m trying to do something the same.
I have a FLA file created. The document class is called Main. Here is Main.as.
package {
import flash.display.*;
import MenuButton;
public class Main extends MovieClip {
public var bg:MainBg = new MainBg();
public static var btn1:MenuButton = new MenuButton(500,500);
public function Main() {
addChild(bg);
addChild(btn1);
}
}
}
Here is MenuButton.as.
package {
import flash.display.SimpleButton;
import flash.display.MovieClip;
import flash.events.MouseEvent;
public class MenuButton extends SimpleButton {
public var masterMenu:MovieClip;
public var menuToOpen:MovieClip;
public function MenuButton(xPos:Number, yPos:Number):void {
x = xPos;
y = yPos;
this.addEventListener(MouseEvent.CLICK, actionOnClick);
}
public function actionOnClick(e:MouseEvent):void {
//do something
}
}
}
Well, I tried this.displayText.text = “Something”, but of course it doesn’t work. I tried accessing from the document class, i.e. btn1.displayText.text = “Something”, and it doesn’t work either.
Er… Hungry, thirsty and frustrated… How to make it work???
Thanks in advance.
Felastine.