It depends.

Well, if you're in the main app, its just "this", obviously.  But if
you're in a child component, you should build the application to pass
down a handle to the application class instance; make a var on the
component of type Application, initialized from outside.

I meant to elaborate a bit more in my previous message.
Application.application is ok for small "toy" apps, but it doesn't work
well once your app scales.  In general, relative "paths" of the sort you
were building will lock you in to a very rigid structure that is hard to
change.

Try to figure out the minimal data that a particular control needs to
attach to, then pass a reference to just that piece.

Example:

Application a
  MyController c
    Button b
    Slider s
  MyDisplay d
    Label l
    Grid g
    
Bad: bind Application.application.d.l.text into b.  You're baking
knowledge of internals of MyDisplay outside, it will make things hard to
rewrite.  Using Application.application will also probably break if your
app is dynamically loaded by another app.

Better: make have a getLabel() call on MyDisplay, hand that label to
MyController.

More Betterer: Make MyDisplay implement an interface that has a
setDisplayText method, and have code in "a" hand an instance of the
display interface to c.

-rg


> -----Original Message-----
> From: flexcoders@yahoogroups.com 
> [mailto:[EMAIL PROTECTED] On Behalf Of ben.clinkinbeard
> Sent: Tuesday, April 18, 2006 12:16 PM
> To: flexcoders@yahoogroups.com
> Subject: [flexcoders] Re: Accessing and binding to (and from) 
> Application level vars
> 
> What is the proper way to access application-level vars and 
> methods then?
> 
> --- In flexcoders@yahoogroups.com, "Roger Gonzalez" 
> <[EMAIL PROTECTED]> wrote:
> >
> > > Hello, I have a couple of questions relating to Application level
> > > access and binding. First off, why can I not bind to a 
> property using
> > > this syntax even if the var is declared [Bindable]?:
> > > 
> > > dataProvider="{Application.application.arr_selectedPlans}"
> > > 
> > > I get the 'Data binding will not be able to detect assignments to
> > > "application"' warning.
> > 
> > I believe this is because its a static, and we don't handle those.
> > 
> > Note: Application.application should be avoided at all costs.
> > 
> > -rg
> >
> 
> 
> 
> 
> 
> 
> --
> Flexcoders Mailing List
> FAQ: http://groups.yahoo.com/group/flexcoders/files/flexcodersFAQ.txt
> Search Archives: 
> http://www.mail-archive.com/flexcoders%40yahoogroups.com 
> Yahoo! Groups Links
> 
> 
> 
>  
> 
> 
> 


--
Flexcoders Mailing List
FAQ: http://groups.yahoo.com/group/flexcoders/files/flexcodersFAQ.txt
Search Archives: http://www.mail-archive.com/flexcoders%40yahoogroups.com 
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/
 


Reply via email to