Hi, i am new to the forum.
I am creating a game in which a timer controlled movieclip (circle) appears on the stage for 60 seconds at a time and then removes itself, appearing again in another random possition on the stage. I also have a main character movieclip (mario) which i have created and in the code have specified if mario hits the circle, i wish for the circle to be removed, 1 point to be added to the score and then the circle added once again in a new random place on the stage.
I seem to be having difficulties with this as whenever i test my game i have a compiler error of: function value used where type void was expected. But when i play the game everything is working fine until the mario character hits the circle. This results in the circle disapearing, the score adding loads of numbers and the circle not reapearing again on the stage. however the timer is still active as the timer trace still appears in the flash output every 60 seconds.
can anyone help?!?
ActionScript Code:
import flash.utils.Timer;
import flash.events.TimerEvent;
var circle:coin = new coin();
coin.x=Math.random()*stage.stageWidth;
coin.y=Math.random()*stage.stageHeight;
addChild(coin);
var mytimer:Timer=new Timer(60000,1);
mytimer.addEventListener(TimerEvent.TIMER,myrandom);
mytimer.start();
function myrandom(evt:TimerEvent):void{
coin.x=Math.random()*stage.stageWidth;
coin.y=Math.random()*stage.stageHeight;
var mytrace = (Math.random() * 60000);
trace(mytrace);
var secondarytimer:Timer= new Timer(mytrace,1);
mytrace.addEventListener(TimerEvent.TIMER,myrandom);
secondarytimer.start();
var myscore=0;
addEventListener(Event.ENTER_FRAME,newscore);
function newscore(event:Event):void {
if(mario.hitTestObject(circle)) {
myscore+=1;
dynamicscore.text=myscore;
removeChild(circle);
}
}
addEventListener(Event.ENTER_FRAME,mycheck);
function mycheck(event:Event):void {
if (mario.stage) {
trace("working fine");
} else {
myrandom;
}
}