Copy link to clipboard
Copied
I create a component and it has a method "reset" I want to use. I need to call this method from my default application using a button. So how should I do that?
I tried to create [Event(name="reset", type="flash.events.Event")] in default application, it seems it is used to call a method inside application when you are in a component; I need it the other way around. Thanks!
Copy link to clipboard
Copied
Hi,
You certainly can use events to do this however a direct way would be to give the component in the application and id name and assuming the function is accessible i.e. public you can call it directly in actionscript.
for example if you have the component on the stage with say id="myComponent" and that component has a public function called "myFunction" then in actionscript you could just do
myComponent.myFunction();
Perhaps not the most elegant way, but if you are just needing a simple and direct way that will certainly do it. The other way would indeed be to set up a custom event and dispatch it.
Hope this helps,
Regards,
Peter Witham.
Copy link to clipboard
Copied
Thanks! This component is a skin Class, it is like
<s:SparkSkin
xmlns:fx="http://ns.adobe.com/mxml/2009"
xmlns:s="
library://ns.adobe.com/flex/spark"
xmlns:mx="
library://ns.adobe.com/flex/mx"
>
Do you mean I need to put it inside my application? OR create an instance in my application and use the id of that instance to call it?
Copy link to clipboard
Copied
It is a MXML component, can I create an instance? It is not a class
Copy link to clipboard
Copied
Hi,
Declare the method as public and then create an object of the component and then you can access the method