Events are the preferred solution, but from anywhere in an app,
including swfs loaded using SWFLoader, you can access any public member
in the main application scope doing:

Import mx.core.Application;

Then:

var myVar:String = Application.application.publicStringVarInMainApp;
//works for public functions and components too.

 

I typically create a var, _app:Application, to shorten the code.  If you
type _app to the exact class (file name) of the main app, you will get
the benefits of code hinting in FB.

 

Tracy

 

 

________________________________

From: [email protected] [mailto:[EMAIL PROTECTED] On
Behalf Of Paul Andrews
Sent: Friday, February 22, 2008 1:50 PM
To: [email protected]
Subject: Re: [flexcoders] as3 global variables - no more

 

----- Original Message ----- 
From: "dsds99" <[EMAIL PROTECTED] <mailto:dsds99%40yahoo.com> >
To: <[email protected] <mailto:flexcoders%40yahoogroups.com> >
Sent: Friday, February 22, 2008 6:41 PM
Subject: [flexcoders] as3 global variables - no more

> Yes, using global variables was easy solution to referencing
> movieclips from anywhere.
>
> I'm trying to link up my play button to play the selected track in a
> listbox. The two components are in separate classes.
>
> one solution is that in my main class I pass a reference of the
> listbox to my playbutton.
>
> Are there alternative solutions to this...Better OOP practice.

I thin k you either have a class missing, or the wrong push button
class.

The button gets pressed and should fire off an event. In your
application 
there needs to be a class that responds to the pushbutton. That class is

also aware of the list, so it can know the button is pressed then access
the 
current item on the list and activate the playing.

A method of this application class can be called by the buttons click 
handler..

Paul 

 

Reply via email to