I generally pass a reference to the parent or to the Application scope
in my constructor, depending on what scope I'm interested in having
access to within my custome component (in this cass class instances).
The code generally looks like this:

// where the instance is constructed could be a sub class could be at
application level
var myInst = new myClass(this);

// the class definition
public class myClass{
  private var owner:Object;
  public function myClass(obj:Object){
    owner = obj;
  }
}

You can daisy chain this reference to instances used within this
class. You can also easily extend any class to incorporate this
method. The above code gives me access to all peer instances, and data
value that 'live' at the 'owner' level.

Good Luck

--- In flexcoders@yahoogroups.com, "Roger Gonzalez" <[EMAIL PROTECTED]> wrote:
>
> 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" 
> > <rgonzale@> 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