0
votes

I have 4 movieclips on frame 1 , clip 1, clip 2 , clip 3 , clip 4 ...

Only clip one's mouse enabled is set to true ...all else false ..

Now on frame 4 i have a movieclip game , inside movie clip i do some counting, when the counting reaches 10 , i set a boolean value test1 to true ...

Now when test1 value becomes true i want to set mouseenabled for clip 2 to be true,

When i try and access from frame1 using code game.test1 , i get null reference error ...

Cannot access a property or method of a null object reference.

How can i access the value of test1 , kindly guide ...

Thanks

Jin

2

2 Answers

0
votes

Game movieclip is on the 4th frame, and when you're trying to access it from the first frame, so of course you'll get a null reference error; it doesn't exist there. There are several solutions to this, and it's mostly about structure.

  1. Keep the whole game on one frame, in one movieclip. Write code outside of this movieclip.
  2. Use a static variable for counting.
  3. Use a singleton.
0
votes

Just so as to help every one , this is what i did ...

I declared a variable on frame 4 say var test1:Boolean=false; , then inside the movieclip , i gave it a value of boolean using the code -

                    MovieClip(root).test1=true;

Now i can access test1 from any where , hope this helps any one who wants to access variables from any frame ...

Regards