Reputation: 11
Can someone tell me why I get this error?
ReferenceError: Error #1069: Property roll_mc not found on com.usmanzubairi.theAges.TheAges and there is no default value. at com.usmanzubairi.theAges::PirGame/rolling()
package com.usmanzubairi.theAges
{
import flash.display.MovieClip;
import flash.events.*;
import flash.media.*;
public class TheAges extends MovieClip
{
private var game:PirGame;
private var game2:PreGame;
private var game3:SupGame;
public function TheAges()
{
stage.addEventListener(MouseEvent.CLICK, startGame);
}
private function startGame(event:Event):void
{
if (event.target != player_btn)
{
removeEventListener(MouseEvent.CLICK, startGame);
game = new PirGame();
addChild(game);
}
else
{
addChild(player_mc);
player_mc.visible = true;
player_mc.play();
}
if (event.target == player_mc.tom_mc)
{
removeEventListener(MouseEvent.CLICK, startGame);
game2 = new PreGame();
addChild(game2);
}
if (event.target == player_mc.pete_mc)
{
removeEventListener(MouseEvent.CLICK, startGame);
game = new PirGame();
addChild(game);
}
if(event.target == player_mc.sam_mc)
{
removeEventListener(MouseEvent.CLICK, startGame);
game3 = new SupGame();
addChild(game3);
}
}
public function gameOver():void
{
removeChild(game);
game = null;
stage.addEventListener(MouseEvent.CLICK, startGame);
}
}
}
Here's the PirGame document class code:
package com.usmanzubairi.theAges
{
import flash.utils.Timer;
import flash.events.*;
import flash.display.*;
import flash.geom.Matrix;
import flash.net.SharedObject;
public class PirGame extends MovieClip
{
public function PirGame()
{
addEventListener(MouseEvent.CLICK,rolling);
}
private function rolling (event:Event):void
{
if (event.target == MovieClip(root).roll_mc)
{
addChild(roll)
roll.visible = true;
runner_mc.visible = false;
roll.play();
}
}
}
}
Thanks.
Upvotes: 1
Views: 9307
Reputation: 946
If your roll_mc is in your PirGame symbol, and i think Pirgame class is well associated with the symbol, try modify your PirGame class a s follow:
package com.usmanzubairi.theAges
{
import flash.utils.Timer;
import flash.events.*;
import flash.display.*;
import flash.geom.Matrix;
import flash.net.SharedObject;
public class PirGame extends MovieClip
{
public function PirGame()
{
addEventListener(MouseEvent.CLICK,rolling);
}
private function rolling (event:Event):void
{
trace( event.target, roll_mc );
// change MovieClip(root).roll_mc to this.roll_mc as roll_mc is on this symbol and not on the root.
if( event.target == this.roll_mc )
{
trace( 'roll_mc clicked' );
addChild( roll )
roll.visible = true;
runner_mc.visible = false;
roll.play();
}
}
}
}
if you just want the roll_mc be clickable try the following:
package com.usmanzubairi.theAges
{
import flash.utils.Timer;
import flash.events.*;
import flash.display.*;
import flash.geom.Matrix;
import flash.net.SharedObject;
public class PirGame extends MovieClip
{
public function PirGame()
{
if( roll_mc ) roll_mc.addEventListener( MouseEvent.CLICK, rolling );
else addEventListener( Event.ADDED_TO_STAGE, _onStage );
}
private function _onStage( e:Event ):void
{
removeEventListener( Event.ADDED_TO_STAGE, _onStage );
roll_mc.addEventListener( MouseEvent.CLICK, rolling );
}
private function rolling( e:Event ):void
{
trace( 'roll_mc clicked' );
addChild( roll )
roll.visible = true;
runner_mc.visible = false;
roll.play();
}
}
}
if you don't have to re display the runner_mc you can remove it from the display list instead of make it not visible:
removeChild( runner_mc );
Upvotes: 2