Jump to content
GreenSock

joakimhoegset

Cannot acess property [SOLVED]

Recommended Posts

Hi I am having problems with tweenMax. I am getting this in the output window.

 

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

at com.greensock::TweenLite/init()

at com.greensock::TweenMax/init()

at com.greensock::TweenMax/renderTime()

at com.greensock.core::SimpleTimeline/renderTime()

at com.greensock::TweenLite$/updateAll()

 

The code I am using is the following.

 

function loadStart(e:Event) {
//PRODUCTS
// No invisibility due to tween to the products comments 2,3,4
productsBack_mc.visible = 		false;
TweenMax.to(products_mc, 0, {x:749});

//GRENIFY
greenifyBack_mc.visible = 		false;
//Ten_mc contains comments_txt 10,11,12
ten_mc.visible = 				false;
comments_txt13.visible = 		false;
comments_txt14.visible = 		false;

//SYMBOLS
symbolsBack_mc.visible = 		false;
comments_txt5.visible = 		false;
comments_txt6.visible = 		false;
comments_txt7.visible = 		false;
comments_txt8.visible = 		false;
comments_txt9.visible = 		false;

//MORE 1
moreBack_mc.visible = 			false;
comments_txt15.visible = 		false;
comments_txt16.visible = 		false;
more2_btn.visible = 			false;

//MORE 2
comments_txt17.visible = 		false;
comments_txt18.visible = 		false;
more3_btn.visible = 			false;

//START
/*startBack_mc.visible = true;
comments_txt0.visible = true;
comments_txt1.visible = true;
classicMini_btn.visible = true;
ecoMini_btn.visible = true;
newMini_btn.visible = true;
ten_btn.visible = true;*/
TweenMax.to(startBack_mc.back, 0.5, {alpha:1});
TweenMax.to(startBack_mc.green, 0.5, {alpha:1, delay:0.5});
TweenMax.to(startBack_mc.left_mc, 0.5, {alpha:1, delay:1});
TweenMax.to(startBack_mc.middle_mc, 0.5, {alpha:1, delay:1.5});
TweenMax.to(startBack_mc.right_mc, 0.5, {alpha:1, delay:2});
TweenMax.to(comments_txt0, 0.5, {alpha:1, delay:2.5});
TweenMax.to(comments_txt1, 0.5, {alpha:1, delay:2.5});
TweenMax.to(classicMini_btn, 0.5, {alpha:1, delay:2.5});
TweenMax.to(ecoMini_btn, 0.5, {alpha:1, delay:2.5});
TweenMax.to(newMini_btn, 0.5, {alpha:1, delay:2.5});
TweenMax.to(ten_btn, 0.5, {alpha:1, delay:2.5});
}

 

What is wrong?

 

Thx,

Joakim

Link to comment
Share on other sites

One of the objects you're trying to tween is null. For example, if you did this...:

TweenMax.to(startBack_mc.back, 0.5, {alpha:1});

 

...and there was no "back" property/child of startBack_mc, that would be a null reference. It's not a problem with TweenMax. You could trace() each object before you tween it to see which one is null.

Link to comment
Share on other sites

Hi ok, I tried to change all the 0 to 0.1 but still it is not working. The difference when using visible and tweenmax is that I want use tweenmax to tween objects inside startBack_mc which is my preference.

I will post the whole code and send you the fla to you private if you want to have a look.

There are probably many ways of making this much easier maybe if statements but I am still kinda new and just want to get comfortable with one thing before throwing myself into the next. If you have any good pointers I would really love the input.

 

Thx,

 

Joakim

 

import com.greensock.*;

//Buttons for visibility

