我已複製的對象在另一幀使用它的屬性或方法(該對象使用Greensock滾動X軸和我使用的功能(onMove (EVT:MouseEvent)方法),但是當我移動鼠標這個錯誤在輸出選項卡TypeError: Error #1009: Cannot access a property or method of a null object reference. at Main_fla::mainContianer_1/onMove()
來了,當我按下一個按鈕,進入新的對象這個錯誤出現TypeError: Error #1009: Cannot access a property or method of a null object reference. at com.greensock::TweenLite/init() at com.greensock::TweenLite/renderTime() at com.greensock.core::SimpleTimeline/renderTime() at com.greensock::TweenLite$/updateAll()
和舊的對象出現AS3 - 類型錯誤:錯誤#1009:無法訪問空對象引用
這裏是我的舊行爲
import com.greensock.TweenLite;
import com.greensock.easing.Back;
import com.greensock.easing.Elastic;
import com.greensock.plugins.TweenPlugin;
import com.greensock.plugins.BlurFilterPlugin;
var panelContainer:Sprite = new Sprite;
addChild(panelContainer);
for(var i:Number=0;i<3; i++) {
var projectPanel:ProjectPanel = new ProjectPanel;
projectPanel.x = i*(projectPanel.width+10);
panelContainer.addChild(projectPanel);
projectPanel.addEventListener(MouseEvent.CLICK, onClick);
}
function onClick(evt:MouseEvent):void {
TweenLite.to(panelContainer, 0.5, {y:stage.stageHeight, ease:Back.easeIn});
MovieClip(this.parent).addFullPanel(Number(evt.currentTarget.name));
}
function slideUp():void {
TweenLite.to(panelContainer, 0.5, {y:0, ease:Back.easeOut});
}
stage.addEventListener(MouseEvent.MOUSE_MOVE, onMove);
function onMove(evt:MouseEvent):void {
if(MovieClip(this.parent).fullProjectPanelUp==false){
TweenLite.to(panelContainer,0.3, {x:- (stage.mouseX/1225)*panelContainer.width+stage.stageWidth/2.65});
}
}
stop();
和新的動作:
import com.greensock.TweenLite;
import com.greensock.easing.Back;
import com.greensock.easing.Elastic;
import com.greensock.plugins.TweenPlugin;
import com.greensock.plugins.BlurFilterPlugin;
var lessonContainer:Sprite = new Sprite;
addChild(lessonContainer);
for(var p:Number=0;p<8; p++) {
var lessonPanel:LessonPanel = new LessonPanel;
lessonPanel.x = p*(lessonPanel.width+10);
lessonContainer.addChild(lessonPanel);
lessonPanel.addEventListener(MouseEvent.CLICK, onClick);
}
function onClickLesson(evt:MouseEvent):void {
TweenLite.to(lessonContainer, 0.5, {y:stage.stageHeight, ease:Back.easeIn});
MovieClip(this.parent).addfullLessonPanel(Number(evt.currentTarget.name));
}
function slideLessonUp():void {
TweenLite.to(lessonContainer, 0.5, {y:0, ease:Back.easeOut});
}
stage.addEventListener(MouseEvent.MOUSE_MOVE, onMove);
function onLessonMove(evt:MouseEvent):void {
if(MovieClip(this.parent).fullLessonPanelUp==false){
TweenLite.to(lessonContainer,0.3, {x:-(stage.mouseX/1225)*lessonContainer.width+stage.stageWidth/2.65});
}
}
stop();
這裏是Project Files如果u需要他們
您使用的MovieClip(this.parent)所有的地方還沒有這樣做沒有類中的代碼。那麼讓我問你,「this.parent」是指什麼? – 2012-02-27 23:33:56
fullProjectPanel – aymanzzz 2012-02-27 23:36:30
我怎樣才能使參考fullLessonPanel?! – aymanzzz 2012-02-27 23:37:20