Jump to content
Search Community

empty(true, true); don't seems to work

Harvid test
Moderator Tag

Recommended Posts

Hey

 

i dont think the queue1/queue2 is ben empty of its contents

what am i doing wrong

 

function completeHandler2OK():void 
{ 
 queue1.empty(true, true);
 var image2:ContentDisplay = LoaderMax.getContent("mainClip2");
 TweenLite.to(image2, 1.5 , {alpha:1, onComplete:image2.rawContent.play});
 switcher2 = 1;

}

 

g2 is loaded into queue1

 

TypeError: Error #1009: Cannot access a property or method of a null object reference.

at g2_fla::MainTimeline/fullScrHandler3()

at flash.display::Stage/set_displayState()

at flash.display::Stage/set displayState()

at g1_fla::MainTimeline/k9CLICK()

 

all code

import com.greensock.*;
import com.greensock.loading.*;
import com.greensock.events.LoaderEvent;
import com.greensock.loading.display.*;
import flash.display.StageDisplayState;


var ShowArray:Array = [g1, g2, g3, g4 ,g5, g6, g7, g8];
////////////////////////////////////////////////////////////
g1.addEventListener(MouseEvent.CLICK,Showclick)
g2.addEventListener(MouseEvent.CLICK,Showclick)
g3.addEventListener(MouseEvent.CLICK,Showclick)
g4.addEventListener(MouseEvent.CLICK,Showclick)
g5.addEventListener(MouseEvent.CLICK,Showclick)
g6.addEventListener(MouseEvent.CLICK,Showclick)
g7.addEventListener(MouseEvent.CLICK,Showclick)
g8.addEventListener(MouseEvent.CLICK,Showclick)
////////////////////////////////////////////////////////////
var switcher = 0; 
var switcher2 = 0;
var queue1:LoaderMax = new LoaderMax({name:"mainQueue1", onProgress:progressHandler1, onComplete:completeHandler1/*, onError:errorHandler*/});
var queue2:LoaderMax = new LoaderMax({name:"mainQueue2", onProgress:progressHandler2, onComplete:completeHandler2/*, onError:errorHandler*/});
TweenLite.to(preloadText, 0 , {alpha:0});
function Showclick(event:MouseEvent):void{
trace(event.target.name + " load");
  if (switcher == 0){ 
   queue1.empty(true, true);
   queue1.append( new SWFLoader("SWFS/SHOWCASES/"+event.target.name+".swf", {name:"mainClip1", alpha:0, container:this, y:86, autoPlay:false}));
   queue1.load();
switcher = 1;
trace("første")
   }
else
{
   queue2.empty(true, true);
queue2.append( new SWFLoader("SWFS/SHOWCASES/"+event.target.name+".swf", {name:"mainClip2", alpha:0, container:this, y:86, autoPlay:false}));
   queue2.load();
switcher = 0;
trace("anden")
}
}
////////////////loader queue 1//////////////////////////////////////////

function progressHandler1(event:LoaderEvent):void { 
preloadText.text = ("Loading " + Math.round(event.target.progress*100).toString() + "%");
TweenLite.to(preloadText, 1.0 , {alpha:1});
 if (switcher2 == 1){
   //clip exists 
var image2:ContentDisplay = LoaderMax.getContent("mainClip2");

TweenLite.to(image2, 1.5 , {alpha:0});
}
}
/*--------------------------------------------------------------*/
function completeHandler1(event:LoaderEvent):void 
{  
TweenLite.to(preloadText,  1.5 , {alpha:0});
   if (switcher2 == 1){
var image2:ContentDisplay = LoaderMax.getContent("mainClip2");
TweenLite.to(image2, 0.5 , {alpha:0, onComplete:completeHandler1OK})
   }
else
{ 
completeHandler1OK()
}} 

