;

PDA

Click to See Complete Forum and Search --> : Timer function


maturn100
01-19-2009, 10:07 AM
Hi

I have created a timer event,
and I want its function onTimerp3 to call the function
'Rollp3part2' into action, but I dont know how to initiate it:

Any help will be a great help!
matt

function onTimerp3 ( e : TimerEvent ) : void {

Rollp3part2

}

function Rollp3part2 ( e : MouseEvent ) {

myTween = new Tween ( e.target, "x" , Back.easeIn, e.target.x, p3part2RollPoint.x , 1 , true );
myTween = new Tween ( e.target, 'y' , Back.easeOut, e.target.y, p3part2RollPoint.y , 1 , true );

}

neznein9
01-19-2009, 10:12 AM
Since the second function is a mouse handler it's expecting a mouse event - override that with a default value so you can call it regularly:

function Rollp3part2 ( e : MouseEvent = null ) {

maturn100
01-19-2009, 10:28 AM
brilliant
Is this a correct way to call the second function 'Rollp3part2' ?
It is giving me an error report


function onTimerp3 ( e : TimerEvent ) : void {

Rollp3part2

}

thanks for the help

neznein9
01-19-2009, 11:15 AM
function onTimerp3 (e:TimerEvent):void{
Rollp3part2();
}

maturn100
01-19-2009, 11:55 AM
hi neznein

thanks for the help so far!
however i am getting this message

'Cannot access a property or method of a null object reference'

Im having difficulty finding the problem
here is my code:

function onTimerp3 ( e : TimerEvent ) : void {

Rollp3part2();

}

function Rollp3part2 ( e : MouseEvent = null ) {


myTween = new Tween ( e.target, "x" , Back.easeIn, e.target.x, p3part2RollPoint.x , 1 , true );
myTween = new Tween ( e.target, 'y' , Back.easeOut, e.target.y, p3part2RollPoint.y , 1 , true );

}


cheers for helping

neznein9
01-19-2009, 12:00 PM
Oh whoops - your second function is using data from the mouse Event - so if you ignore that (eg. call that function from a timer) there is no mouse data for it to tween to.

You can either remove or rework those tweens or else you need to spoof a mouse event for whichever button you want to appear 'clicked' when that timer goes off...

maturn100
01-19-2009, 12:14 PM
Ah.. the tween that I want is to move an object to another position on the stage,, any suggestions how I could spoof a mouse event to do this?

neznein9
01-19-2009, 12:35 PM
If you already know the object you can do it like so:
function onTimerp3 (e:TimerEvent):void{
// Rollp3part2();
theObject.dispatchEvent(new MouseEvent(MouseEvent.CLICK));
}

maturn100
01-19-2009, 06:33 PM
Brilliant ! cheers neznein
that sorted out my problem
matt