AS3动态按钮名称捕捉的问题 [英] as3 dynamic button name capturing problem

查看:89
本文介绍了AS3动态按钮名称捕捉的问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我用这code以下,动态捕捉的按钮pressed的名称,然后播放相关的气球影片剪辑动画。

i am using this code below to dynamically capture the name of the button pressed and then playing the related balloon movie clip animation.

stage.addEventListener(MouseEvent.CLICK, player); 

function player(evt:MouseEvent){
var nameofballoon = evt.target.name;
 nameofballoon =nameofballoon.substring(nameofballoon.length-1,nameofballoon.length);
var movie = "balloon"+nameofballoon;
 trace(movie);
movie.gotoAndPlay("burst");

  }

我得到这个错误,即使夹子捕获的事件的名称是否正确

i'm getting this error even though the name of the clip capture by the event is correct

TypeError: Error #1006: value is not a function.
at Balloons2_fla::MainTimeline/player()

有什么想法?有什么不对的code?

any thoughts ? what wrong with this code?

推荐答案

您变量电影被认为是一个字符串。
你应该尝试是这样的:

Your variable movie is considered as a String.
You should try something like this :

var movie:MovieClip = this["balloon"+nameofballoon];
movie.gotoAndPlay("burst");

您可能必须更换由母公司的名称,你的 ballonX 影片剪辑。

You may have to replace this by the name of the parent of your ballonX MovieClip.

这篇关于AS3动态按钮名称捕捉的问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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