Hii
I’m making a shootergame but I’m stuck. I have a crossbow in a separate as file but I need to call it from my main file. But i just don’t know how to do that… can anybody help me?
this is the code of the main:
package
{
import flash.display.;
import flash.text.TextField;
import flash.utils.Timer;
import flash.events.;
public class main extends MovieClip
{
private var aantal_rozen:uint = 2;
private var gameLevel:uint = 0;
private var score:uint = 0;
private var roosSnelheid:uint = 2;
public function main()
{
stop();
}
public function scoreVerhogen():void
{
score++;
score_txt.text = score.toString();
}
private function initLevel():void
{
gameLevel++;
//aantal_rozen++;
var timer:Timer = new Timer(2000, 1);
timer.addEventListener(TimerEvent.TIMER, gaNaarGame);
timer.start();
level_txt.text = gameLevel.toString();
stop();
}
private function gaNaarLevel():void
{
gotoAndStop("level");
}
private function gaNaarGame(evt:TimerEvent):void
{
gotoAndStop("game");
}
private function gaNaarGameOver():void
{
gotoAndStop("gameOver");
}
private function initGame():void
{
for(var i:uint = 1; i<=aantal_rozen; i++)
{
var Roos:MovieClip = new mc_roos(gameLevel);
Roos.name = "mc_roos" + i;
addChild(Roos);
}
stage.addEventListener(Event.ENTER_FRAME, controle);
score_txt.text = score.toString();
}
private function initGameOver():void
{
stop();
score_txt.text = score.toString();
}
public function controle(evt:Event):void
{
if (score >= gameLevel*15)
{
verwijder_rozen();
gaNaarLevel();
}
}
public function verwijder_rozen():void
{
for(var i:uint=0; i<aantal_rozen; i++)
{
if(!(getChildByName("roos"+i) == null))
{
mc_roos(getChildByName("roos"+ i)).destroy();
}
}
}
}
}
And this is the code of my crossbow:
package
{
import flash.display.;
import flash.events.;
import flash.utils.*;
public class mc_boog extends MovieClip
{
private var links:Boolean=false;
private var rechts:Boolean=false;
private var speed:uint=15;
private var tijd:int=0;
private var limiet:int=12;
private var schietenAllow:Boolean=true;
public function mc_boog():void
{
this.addEventListener(Event.ENTER_FRAME, beweging);
this.addEventListener(KeyboardEvent.KEY_DOWN, controlDown);
this.addEventListener(KeyboardEvent.KEY_UP, controlUp);
}
public function beweging(evt:Event):void
{
if(links)
{
this.x-=speed;
}
if(rechts)
{
this.x+=speed;
}
if(this.x<45)
{
this.x = this.x+=speed;
}
if(this.x>655)
{
this.x = this.x-=speed;
}
if(tijd<limiet)
{
tijd++;
}
else
{
schietenAllow=true;
tijd=0;
}
}
private function controlDown(evt:KeyboardEvent):void
{
// booleans true als de toets ingedrukt is
if(evt.keyCode == 37 || evt.keyCode == 65)
{
links = true;
}
if(evt.keyCode == 39 || evt.keyCode == 68)
{
rechts = true;
}
}
private function controlUp(evt:KeyboardEvent):void
{
if(evt.keyCode == 37 || evt.keyCode == 65)
{
links = false;
}
if(evt.keyCode == 39 || evt.keyCode == 68)
{
rechts = false;
}
}
}
}
Thanks!