Monster Racer Rush
Select between 5 monster racers, upgrade your monster skill and win the competition!
4.23 / 5.00 3,881 ViewsBuild and Base
Build most powerful forces, unleash hordes of monster and control your soldiers!
3.93 / 5.00 4,634 ViewsAny one know a way to delay multiple array objects from being added into my contsiner at the same time using as3?! I failed to use the timer to it, any idea ?
At 11/25/13 10:28 PM, A-Genius wrote: Any one know a way to delay multiple array objects from being added into my contsiner at the same time using as3?! I failed to use the timer to it, any idea ?
Add the item to the array in the TimerEvent.TIMER handler function.
Post your code, and point out where the problem is, using code comments //
At 11/26/13 11:38 AM, kkots wrote: Post your code, and point out where the problem is, using code comments //
I want my to execute the code inside my class but I think using setInterval(); was a bad idea
var i:Number =0;
var m1:Array = [new monster1()];
var MyTimer:Timer = new Timer(2000,8);
MyTimer.addEventListener(TimerEvent.TIMER,TimerFunction);
//the function increment and decrement the y and x in the path I have created it for it
function td():void{
m1[i].mapPattern();
}
function TimerFunction(e:TimerEvent):void{
for(i=0; i<m1.length; i++){
enemy_contain_mc.addChild(m1[i]);
//doesn't work
setInterval(td,1);
}
// doesn't work
}
MyTimer.start(); At 11/26/13 06:23 PM, A-Genius wrote:At 11/26/13 11:38 AM, kkots wrote: Post your code, and point out where the problem is, using code comments //I want my to execute the code inside my class but I think using setInterval(); was a bad idea
You don't need setInterval, you already wrote out everything you need. Just push() the new thing into the array inside the timer function. The timer function IS your interval-setter.
At 11/26/13 06:59 PM, MSGhero wrote:I want my to execute the code inside my class but I think using setInterval(); was a bad ideaYou don't need setInterval, you already wrote out everything you need. Just push() the new thing into the array inside the timer function. The timer function IS your interval-setter.
I have created this code but it works only for 2 objects
var i:Number =0;
var m1:Array = [new monster1(),new monster1()]
var addObj:Number = 21;
var MyTimer:Timer = new Timer(2000,1);
var MyTimer_2:Timer = new Timer(1,2000);
var MyTimer_3:Timer = new Timer (1,2000);
MyTimer.addEventListener(TimerEvent.TIMER,TimerFunction);
function Timer2Function(e:TimerEvent):void{
MyTimer_3.addEventListener(TimerEvent.TIMER,Timer3Function);
m1[i- m1.length + 1].mapPattern();
if(m1[i-m1.length + 1].x == 70){
MyTimer_3.start();
}
}
function Timer3Function(e:TimerEvent):void{
m1[i- m1.length].mapPattern();
}
function TimerFunction(e:TimerEvent):void{
MyTimer_2.addEventListener(TimerEvent.TIMER,Timer2Function);
for(i=0; i<m1.length; i++){
enemy_contain_mc.addChild(m1[i]);
}
MyTimer_2.start();
}
MyTimer.start(); At 11/26/13 07:41 PM, A-Genius wrote: I have created this code but it works only for 2 objects
I don't think you understand what a timer does. Every 2 seconds your timer function runs. You want to add a new monster every 2 seconds. So add a new monster inside your timer function. The array starts out empty since you want to add things to it every 2 seconds.
array = [];
timer = new Timer(2000, 8);
timer.addEventListener(TimerEvent.TIMER, timerFunction);
function timerFunction(e:TimerEvent):void {
array.push(new Monster());
} At 11/26/13 07:45 PM, MSGhero wrote: array = [];
timer = new Timer(2000, 8);
timer.addEventListener(TimerEvent.TIMER, timerFunction);
function timerFunction(e:TimerEvent):void {
array.push(new Monster());
}
OK now I understood the function better!