In my library I have a movieclip that is linked to my AS3 custom class TweenButton. On the movieclip there is a textfield. I would like to be able to set the .text property of the textfield through TweenButton’s constructor, which must be so simple, but I haven’t been able to make it work. If someone could please explain it all to me slow and easy, I would be most gratefull. Here’s the code and source files:
package
{
import flash.display.*;
import TweenButton;
public class Base extends MovieClip {
private var __myFirstButton:TweenButton;
private var __mySecondButton:TweenButton;
private var __myThirdButton:TweenButton;
private var __myFourthButton:TweenButton;
public function Base() {
var myFirstButton:TweenButton = new TweenButton(150, 150);
__myFirstButton = myFirstButton;
var mySecondButton:TweenButton = new TweenButton(150, 190);
__mySecondButton = mySecondButton;
var myThirdButton:TweenButton = new TweenButton(150, 230);
__myThirdButton = myThirdButton;
var myFourthButton:TweenButton = new TweenButton(150, 270);
__myFourthButton = myFourthButton;
addChild(myFirstButton);
addChild(mySecondButton);
addChild(myThirdButton);
addChild(myFourthButton);
}
}
}
package
{
import flash.display.*;
import flash.events.Event;
import flash.events.MouseEvent;
import flash.events.*
public class TweenButton extends MovieClip {
private var __over:Boolean;
public function TweenButton(posX:Number, posY:Number) {
this.x = posX;
this.y = posY;
__over = new Boolean();
__over = undefined;
this.addEventListener(MouseEvent.MOUSE_OVER,overHandler);
this.addEventListener(MouseEvent.MOUSE_OUT,outHandler);
}
public function overHandler(e:MouseEvent):void {
__over = true;
this.addEventListener(Event.ENTER_FRAME,playForwards);
}
public function outHandler(e:MouseEvent):void {
__over = false;
this.addEventListener(Event.ENTER_FRAME,playBackwards);
}
public function playForwards(e:Event):void {
if(__over == true){
this.nextFrame();
}
}
public function playBackwards(e:Event):void {
if(__over == false){
this.prevFrame();
}
}
}
}
Fingers