0

我正在尝试为影片剪辑编写可见 = true/false,当您按住鼠标按钮时,它是可见的,而当您松开鼠标按钮时,它就不再可见了!但我无法让它工作,请看看并帮助我:)

import flash.events.Event;
import flash.events.MouseEvent;
import flash.media.Sound;

var mouseIsDown = false;
var speed = 0; 
var score = 0;
var flames:MovieClip = new Flammer()
Flammer.visible = false;
addEventListener(Event.ENTER_FRAME, mainLoop);
stage.addEventListener(MouseEvent.MOUSE_DOWN, clicked);
stage.addEventListener(MouseEvent.MOUSE_UP, unclicked);




function clicked(m:MouseEvent){
mouseIsDown = true;
}
function unclicked(m:MouseEvent){
mouseIsDown = false;

}
function mainLoop(e:Event) {
score = score + 10;
output.text = "Score: " + score;
    if (mouseIsDown) {
    speed -= 2;
    Flammer.visible = true;


} else {
    speed += 2;


}
if (speed > 10) speed = 10;
if (speed < -10) speed = -5;
Player.y += speed;



for (var i = 0; i<numChildren; i++) {
    if(getChildAt(i) is Block || getChildAt(i) is Boundray) {
        var b = getChildAt(i) as MovieClip;
        if(b.hitTestObject(Player)) {
            trace("Hit");
            removeEventListener(Event.ENTER_FRAME, mainLoop);


        }

    } 
} 

}
4

1 回答 1

1

该特定错误告诉您,在您拥有的第 9 行Flammer.visible = false;没有这样的对象称为Flammer,那是一个类。你想要实例化的对象。正确写将是

flames.visible = false;

您还想在第 29 行修复它,在那里您重复相同的问题。

于 2013-10-29T19:15:35.253 回答