It's possible to declare package-level functions. For example:
 
MyApp.mxml
----------
 
<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml
<http://www.adobe.com/2006/mxml> ">
 
    <mx:Script>
    <![CDATA[

        private function clickHandler():void
        {
            doSomething();
        }
 
    ]]>
    </mx:Script>
 
    <mx:Button click="clickHandler()"/>
 
</mx:Application>
 
doSomething.as
--------------
 
package
{
 
public function doSomething():void
{
    trace("doSomething");
}
 
}

However, you can declare only one such public function per file so this
isn't typically done.
 
My advice is to re-orient yourself as to what constitutes a "normal
helper". Since Flex is strongly class-oriented, the best practice for
creating helper functions in Flex is to make them static methods of
helper classes. This is what we do in the mx.utils package of the
framework.
 
Gordon Smith
Adobe Flex SDK Team

________________________________

From: [email protected] [mailto:[EMAIL PROTECTED] On
Behalf Of Rafael Faria
Sent: Monday, November 26, 2007 3:22 PM
To: [email protected]
Subject: [flexcoders] Re: Helpers - Global function



But what if i wanted to create just normal helpers that will be seen
by any package/script/componenet/module 
?

how would i do it!?

--- In [email protected] <mailto:flexcoders%40yahoogroups.com>
, "Ralf Bokelberg"
<[EMAIL PROTECTED]> wrote:
>
> Typically you use a class with static methods for this.
> Cheers
> Ralf.
> 
> On Nov 26, 2007 6:56 AM, Rafael Faria <[EMAIL PROTECTED]> wrote:
> >
> >
> >
> >
> >
> >
> > There is any way to create helpers? like... functions that will be
> > seen on any component or class?
> >
> > how and where i declare this kind of function to be shown outside
the
> > scope i'm declaring?!
> >
> > 
> 
> 
> 
> -- 
> Ralf Bokelberg <[EMAIL PROTECTED]>
> Flex & Flash Consultant based in Cologne/Germany
> Phone +49 (0) 221 530 15 35
>



 

Reply via email to