如何播放影片剪辑当你点击按钮 [英] How do I play movie clip when you click on button

查看:197
本文介绍了如何播放影片剪辑当你点击按钮的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我新闪....这里是我想要做的事。我工作的时间线,并且有一定的ActionScript 3 code(我有时间线上的操作层)。我不知道在code是什么点击一个按钮(我做的按钮影片剪辑,因为我想制作动画),它扮演一个影片剪辑。任何帮助将是AP preciated!谢谢

I am new to flash....Here's what I am trying to do. I working on the timeline and have some Actionscript 3 code (I have a actions layer on the timeline). I am not sure what the code is for clicking on a button(I made the buttons movie clips since I wanted to animate it) and it plays a movie clip. Any help would be appreciated! Thanks

推荐答案

假设你有一个按钮(影片剪辑)名为myButton的,一个影片剪辑命名为targetMc在舞台上,你可以做到这一点是这样的:

Assuming you have one button (movieclip) named "myButton" and one movieclip named "targetMc" on stage you can do it like this:

myButton.buttonMode = true; // set the movieclip to act as a button
myButton.addEventListener(MouseEvent.CLICK, onButtonClick); // add mouse listener

function onButtonClick(event : Event) : void
{
    trace("clicked" + event.target);
    //gotoAndPlay("someFrameLabel"); // plays frame in current timeline
    targetMc.gotoAndPlay("someFrameLabel"); // plays frame in instance "targetMc" timeline
}

这篇关于如何播放影片剪辑当你点击按钮的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