1
我嘗試做一對夫婦的閃存是由隨機的數字,但IM每次收到此錯誤的基本遊戲我跑我的場景:AS3閃存錯誤「無法訪問空對象引用的屬性或方法」
TypeError: Error #1009: Cannot access a property or method of a null object reference.
at capacitacion_fla::MainTimeline/frame1()
TypeError: Error #1009: Cannot access a property or method of a null object reference.
at capacitacion_fla::MainTimeline/frame1()
at flash.display::MovieClip/gotoAndStop()
at capacitacion_fla::MainTimeline/fl_ClickToGoToAndStopAtFrame()
我學習閃存和AS3,我將不勝感激,如果有人可以幫助我知道怎麼回事,我也離開你我的AS3代碼被全部放在幀1:
stop();
import com.greensock.*;
import com.greensock.easing.*;
import flash.events.MouseEvent;
import flash.display.MovieClip;
var blitMask1:BlitMask = new BlitMask(strip1,strip1.x,strip1.y,strip1.width,207,true,true,0xffffff,true);
var blitMask2:BlitMask = new BlitMask(strip2,strip2.x,strip2.y,strip2.width,207,true,true,0xffffff,true);
// ------- botones ----------
numerico_btn.addEventListener(MouseEvent.CLICK, fl_ClickToGoToAndStopAtFrame);
function fl_ClickToGoToAndStopAtFrame(event:MouseEvent):void
{
gotoAndStop(1);
}
preguntas_btn.addEventListener(MouseEvent.CLICK, fl_ClickToGoToAndStopAtFrame_2);
function fl_ClickToGoToAndStopAtFrame_2(event:MouseEvent):void
{
gotoAndStop(2);
}
imagenes_btn.addEventListener(MouseEvent.CLICK, fl_ClickToGoToAndStopAtFrame_3);
function fl_ClickToGoToAndStopAtFrame_3(event:MouseEvent):void
{
gotoAndStop(3);
}
//------- Fin de los botones ----------
//------------ Escena 1 ----------------------------------------------------
spin_btn.addEventListener(MouseEvent.CLICK, spin);
function spin(event:MouseEvent):void {
var i:int = 1;
while (i <= 2) {
var newNumber:Number = (randomNumber(0, 19) * 207) + 4968;
TweenMax.to(this["strip" +i], 2 + (i*.5), {y:strip1.y + newNumber});
i++;
}
}
function randomNumber(min:Number, max:Number):Number {
//good
return Math.floor(Math.random() * (1 + max - min) + min);
}
// ----------- fin escena 1 ----------
// ----------- Principio escena 2 -------------------
var blitMask3:BlitMask = new BlitMask(strip1q, strip1q.x, strip1q.y, 392 , strip1q.height, true, true, 0xffff00, true);
preguntas_btn.addEventListener(MouseEvent.CLICK, rodarPreguntas);
function rodarPreguntas(event:MouseEvent):void {
preguntas_btn.visible = false;
var newNumber1:Number = (randomNumber1(0, 50)*392) + 21168 ;
//tween to the relative value of newNumber
TweenMax.to(strip1q, 4, {x:String(-newNumber1), onComplete:showBtn});
}
function showBtn(){
preguntas_btn.visible = true;
}
function randomNumber1(min:Number, max:Number):Number {
//good
return Math.floor(Math.random() * (1 + max - min) + min);
}
// ------- Fin escena 2 --------
我希望有人可以幫助我搞清楚這一點!
看看右側的相關問題,以瞭解您的問題。這個問題每週至少會被詢問兩次。如果您在閱讀其他答案後仍然遇到問題,請嘗試更新您的問題以顯示您嘗試過的內容。 – Marty
馬蒂華萊士是正確的:這是一個非常標準的問題,並且在創建它的代碼中可能會出現很多事件。 – JustLogin
檢查您的關鍵幀(1,2,3)跳躍的位置。檢查這些關鍵幀上是否存在必需的對象。 –