2012-03-08 124 views
1

大部分是工作,即使有错误,则会继续以部分工作:AS3这段代码有什么问题?

// Make PostItNote MC draggable and keep ON TOP 
mcMXredBox.addEventListener(MouseEvent.MOUSE_DOWN, fl_ClickToDrag); 

var q:int = 1; 

// Add multiple copies of PostItNote when used 
function fl_ClickToDrag(event:MouseEvent):void 
{ 
    event.currentTarget.parent.startDrag(); 
    event.currentTarget.parent.parent.setChildIndex(DisplayObject(event.currentTarget.parent),87); 
    var my_PIN = new postItNote(); 
    my_PIN.name = "my_RTC" + q; // Doesn;t like this line 
    this.parent.addChild(my_PIN); 
    trace("my_PIN = " + my_PIN); 
    this.my_PIN[q].x = 1388.05; // Doesn't like this line 
    this.my_PIN[q].y = 100; 
    q++; 
} 

的错误是

TypeError: Error #1010: A term is undefined and has no properties. 
    at postItNote/fl_ClickToDrag()[postItNote::frame1:71]" 
+0

你可能需要提供更多的信息。 this.my_PIN在哪里声明?它是一个数组? (你正在作为一个访问它)。 postItNode中是否有名称公共属性?等 – Ben 2012-03-08 10:29:11

回答

1

my_PIN.name = “my_RTC” + Q; // Doesn; t like this line

这表示name不是postItNote类的属性。

this.my_PIN [q] .x = 1388.05; //不喜欢这一行

你似乎在这里使用了错误的语法。你想要的可能只是:

my_PIN.x = 1388.05; // In this context, my_PIN already refers to the movie clip named '"my_RTC" + q' 
+1

改变语法是正确的,我已经离开了其他代码!一定很累。谢谢。另外,仅仅使用my_PIN.x是正确的,我把自己和括号混淆了。再次感谢! – user1203605 2012-03-08 10:38:29