start_btn.addEventListener(MouseEvent.CLICK, loadStart);
classic_btn.addEventListener(MouseEvent.CLICK, loadClassic);
eco_btn.addEventListener(MouseEvent.CLICK, loadEco);
new_btn.addEventListener(MouseEvent.CLICK, loadNew);
symbols_btn.addEventListener(MouseEvent.CLICK, loadSymbols);
greenify_btn.addEventListener(MouseEvent.CLICK, loadGreenify);
more_btn.addEventListener(MouseEvent.CLICK, loadMoore1);
more2_btn.addEventListener(MouseEvent.CLICK, loadMoore2);
more3_btn.addEventListener(MouseEvent.CLICK, loadClassic);
classicMini_btn.addEventListener(MouseEvent.CLICK, loadClassic);
ecoMini_btn.addEventListener(MouseEvent.CLICK, loadEco);
newMini_btn.addEventListener(MouseEvent.CLICK, loadNew);
ten_btn.addEventListener(MouseEvent.CLICK, loadGreenify);
products_mc.symbolsMini_btn.addEventListener(MouseEvent.CLICK, loadSymbols);


more_btn.visible = 				false;
more2_btn.visible = 			false;
more3_btn.visible = 			false;


// No invisibility due to tween to the products comments 2,3,4
productsBack_mc.visible = 		false;

greenifyBack_mc.visible = 		false;
//Ten_mc contains comments_txt 10,11,12
ten_mc.visible = 				false;
comments_txt13.visible = 		false;
comments_txt14.visible = 		false;

symbolsBack_mc.visible = 		false;
comments_txt5.visible = 		false;
comments_txt6.visible = 		false;
comments_txt7.visible = 		false;
comments_txt8.visible = 		false;
comments_txt9.visible = 		false;

moreBack_mc.visible = 			false;
comments_txt15.visible = 		false;
comments_txt16.visible = 		false;
comments_txt17.visible = 		false;
comments_txt18.visible = 		false;

/*startBack_mc.visible = true;
comments_txt0.visible = true;
comments_txt1.visible = true;
classicMini_btn.visible = true;
ecoMini_btn.visible = true;
newMini_btn.visible = true;
ten_btn.visible = true;*/

TweenMax.to(startBack_mc.back, 0.5, {alpha:1});
TweenMax.to(startBack_mc.green, 0.5, {alpha:1, delay:0.5});
TweenMax.to(startBack_mc.left_mc, 0.5, {alpha:1, delay:1});
TweenMax.to(startBack_mc.middle_mc, 0.5, {alpha:1, delay:1.5});
TweenMax.to(startBack_mc.right_mc, 0.5, {alpha:1, delay:2});
TweenMax.to(comments_txt0, 0.5, {alpha:1, delay:2.5});
TweenMax.to(comments_txt1, 0.5, {alpha:1, delay:2.5});
TweenMax.to(classicMini_btn, 0.5, {alpha:1, delay:2.5});
TweenMax.to(ecoMini_btn, 0.5, {alpha:1, delay:2.5});
TweenMax.to(newMini_btn, 0.5, {alpha:1, delay:2.5});
TweenMax.to(ten_btn, 0.5, {alpha:1, delay:2.5});

