Hello all,
Just recently got TweenLite/Max and am still new to it. So this may be an oversight on my part.
I am creating a movie clip and using it as a button. When the button is clicked it creates a box(movie clip), inside the box is a series of bars(each one a movie clip). The box is then tween down in a simple animation. If the button is clicked again, it raises the box. If the button is clicked again it lowers the box.
There is a check when the button is clicked to see if the box has already been created. If it has, then it skips that part and either raises or lowers it based on its current state.
The button creates fine, it will create the box and bars, and lower it all just fine. But when i click the button again, to raise the box, i get:
TypeError: Error #1009: Cannot access a property or method of a null object reference.
at com.greensock::TweenLite/render()
at com.greensock.core::SimpleTimeline/render()
at com.greensock.core::Animation$/_updateRoot()
It will continuously create this error as if it stuck in a loop. I ran the debugger and got:
Error: Cannot tween a null object. Duration: 1, data: undefined
at com.greensock::TweenLite()[C:\...\com\greensock\TweenLite.as:448]
at com.greensock::TweenLite$/to()[C:\...\com\greensock\TweenLite.as:910]
at TrainingModulev2_fla::MainTimeline/Index_Drop()[TrainingModulev2_fla.MainTimeline::frame1:146]
Frame1:146 is the 4th from last line in my code below.( TweenLite.to(IndexBox, 1, {delay:0, y:58}); )
My code:
function Index_Button()
{
var IndexButton:MC_IndexButton = new MC_IndexButton ;
addChild(IndexButton);
IndexButton.x = -50;
IndexButton.y = 110;
IndexButton.alpha = 0;
TweenLite.to(IndexButton, 1, {x:1, alpha:1});
IndexButton.addEventListener(MouseEvent.CLICK, Index_Drop);
}
function Index_Drop(e:MouseEvent)
{
if (IndexDown==true)
{
TweenLite.to(IndexBox, 1, {y:"-58"});
IndexDown = false;
}
else if (IndexCreated == false)
{
var IndexBox:MC_IndexBox = new MC_IndexBox ;
addChild(IndexBox);
IndexBox.x = 0;
IndexBox.y = -184.5;
var IndexBarArray:Array = [];
for (i=1; i<8; i++)
{
IndexBarArray[i] = new MC_IndexBar ;
IndexBarArray[i].name = "IndexBar" + i;
IndexBox.addChild(IndexBarArray[i]);
IndexBarArray[i].x = 14;
IndexBarArray[i].y = i * 27 + 72;
IndexBarArray[i].addEventListener(MouseEvent.MOUSE_OVER, IndexBar_Over);
IndexBarArray[i].addEventListener(MouseEvent.MOUSE_OUT, IndexBar_Out);
}
setChildIndex(IndexBox, 2);
IndexCreated = true;
TweenLite.to(IndexBox, 1, {delay:0, y:58});
}
else
{
TweenLite.to(IndexBox, 1, {delay:0, y:58});
IndexDown = true;
}
}
I cant figure out what im doin wrong. From what i am understanding, That line isnt ran until after IndexBox is created. I know its there, I've targeted it a few times in the code. I can see it when i run a test.
thanks