2012-02-27 98 views
-1

我已複製的對象在另一幀使用它的屬性或方法(該對象使用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需要他們

+0

您使用的MovieClip(this.parent)所有的地方還沒有這樣做沒有類中的代碼。那麼讓我問你,「this.parent」是指什麼? – 2012-02-27 23:33:56

+0

fullProjectPanel – aymanzzz 2012-02-27 23:36:30

+0

我怎樣才能使參考fullLessonPanel?! – aymanzzz 2012-02-27 23:37:20

回答

0

如果FrameLabelPlugin沒有激活,TweenLite的將充當雖然你試圖從字面上補間mc.frameLabel屬性(有沒有這樣的事情)。

激活插件需要一個單一的代碼行,你只需要一次做你的應用程序,所以它很容易。只需通過一個包含所有插件的名稱的數組,你想激活該TweenPlugin.activate()方法,像這樣:

import com.greensock.plugins.*; 
TweenPlugin.activate([FrameLabelPlugin, ColorTransformPlugin]); 
相關問題