I did it, and you know it works, I put an event listener for the timer.stop the code is like this:

stop();
import flash.utils.*;
import flash.display.*;



var timer:Timer = new Timer(100, 100);

timer.addEventListener("timer",timedFunction);
var newX:Number = stage.stageWidth;
var newY:Number = stage.stageHeight;

timer.start();
timer.addEventListener(TimerEvent.TIMER_COMPLETE, timerStop);
function timedFunction(e:TimerEvent):void{
var heart:MovieClip = new Heart();
heart.x = Math.random() * (stage.stageWidth);
heart.y = Math.random()* (stage.stageHeight);
heart.width=heart.width * Math.random();
heart.height=heart.height  * Math.random();
addChild(heart);

}
function timerStop(e:TimerEvent):void{
        timer.stop();
}

now I'm gonna look in google how to make the size of the heart more consistent...

now I'm going to be off-the air, going to church.

Cya friends


Gus


On Feb 4, 2010, at 5:40 PM, Jim Lafser wrote:

Add second param when instantiate Timer which indicates how many times it should repeat. If don't specify, then defaults to 0 which means run forever.
Add an event listener for the Timer.timerComplete event.
I think the listener you've already got should be registering for the Timer.timer event instead of "timer".


--- On Thu, 2/4/10, Gustavo Duenas <[email protected]> wrote:


From: Gustavo Duenas <[email protected]>
Subject: Re: [Flashcoders] making a repeating effect
To: "Flash Coders List" <[email protected]>
Date: Thursday, February 4, 2010, 4:14 PM


I've downloaded thanks
on other matters, when you say using a timer, you mean something like this ( I've have this from a tutorial, mixing with my idea);

something like this?

import flash.utils.*;

var timer:Timer = new Timer(5000);

timer.addEventListener("timer",TimedFunction);


timer.start();

function timedFuntion(e:TimerEvent):void{
var heart:MovieClip = new Heart();
heart.x = Math.random * stage.stageWidth;
heart.y = Math.random * stage.stageHeight;

}

the question is , how can I stop this?

Gus
On Feb 4, 2010, at 3:40 PM, Jer Brand wrote:

Completely un-helpful for your code, but you could also give HYPE a
whirl. Have been having a blast playing with it lately. I think the
above task is one of the examples.

http://hype.joshuadavis.com/
_______________________________________________
Flashcoders mailing list
[email protected]
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders


_______________________________________________
Flashcoders mailing list
[email protected]
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders




_______________________________________________
Flashcoders mailing list
[email protected]
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders


_______________________________________________
Flashcoders mailing list
[email protected]
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders

Reply via email to