【发布时间】:2013-07-02 07:39:05
【问题描述】:
我在图书馆里有一个符号,在舞台上我有十二个符号对象。 每个符号都有一个实例名称,来自 a-l
此外,我还有 12 个对象 (image ) 实例名称,从 1 到 12
我单击了图像中的一个对象,我可以从数组中提取名称对象 (a-l) 但不能访问 while。
如何在 as3 中将字符串转换为实例名称
var abc:Array = ["0","a","b","c","d","e","f","g","h","i","j","k","l"];
function item_onMouseUp(event:MouseEvent):void
{
var clip:Sprite = Sprite(event.currentTarget);
var c:int = int(clip.name);
trace("abc[c]=" +[abc[c]]);
//The problem here
if (clip.hitTestObject([abc[c]]))
{
trace("===");
}
clip.stopDrag();
}
以我得到的跟踪胜利为例
abc[c]=d
TypeError: Error #1034: Type Coercion failed: cannot convert "d" to flash.display.DisplayObject.
at gamewitoutserver_fla::MainTimeline/item_onMouseUp()
【问题讨论】:
标签: actionscript-3