pollockd
07-02-2009, 02:22 AM
Hi, I am relatively new to actionscript 3.0. I am trying to tween a Movieclip which is a menu that has 3 simple buttons in it. Each simple button has a movieclip on the three states (so i can apply filters to them).
The project is a simple paper scissors rock game and the menu has the paper scissors rock buttons for the user.
When I have the tween code and Movieclip in the first frame of the movie they tween perfectly so I know the code is correct there.
BUT, When I move all that to frame 2 so that I can have an intro screen to the game and a button which does a simple gotoAndStop(2) to the game screen I get a "cannot access a property or method of a null object reference"
If I remove the button symbols from the Menu movieclip it will tween (even on frame 2) but add them in and it fails. Do I have to initialise the buttons somewhere????
Can anyone tell me what I'm doing wrong? I have been at this for hours.
Is it something to do with the nested MC or have I not initialised something?
Here is the code from the dummy test app I've been trying to work.
frame 1:
import fl.transitions.Tween;
import fl.transitions.easing.None;
stop();
thing.addEventListener(MouseEvent.CLICK,stuff);
function stuff(event:MouseEvent):void
{
gotoAndStop(15);
}
Frame 2
var boxTween:Tween = new Tween(box,"x",None.easeNone,400,50,1,true);
boxTween.start();
The project is a simple paper scissors rock game and the menu has the paper scissors rock buttons for the user.
When I have the tween code and Movieclip in the first frame of the movie they tween perfectly so I know the code is correct there.
BUT, When I move all that to frame 2 so that I can have an intro screen to the game and a button which does a simple gotoAndStop(2) to the game screen I get a "cannot access a property or method of a null object reference"
If I remove the button symbols from the Menu movieclip it will tween (even on frame 2) but add them in and it fails. Do I have to initialise the buttons somewhere????
Can anyone tell me what I'm doing wrong? I have been at this for hours.
Is it something to do with the nested MC or have I not initialised something?
Here is the code from the dummy test app I've been trying to work.
frame 1:
import fl.transitions.Tween;
import fl.transitions.easing.None;
stop();
thing.addEventListener(MouseEvent.CLICK,stuff);
function stuff(event:MouseEvent):void
{
gotoAndStop(15);
}
Frame 2
var boxTween:Tween = new Tween(box,"x",None.easeNone,400,50,1,true);
boxTween.start();