将Button替换为变量AS3

时间:2014-06-22 01:18:20

标签: actionscript-3 flash-cs5

当我想将按钮替换为变量时,我遇到错误#1046,非常感谢任何类型的帮助。

var w1:ColorTransform = new ColorTransform();
w1.color =0xCC0000; //red dark
var w2:ColorTransform = new ColorTransform(); 
w2.color = 0xB3B3B3; //Grey 

// error--------
var boxNow:Button; <= These 2 lines gives me error
boxNow = boxQ;
//---------

boxNow.addEventListener(MouseEvent.MOUSE_OVER, myHover);

function myHover(event: MouseEvent):void{
    boxNow.removeEventListener(MouseEvent.MOUSE_OVER, myHover);
    boxNow.transform.colorTransform = w1;
    boxNow.addEventListener(MouseEvent.MOUSE_OUT, myOut);
}

function myOut(event:MouseEvent):void{
    boxNow.removeEventListener(MouseEvent.MOUSE_OUT,myOut);
    boxNow.transform.colorTransform = w2;
    boxNow.addEventListener(MouseEvent.MOUSE_OVER, myHover);
}

1 个答案:

答案 0 :(得分:3)

首先创建一个像这样的对象

var boxNow:Button = new Button();

然后chek boxQ的类型