开发者

Flex: How to Call a Custom Component's Public Function in the Main App?

开发者 https://www.devze.com 2023-01-18 19:20 出处:网络
How do I call a custom component\'s public function from the main app. For example, I\'ve got a timer component, MyTimer.

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 startTim开发者_如何学JAVAer() 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


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();
0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号