使用 MovieClip (root) 制作滑动按钮功能时遇到问题。
addEventListener (Event.ENTER_FRAME, onenterFrameHandler);
当给定一个命令按钮时..addEventListener (MouseEvent.CLICK, fl_ClickToGoToScene_20);
当我单击按钮时,我得到输出
TypeError:错误#1009:无法访问空对象引用的属性或方法。在 index_fla::MainTimeline/onenterFrameHandler()
这是我的代码:
var myVar:Boolean;
MovieClip(root).addEventListener(Event.ENTER_FRAME,onenterFrameHandler);
MovieClip(root).addEventListener(MouseEvent.CLICK, mouseClickHandler);
function onenterFrameHandler(event:Event):void
{
if (MovieClip(root).mouseY < 500)
{
myVar=false;
}
if (MovieClip(root).mouseY > 500)
{
myVar=true;
}
if (MovieClip(root).mouseX > 1266 && myVar==true)
{
imgbar.nextFrame();
} else {
imgbar.play();
}
if (MovieClip(root).mouseX < 100 && myVar==true)
{
imgbar.prevFrame();
} else {
imgbar.play();
}
if (MovieClip(root).mouseX > 100 && mouseX < 1266 && myVar==true)
{
imgbar.stop();
}
}
在按钮层中,我填写代码来命令我的按钮/电影剪辑;
btn1.addEventListener(MouseEvent.CLICK, fl_ClickToGoToScene);
function fl_ClickToGoToScene(event:MouseEvent):void
{
MovieClip(this.root).gotoAndPlay(80, "Scene 2");
}
请帮我