Below is a sample app and two AS classes that demonstrate this:
UtilityClassText.msml
<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.macromedia.com/2003/mxml"
xmlns="*">
<mx:Script><![CDATA[
import UtilityClassStatic
]]></mx:Script>
<UtilityClass id="u" />
<mx:Label text="{u.getFoo()}" />
<mx:Label text="{UtilityClassStatic.getBar()}" />
</mx:Application>
UtilityClass.as
// Example utility function class for dynamic instantiation
class UtilityClass
{
public function getFoo():String{
return "FOO";
}
}//UtilityClass
UtilityClassStatic.as
// Example utility function class for Static reference
class UtilityClassStatic
{
public static function getBar():String{
return "BAR";
}
}//UtilityClassStatic
-----Original Message-----
From: Tracy Spratt [mailto:[EMAIL PROTECTED]
Sent: Wednesday, March 30, 2005 2:27 PM
To: [email protected]
Subject: RE: [flexcoders] Re: Large Flex app architecture
" separate .as files and include them inline "
I recommend against this. If you get more than a couple thousand lines
you will hit the the 32k barrier.
Instead, create an AS class that contains the functionality script. Make
the functions static and import the class, or make them normally and
instantiate the class in mxml <MyUIFunctions id="ui" ...>
Reference the functions ui.myFunction.
I have never hit the 32k limit using this method.
Look into the Cairngorm architecture.
Tracy
-----Original Message-----
From: stevenkeys2003 [mailto:[EMAIL PROTECTED]
Sent: Wednesday, March 30, 2005 1:38 PM
To: [email protected]
Subject: [flexcoders] Re: Large Flex app architecture
Valy, the only suggestion I have is break things up into separate
components (mxml pages) as much as possible.
Here's some steps we've taken to help combat mem/load issues:
Eventually you're going to run into even the 32K limit on each file
like we did. Keep all your actionscript in separate .as files and
include them inline in your mxml (using <mx:Script source="my
path/myActionscript.as"/> to help avoid this. And rememeber to keep
code efficient, as every line adds up.
Separate out your remoteobject calls...
<mx:RemoteObject id="roFlexCompanyUser"
endpoint="http://dev.mfgquote.com/flashservices/gateway?a"
source="app.machii.model.FlexUser" showBusyCursor="true">
<mx:method name="getCompanyUserInfo"
result="roCompanyUserInfoHandler(event.result)"/>
</mx:RemoteObject>
<mx:RemoteObject id="roFlexUser"
endpoint="http://dev.mfgquote.com/flashservices/gateway?b"
source="app.machii.model.FlexUser" showBusyCursor="true">
<mx:method name="getUserInfo"
result="roUserInfoHandler(event.result)"/>
</mx:RemoteObject>
and remember to append the ?x to trick the gateway so as to not
bombard it but to attack it seperately.. there's an article about this
in detail online (if someone can provide url)
do as much preplanning as possible ... to break this "large app" up.
Ensure you're not trying to put too much into just 1 application.
Also from a backend perspective, don't send too much data down the
pipe either.. (ie. 10,000 rows vers 500) Perfect your backend code/sql
to send down only what is necessary for that given moment.
Look at your overall container load.. do you truly need viewstacks
everywhere? Mainly, keep nesting down to a minimum.. the more
containers you add, the larger the overall load.
keep breakin up the pieces mon, that's the key -- compartmentalize
your tools/apps/functions
good luck.
-Steve
--- In [email protected], Valy Sivec <[EMAIL PROTECTED]> wrote:
>
> I'm designing a quite large application and plann to use viewstack
container(s). Because each view will contain lots of panels and info
I'm affraid that the browser might hit his limit in regards with the
memory consumption and crash... seen couple of messages with the same
problem and I would like to avoid it...
>
> Actually I'm not even sure how the Flash Player garbage collector
works or if there is any .... I'm very new to this Flash/Flex
world.... so sorry if the question is dumb...
>
> Is it safe grouping the screens in multiple viewstacks and include
them from the jsp pages? or should be enough having only one viewstack
container for the whole application? Any suggestion?
>
> Valy
>
>
>
>
>
> ---------------------------------
> Do you Yahoo!?
> Make Yahoo! your home page
Yahoo! Groups Links
Yahoo! Groups Links
Yahoo! Groups Links
<*> To visit your group on the web, go to:
http://groups.yahoo.com/group/flexcoders/
<*> To unsubscribe from this group, send an email to:
[EMAIL PROTECTED]
<*> Your use of Yahoo! Groups is subject to:
http://docs.yahoo.com/info/terms/