修改根時間軸設置的變量,我是相當新的動作腳本3,我有一個框架上,我的根時間軸中的變量設置字符的速度我的遊戲:AS3從類
var userSpeed:Number = 2;
現在,我有一堂課爲我的拍攝,並且我添加了一個熱門測試,以便當我開機時它將速度更改爲4(默認值的兩倍),但由於這是在我的班級內,因此我想知道如何在課堂上從這裏修改變量。
if(this.hitTestObject(speedPower) || this.x < 0 || this.x > stage.stageWidth || this.y < 0 || this.y > stage.stage.height)
{
this.removeEventListener(Event.ENTER_FRAME, moveShot);
this.parent.removeChild(thisshootTurret);
this.parent.userSpeed = 4;
}
訪問變量只是一個隨機猜測的方式,我無法找到互聯網或這裏適合我的問題,所以這是所有我能想出問題上的任何東西。
目前的方式給了我這個錯誤:
1119: Access of possibly undefined property userSpeed through a reference with static type flash.display:DisplayObjectContainer.
,我也得到了同樣的錯誤,當我嘗試:
root.userSpeed = 4;
有什麼建議?
對不起,我的回答錯了,我不明白你的問題。 – 2013-02-24 16:14:13
這很好,我真的需要幫助,你沒有任何想法我可以從我的班級更改該變量嗎? – Engine 2013-02-24 16:21:48
'MovieClip(this.parent).userSpeed = 4'? – 2013-02-24 16:41:46