mardi 23 février 2016

AS3 How to call a button from another class?

I'm trying to create a button that when you click on it, the ship fires a laser, but the button isn't working. I mean I didn't get any error when debugging, however it won't allow me to click on the button, but instead it allows me to click on my ship to fire. Any help is greatly appreciated, thanks!

Part of my button.as

package {

import flash.events.Event;
import flash.display.Stage;
import flash.display.MovieClip;
import flash.events.MouseEvent;

import objects.Ship;

public class Fire extends MovieClip {

    public function Fire {

    addEventListener(MouseEvent.MOUSE_DOWN, shipfire);

    private function shipfire(event:MouseEvent):void
    {
        Ship.addEventListener(MouseEvent.MOUSE_DOWN, init)
    }

    }
}

}

part of my ship.as

package {

import flash.display.MovieClip;
import flash.display.Stage; 
import flash.ui.Mouse;
import flash.events.MouseEvent;
import flash.events.Event;

import control.Fire;    

public class Ship extends MovieClip
{

    private var stageRef:Stage;

    public function shipfire(e:Event) : void
    {   
        fireLaser();
    }
}

}

Aucun commentaire:

Enregistrer un commentaire