function loadStart(e:Event) {
//PRODUCTS
// No invisibility due to tween to the products comments 2,3,4
productsBack_mc.visible = 		false;
TweenMax.to(products_mc, 0.1, {x:749});

//GRENIFY
greenifyBack_mc.visible = 		false;
//Ten_mc contains comments_txt 10,11,12
ten_mc.visible = 				false;
comments_txt13.visible = 		false;
comments_txt14.visible = 		false;

//SYMBOLS
symbolsBack_mc.visible = 		false;
comments_txt5.visible = 		false;
comments_txt6.visible = 		false;
comments_txt7.visible = 		false;
comments_txt8.visible = 		false;
comments_txt9.visible = 		false;

//MORE 1
moreBack_mc.visible = 			false;
comments_txt15.visible = 		false;
comments_txt16.visible = 		false;
more2_btn.visible = 			false;

//MORE 2
comments_txt17.visible = 		false;
comments_txt18.visible = 		false;
more3_btn.visible = 			false;

//START
/*startBack_mc.visible = true;
comments_txt0.visible = true;
comments_txt1.visible = true;
classicMini_btn.visible = true;
ecoMini_btn.visible = true;
newMini_btn.visible = true;
ten_btn.visible = true;*/
TweenMax.to(startBack_mc.back, 0.5, {alpha:1});
TweenMax.to(startBack_mc.green, 0.5, {alpha:1, delay:0.5});
TweenMax.to(startBack_mc.left_mc, 0.5, {alpha:1, delay:1});
TweenMax.to(startBack_mc.middle_mc, 0.5, {alpha:1, delay:1.5});
TweenMax.to(startBack_mc.right_mc, 0.5, {alpha:1, delay:2});
TweenMax.to(comments_txt0, 0.5, {alpha:1, delay:2.5});
TweenMax.to(comments_txt1, 0.5, {alpha:1, delay:2.5});
TweenMax.to(classicMini_btn, 0.5, {alpha:1, delay:2.5});
TweenMax.to(ecoMini_btn, 0.5, {alpha:1, delay:2.5});
TweenMax.to(newMini_btn, 0.5, {alpha:1, delay:2.5});
TweenMax.to(ten_btn, 0.5, {alpha:1, delay:2.5});
}

function loadClassic(e:Event) {
//PRODUCTS
// No invisibility due to tween to the products comments 2,3,4
productsBack_mc.visible = 		true;
TweenMax.to(products_mc, 1, {x:35});

//GRENIFY
greenifyBack_mc.visible = 		false;
//Ten_mc contains comments_txt 10,11,12
ten_mc.visible = 				false;
comments_txt13.visible = 		false;
comments_txt14.visible = 		false;

//SYMBOLS
symbolsBack_mc.visible = 		false;
comments_txt5.visible = 		false;
comments_txt6.visible = 		false;
comments_txt7.visible = 		false;
comments_txt8.visible = 		false;
comments_txt9.visible = 		false;

//MORE 1
moreBack_mc.visible = 			false;
comments_txt15.visible = 		false;
comments_txt16.visible = 		false;
more2_btn.visible = 			false;

//MORE 2
comments_txt17.visible = 		false;
comments_txt18.visible = 		false;
more3_btn.visible = 			false;

//START
startBack_mc.visible = 			false;
comments_txt0.visible = 		false;
comments_txt1.visible = 		false;
classicMini_btn.visible = 		false;
ecoMini_btn.visible = 			false;
newMini_btn.visible = 			false;
ten_btn.visible = 				false;
more_btn.visible = 				false;
}

function loadEco(e:Event) {
//PRODUCTS
// No invisibility due to tween to the products comments 2,3,4
productsBack_mc.visible = 		true;
TweenMax.to(products_mc, 1, {x:-764.5});

//GRENIFY
greenifyBack_mc.visible = 		false;
//Ten_mc contains comments_txt 10,11,12
ten_mc.visible = 				false;
comments_txt13.visible = 		false;
comments_txt14.visible = 		false;

//SYMBOLS
symbolsBack_mc.visible = 		false;
comments_txt5.visible = 		false;
comments_txt6.visible = 		false;
comments_txt7.visible = 		false;
comments_txt8.visible = 		false;
comments_txt9.visible = 		false;

//MORE 1
moreBack_mc.visible = 			false;
comments_txt15.visible = 		false;
comments_txt16.visible = 		false;
more2_btn.visible = 			false;

//MORE 2
comments_txt17.visible = 		false;
comments_txt18.visible = 		false;
more3_btn.visible = 			false;

//START
startBack_mc.visible = 			false;
comments_txt0.visible = 		false;
comments_txt1.visible = 		false;
classicMini_btn.visible = 		false;
ecoMini_btn.visible = 			false;
newMini_btn.visible = 			false;
ten_btn.visible = 				false;
more_btn.visible = 				false;
}

function loadNew(e:Event) {
//PRODUCTS
// No invisibility due to tween to the products comments 2,3,4
productsBack_mc.visible = 		true;
TweenMax.to(products_mc, 1, {x:-1526});

//GRENIFY
greenifyBack_mc.visible = 		false;
//Ten_mc contains comments_txt 10,11,12
ten_mc.visible = 				false;
comments_txt13.visible = 		false;
comments_txt14.visible = 		false;

//SYMBOLS
symbolsBack_mc.visible = 		false;
comments_txt5.visible = 		false;
comments_txt6.visible = 		false;
comments_txt7.visible = 		false;
comments_txt8.visible = 		false;
comments_txt9.visible = 		false;

//MORE 1
moreBack_mc.visible = 			false;
comments_txt15.visible = 		false;
comments_txt16.visible = 		false;
more2_btn.visible = 			false;

//MORE 2
comments_txt17.visible = 		false;
comments_txt18.visible = 		false;
more3_btn.visible = 			false;

//START
startBack_mc.visible = 			false;
comments_txt0.visible = 		false;
comments_txt1.visible = 		false;
classicMini_btn.visible = 		false;
ecoMini_btn.visible = 			false;
newMini_btn.visible = 			false;
ten_btn.visible = 				false;
more_btn.visible = 				false;
}

function loadSymbols(e:Event) {
//PRODUCTS
// No invisibility due to tween to the products comments 2,3,4
productsBack_mc.visible = 		false;
TweenMax.to(products_mc, 0.1, {x:749});

//GRENIFY
greenifyBack_mc.visible = 		false;
//Ten_mc contains comments_txt 10,11,12
ten_mc.visible = 				false;
comments_txt13.visible = 		false;
comments_txt14.visible = 		false;

//SYMBOLS
symbolsBack_mc.visible = 		true;
comments_txt5.visible = 		true;
comments_txt6.visible = 		true;
comments_txt7.visible = 		true;
comments_txt8.visible = 		true;
comments_txt9.visible = 		true;

//MORE 1
moreBack_mc.visible = 			false;
comments_txt15.visible = 		false;
comments_txt16.visible = 		false;
more2_btn.visible = 			false;

//MORE 2
comments_txt17.visible = 		false;
comments_txt18.visible = 		false;
more3_btn.visible = 			false;

//START
startBack_mc.visible = 			false;
comments_txt0.visible = 		false;
comments_txt1.visible = 		false;
classicMini_btn.visible = 		false;
ecoMini_btn.visible = 			false;
newMini_btn.visible = 			false;
ten_btn.visible = 				false;
more_btn.visible = 				false;
}

function loadGreenify(e:Event) {
//PRODUCTS
// No invisibility due to tween to the products comments 2,3,4
productsBack_mc.visible = 		false;
TweenMax.to(products_mc, 0.1, {x:749});

//GRENIFY
greenifyBack_mc.visible = 		true;
//Ten_mc contains comments_txt 10,11,12
ten_mc.visible = 				true;
comments_txt13.visible = 		true;
comments_txt14.visible = 		true;

//SYMBOLS
symbolsBack_mc.visible = 		false;
comments_txt5.visible = 		false;
comments_txt6.visible = 		false;
comments_txt7.visible = 		false;
comments_txt8.visible = 		false;
comments_txt9.visible = 		false;

//MORE 1
moreBack_mc.visible = 			false;
comments_txt15.visible = 		false;
comments_txt16.visible = 		false;
more2_btn.visible = 			false;

//MORE 2
comments_txt17.visible = 		false;
comments_txt18.visible = 		false;
more3_btn.visible = 			false;

//START
startBack_mc.visible = 			false;
comments_txt0.visible = 		false;
comments_txt1.visible = 		false;
classicMini_btn.visible = 		false;
ecoMini_btn.visible = 			false;
newMini_btn.visible = 			false;
ten_btn.visible = 				false;
more_btn.visible = 				false;
}

