
Here is my problem. I have two MovieClips in my library, which are virtually identical except in colour. Each has two MovieClips inside them, one a static graphic, the other having nine frames, each one with a number from 1-9 one it. These have the instance names of CoinNumber_mc and sCoinNumber_mc. These MovieClips are linked to the classes Coin and SpecialCoin respectively, and SpecialCoin extends Coin.
I then have a third class which creates a grid of Coins and replaces some of these with SpecialCoins.
Now heres my problem. In the constructors for the two coin classes they set a value proprety to a random number between 1-9 and goes to that frame in either CoinNumber_mc or sCoinNumber_mc. However when I run it I get this error:
TypeError: Error #1009: Cannot access a property or method of a null object reference.
at Coin$iinit()
at SpecialCoin$iinit()
at SphereBreak/::addSpecialCoins()
at SphereBreak/::setUpGrid()
at SphereBreak$iinit()
at spherebreak_fla::MainTimeline/spherebreak_fla::frame1()Now if I’m reading this stacktrace correctly, when the SpecialCoin constructor is being called, its calling it’s super constructor and when it tries to make CoinNumber go to the a frame and can’t find it, it throws an exception.
Here’s my constructors:
public function Coin() { delay = 0; pressed = false; value = Math.ceil(Math.random()*MAX_VALUE); this.CoinNumber_mc.gotoAndStop(value); }
public function SpecialCoin() { value = Math.ceil(Math.random()*MAX_VALUE); this.sCoinNumber_mc.gotoAndStop(value); pressed = false; }
I’m fairly sure I’m sure I’m right in whats happening because if I comment out
this.CoinNumber_mc.gotoAndStop(value);
it works, other than the fact that the Coins don’t initalise properly.
So I was wondering if anyone can confirm my suspicion/explain whats going on and/or how to fix it.
Many thanks.
If you would like to make a comment, please fill out the form below.
Recent Comments