[COLOR=“Sienna”]Ok here are the things that are giving me problems. Whenever the player dies/wins a screen pops up with a button that takes you back to the menu where you can click play to play again… the thing is that every time you do this I get a bunch of null object errors! And these are the things that give me the problem: How do I silence them all together when you go back to the previous scene (once you win or you die…) :([/COLOR]
apple_mc.addEventListener(Event.ENTER_FRAME, circleHit1,false,0,true);
function circleHit1(event:Event): void {
if(apple_mc.hitTestObject(player_mc))
{
health.x=(health.x -10)
}
}
apple2_mc.addEventListener(Event.ENTER_FRAME, circleHit2,false,0,true);
function circleHit2(event:Event): void {
if(apple2_mc.hitTestObject(player_mc))
{
health.x=(health.x -10)
}
}
player_mc.addEventListener(Event.ENTER_FRAME, circleHit3,false,0,true);
function circleHit3(event:Event): void {
if(player_mc.hitTestObject(apple88))
{
health.x=(health.x -10)
}
}
player_mc.addEventListener(Event.ENTER_FRAME, circleHit4,false,0,true);
function circleHit4(event:Event): void {
if(player_mc.hitTestObject(Object(this).platform_mc.fire))
{
health.x=(health.x -5)
}
}
health.addEventListener(Event.ENTER_FRAME, circleHit5,false,0,true);
function circleHit5(event:Event): void {
if(health.hitTestObject(die))
{
lost.x=346.05
lost.y=269.75
SoundMixer.stopAll();
health.removeEventListener(Event.ENTER_FRAME,circleHit5);
}
}
player_mc.addEventListener(Event.ENTER_FRAME, circleHit6,false,0,true);
function circleHit6(event:Event): void {
if(player_mc.hitTestObject(mel_mc))
{
Object(root).mel_mc.gotoAndStop(2);
player_mc.removeEventListener(Event.ENTER_FRAME,circleHit6);
}
}
player_mc.addEventListener(Event.ENTER_FRAME,circleHit7 ,false,0,true);
function circleHit7(event:Event): void {
if(player_mc.hitTestObject(jelly1))
{
health.x=575.3
jelly1.y=1300
player_mc.removeEventListener(Event.ENTER_FRAME,circleHit7);
}
}
player_mc.addEventListener(Event.ENTER_FRAME, circleHit8,false,0,true);
function circleHit8(event:Event): void {
if(player_mc.hitTestObject(appleba))
{
health.x=575.3
appleba.y=1300
player_mc.removeEventListener(Event.ENTER_FRAME,circleHit8);
}
}
player_mc.addEventListener(Event.ENTER_FRAME, circleHit9,false,0,true);
function circleHit9(event:Event): void {
if(player_mc.hitTestObject(boy))
{
Object(this).boy.gotoAndStop(2);
player_mc.removeEventListener(Event.ENTER_FRAME,circleHit9);
}
}
player_mc.addEventListener(Event.ENTER_FRAME, circleHit10,false,0,true);
function circleHit10(event:Event): void {
if(player_mc.hitTestObject(Object(root).platform_mc.robot1))
{
health.x=(health.x -5)
}
}
player_mc.addEventListener(Event.ENTER_FRAME, circleHit11,false,0,true);
function circleHit11(event:Event): void {
if(player_mc.hitTestObject(Object(root).platform_mc.robot2))
{
health.x=(health.x -5)
}
}
player_mc.addEventListener(Event.ENTER_FRAME, circleHit12,false,0,true);
function circleHit12(event:Event): void {
if(player_mc.hitTestObject(Object(root).platform_mc.robot3))
{
health.x=(health.x -5)
}
}
player_mc.addEventListener(Event.ENTER_FRAME, circleHit13,false,0,true);
function circleHit13(event:Event): void {
if(player_mc.hitTestObject(Object(root).platform_mc.robot4))
{
health.x=(health.x -5)
}
}
player_mc.addEventListener(Event.ENTER_FRAME, circleHit14,false,0,true);
function circleHit14(event:Event): void {
if(player_mc.hitTestObject(Object(root).key))
{
opencage=true;
key.y=1300;
Object(root).platform_mc.moneybar.gotoAndStop(2);
player_mc.removeEventListener(Event.ENTER_FRAME,circleHit14);
}
}
player_mc.addEventListener(Event.ENTER_FRAME, circleHit15,false,0,true);
function circleHit15(event:Event): void {
if(player_mc.hitTestObject(Object(root).platform_mc.jack))
{
if(opencage)
{
;
won.x=346.05
won.y=269.75
Object(root).platform_mc.jack.gotoAndStop(2);
Object(root).sound.gotoAndStop(3);
SoundMixer.stopAll();
player_mc.removeEventListener(Event.ENTER_FRAME,circleHit15)
}
}
}
Object(root).ddhealth.dragonh.addEventListener(Event.ENTER_FRAME, circleHit16,false,0,true);
function circleHit16(event:Event): void {
if(Object(root).ddhealth.dragonh.hitTestObject(Object(root).ddhealth.dragond))
{
Object(root).platform_mc.dragon.y=1300;
Object(root).platform_mc.fire.y=1300;
Object(this).ddhealth.y=1300;
ddhealth.dragonh.removeEventListener(Event.ENTER_FRAME,circleHit16);
}
}
player_mc.addEventListener(Event.ENTER_FRAME, circleHit17,false,0,true );
function circleHit17(event:Event): void {
if(player_mc.hitTestObject(Object(root).deathfall))
{
lost.x=346.05
lost.y=269.75
SoundMixer.stopAll();
player_mc.removeEventListener(Event.ENTER_FRAME,circleHit17);
}
}
[COLOR=“Sienna”]This is also giving me problems it is an external AS file for my Coins:[/COLOR]
package
{
import flash.display.MovieClip
import flash.events.*;
public class coin extends MovieClip
{
var player_mc:MovieClip;
public static var coinsCollected:uint = 0;
var score:MovieClip;
public function coin()
{
// constructor code
this.addEventListener(Event.ENTER_FRAME,update);
}
function update (event:Event):void
{
player_mc=MovieClip(root).player_mc;
if(this.hitTestObject(player_mc))
{
coinsCollected += 1;
this.removeEventListener(Event.ENTER_FRAME,update);
MovieClip(parent).score.text = String(coinsCollected);
parent.removeChild(this);
}
}
}
}
:hangover: