AS3类里用for循环复制MC,给MC加个id属性怎么加,
publicclassMianextendsSprite{privatevarmmc:MovieClip;publicvarid:Number;publicfunctio...
public class Mian extends Sprite
{
private var mmc:MovieClip;
public var id:Number;
public function Mian()
{
for (var i = 0; i < 13; i++)
{
var mmc:MovieClip = new m_mc();
mmc.name = "mc" + i;
mmc.id = i;//这属性点怎么定义
mmc.x = int(i % 6) * 180;
mmc.y = int(i / 6) * 160;
addChild(mmc);
mmc.buttonMode = true;
mmc.addEventListener(MouseEvent.CLICK,timerHandler);
}
怎么定这句话这id属性呢
报错:
ReferenceError: Error #1056: 无法为 m_mc 创建属性 id。
at Mian()
自已解决了
var mmc:MovieClip = new m_mc();
改成var mmc:m_mc = new m_mc(); 展开
{
private var mmc:MovieClip;
public var id:Number;
public function Mian()
{
for (var i = 0; i < 13; i++)
{
var mmc:MovieClip = new m_mc();
mmc.name = "mc" + i;
mmc.id = i;//这属性点怎么定义
mmc.x = int(i % 6) * 180;
mmc.y = int(i / 6) * 160;
addChild(mmc);
mmc.buttonMode = true;
mmc.addEventListener(MouseEvent.CLICK,timerHandler);
}
怎么定这句话这id属性呢
报错:
ReferenceError: Error #1056: 无法为 m_mc 创建属性 id。
at Mian()
自已解决了
var mmc:MovieClip = new m_mc();
改成var mmc:m_mc = new m_mc(); 展开
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询