2012-03-08 118 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