在按钮实例内播放影片剪辑实例
问题描述:
我在一个按钮内放置了一个影片剪辑实例,并且我想在释放按钮时播放此影片剪辑。我使用的是包含按钮在框架上的代码:通过一个可能未定义的属性theMC的访问:在按钮实例内播放影片剪辑实例
function playMovie(event:MouseEvent)
{
this.theButton.theMC.gotoAndPlay(3);
}
theButton.addEventListener(MouseEvent.MOUSE_UP, playMovie);
当我尝试测试Flash影片,我得到这个消息:
1119引用静态类型flash.display:SimpleButton。
我可以有点理解为什么它不喜欢它,但我不知道如何解决这个问题。
答
如果你是theButton里面已经那么你就不需要调用“this.theButton”,因为“theButton”是“这个” 尝试
this.theMC.gotoAndPlay(3);
,如果你仍然不确定对象的父子关系,并且您正在使用闪存IDE,在您的操作面板中,单击操作面板顶部的蓝色目标,找到您想要引用的MC,并让闪存IDE找出您的关系。
答
在您的按钮中给movieclip一个实例名称“theMC”。然后使用以下代码:
function playMovie(e:MouseEvent)
{
this.theButton.getChildByName("theMC").gotoAndPlay(3);
}// end function
theButton.addEventListener(MouseEvent.MOUSE_UP, playMovie);