/*--------------------------------------------------------------*/
function completeHandler1OK():void 
{
 queue2.empty(true, true);
 var image1:ContentDisplay = LoaderMax.getContent("mainClip1");
 TweenLite.to(image1, 1.5 , {alpha:1, onComplete:image1.rawContent.play});

}


/////////////////loader queue 2//////////////////////////////////////////////
function progressHandler2(event:LoaderEvent):void { 
preloadText.text = ("Loading " + Math.round(event.target.progress*100).toString() + "%");
TweenLite.to(preloadText, 1.0 , {alpha:1});
var image1:ContentDisplay = LoaderMax.getContent("mainClip1");
TweenLite.to(image1, 1.5 , {alpha:0});
}
/*--------------------------------------------------------------*/
function completeHandler2(event:LoaderEvent):void 
{  
TweenLite.to(preloadText,  1.5 , {alpha:0});
var image1:ContentDisplay = LoaderMax.getContent("mainClip1");
TweenLite.to(image1, 0.5 , {alpha:0, onComplete:completeHandler2OK})

} 

/*--------------------------------------------------------------*/
function completeHandler2OK():void 
{ 
 queue1.empty(true, true);
 var image2:ContentDisplay = LoaderMax.getContent("mainClip2");
 TweenLite.to(image2, 1.5 , {alpha:1, onComplete:image2.rawContent.play});
 switcher2 = 1;

}
////////////////////////////////////////////////////////////

Link to comment
Share on other sites

Why do you think empty(true, true) isn't working? What is the evidence you're looking at?

 

The error you mentioned is being thrown in your fullScrHandler3() method which you didn't show here. I suspect you have a reference to the stage or something there but since the swf isn't added to the stage yet when that code runs, it throws null reference errors. Am I right?

 

If so, that has nothing to do with LoaderMax - just add conditional logic to your code so that it only runs if stage isn't null and if it is null, wait until after its ADDED_TO_STAGE event is dispatched.

Link to comment
Share on other sites

hey

 

why I believed empty detent works is

firste time i using the "fullScrHandler3()" all works

if loading a new .swf like (g1.swf) then its crash

if I have empty the previous loaded shut is be like first time every time

 

the code is the same in all loadet (g1 to g8)

 

function k9CLICK(event:MouseEvent):void
{
imageNumber = 9;
gotoAndStop(5);
stage.displayState = StageDisplayState.FULL_SCREEN;
}
function k9Over(event:MouseEvent):void {
TweenMax.to(k9, 0.7, {dropShadowFilter:{color:0xffffff, alpha:0.1, blurX:2, blurY:2, strength:100}});
   TweenMax.to(k9, 0.7,{colorMatrixFilter:{saturation:1}});
}
function k9Out(event:MouseEvent):void{
TweenMax.to(k9, 0.7, {dropShadowFilter:{color:0xffffff, alpha:0, blurX:0, blurY:0, strength:0}});
TweenMax.to(k9, 0.7,{colorMatrixFilter:{saturation:0.35}});
}

 

this.stage.addEventListener(Event.FULLSCREEN, fullScrHandler3);
function fullScrHandler3(event:FullScreenEvent):void {

      if (stage.displayState == StageDisplayState.NORMAL) {
	   queue1.empty(true, true);
	   queue2.empty(true, true);
	   gotoAndStop(4);
}}

sorry for all my stupid christians but im really new in coding

could you please show me what you mean because i don't understand what i must do

Link to comment
Share on other sites

its works now :D

this.stage.addEventListener(Event.FULLSCREEN, fullScrHandler3);
function fullScrHandler3(event:FullScreenEvent):void {

      if (stage.displayState == StageDisplayState.NORMAL) {
	   this.stage.removeEventListener(Event.FULLSCREEN, fullScrHandler3);
	   queuepp1.empty(true, true);
	   queuepp2.empty(true, true);
	   gotoAndStop(4);
}}

 

i detent understand the addEventListener wasn't remove what the .empty(true, true);

 

Thank you so mutch

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...