function loadMoore1(e:Event) {
//PRODUCTS
// No invisibility due to tween to the products comments 2,3,4
productsBack_mc.visible = 		false;
TweenMax.to(products_mc, 0.1, {x:749});

//GRENIFY
greenifyBack_mc.visible = 		false;
//Ten_mc contains comments_txt 10,11,12
ten_mc.visible = 				false;
comments_txt13.visible = 		false;
comments_txt14.visible = 		false;

//SYMBOLS
symbolsBack_mc.visible = 		false;
comments_txt5.visible = 		false;
comments_txt6.visible = 		false;
comments_txt7.visible = 		false;
comments_txt8.visible = 		false;
comments_txt9.visible = 		false;

//MORE 1
moreBack_mc.visible = 			true;
comments_txt15.visible = 		true;
comments_txt16.visible = 		true;
more2_btn.visible = 			true;

//MORE 2
comments_txt17.visible = 		false;
comments_txt18.visible = 		false;
more3_btn.visible = 			false;

//START
startBack_mc.visible = 			false;
comments_txt0.visible = 		false;
comments_txt1.visible = 		false;
classicMini_btn.visible = 		false;
ecoMini_btn.visible = 			false;
newMini_btn.visible = 			false;
ten_btn.visible = 				false;
more_btn.visible = 				false;
}

function loadMoore2(e:Event) {
//PRODUCTS
// No invisibility due to tween to the products comments 2,3,4
productsBack_mc.visible = 		false;
TweenMax.to(products_mc, 0.1, {x:749});

//GRENIFY
greenifyBack_mc.visible = 		false;
//Ten_mc contains comments_txt 10,11,12
ten_mc.visible = 				false;
comments_txt13.visible = 		false;
comments_txt14.visible = 		false;

//SYMBOLS
symbolsBack_mc.visible = 		false;
comments_txt5.visible = 		false;
comments_txt6.visible = 		false;
comments_txt7.visible = 		false;
comments_txt8.visible = 		false;
comments_txt9.visible = 		false;

//MORE 1
moreBack_mc.visible = 			false;
comments_txt15.visible = 		false;
comments_txt16.visible = 		false;
more2_btn.visible = 			false;

//MORE 2
comments_txt17.visible = 		true;
comments_txt18.visible = 		true;
more3_btn.visible = 			true;

//START
startBack_mc.visible = 			false;
comments_txt0.visible = 		false;
comments_txt1.visible = 		false;
classicMini_btn.visible = 		false;
ecoMini_btn.visible = 			false;
newMini_btn.visible = 			false;
ten_btn.visible = 				false;
more_btn.visible = 				false;
}



/*//Create the loader, set dataFormat to text 
//and listen when data is loaded
var loader:URLLoader = new URLLoader()
loader.dataFormat = URLLoaderDataFormat.TEXT
loader.addEventListener(Event.COMPLETE, onLoadXML)
loader.load(new URLRequest("rapid.xml"))
function onLoadXML(ev:Event){
  try{
	//Convert the downloaded text into an XML
	var myXML:XML = new XML(ev.target.data)
	var list:XMLList = myXML..title
	//walks the list and show in textfields
	for(var i=0; i			this["Comments_txt"+i].text = list[i].comments	
	}
} catch (e:TypeError){
	//Could not convert the data, probavlu because
	//because is not formated correctly
	trace("Could not parse the XML")
	trace(e.message)
}
}
stop()*/

Link to comment
Share on other sites

Hi ok, I tried to change all the 0 to 0.1 but still it is not working.

 

Did you read my last post? It has nothing to do with changing 0 to 0.1. I said one (or more) of the objects you're tweening must be null - that has nothing to do with TweenMax. Please make sure your objects are all valid before tweening them.

Link to comment
Share on other sites

Ok thanks I found the problem. Never tried tracing b4. Great tip. Im a bit of a tool sometimes.

 

Thx,

Joakim

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.
×