views:

24

answers:

1

Hi,

How do I call a custom component's public function from the main app. For example, I've got a timer component, MyTimer.

In the main app, I want to call startTimer() or stopTimer().

In the main app, I've got:

<visualcomponent:MyTimer />

In the component, I've got:

public function startTimer():void {
     baseTimer = getTimer();
     t.start();
     }

Any suggestions? Thank you.

-Laxmidi

+4  A: 

You need to set an ID for your component so that the instance can be referenced:

<visualcomponent:MyTimer id="myTimer" />

Now you can say in your main app's script code:

myTimer.startTimer();
Stefan
Hi thenduks, Sweet! Thank you for the help.
Laxmidi
Hi Stefan, Thank you for helping me, too.
Laxmidi