There are a few ways.  Dirk mentioned one, there are 3 others I've read 
about.

One way is to create your MXML as pure tags & form elements with ID's. 
Then, you create your associated ActionScript that contains only logic (no 
creation of GUI stuff).  You link to this .as file via your <mx:Script> 
tag's source property.

The plus is your MXML has nothing but GUI components (doesn't have to, but 
usually).  The downside is, your AS must:
- use imports even though your MXML already imported them
- you must define the controls you are using as variables of your class even 
though your MXML already has them defined
- you have to write out the code as a class

Because of those first 2 reasons, I stopped doing it.  Yeah, sure, it's a 
better practice, but it's a duplication of efforts and I'm not wasiting time 
when I don't have to.

Cairngorm takes this a step further via a ViewHelper.  It kind of works like 
Dirk's example, except you can access it via a string name, and it has a 
reference to the view as a class property without the need to define all the 
stuff I mentioned.  You can get it via a ViewLocator which acts like a 
Singleton to hold all View's.


----- Original Message ----- 
From: "Brian Lesser" <[EMAIL PROTECTED]>
To: <[email protected]>
Sent: Thursday, February 02, 2006 7:48 AM
Subject: [flexcoders] Flex / OOP custom component coding question


Hi,
In Flash I can create a class that is associated with a Movie Clip in
the library. The clip can contain UI Components and acts as a "form"
within the application. To refer to the form elements within the clip I
just need to declare them in the class.  It seems cleaner than placing
functions on the clip's timeline. When I create a new form-like
component in Flex is there a way to do something similar without
including all the code in a script tag AND still get the benefit of
using MXML to provide all the subcomponents like TextInputs and Buttons?
Primarily, I want the class to play the role of Mediator within the
form. (Mediator pattern.)
My apologies if this is in the docs or I missed it looking back through
the mailing list posts.
Yours truly,
-Brian

-- 
______________________________________________________________________
Brian Lesser
Assistant Director, Teaching and Technology Support
Computing and Communications Services
Ryerson University
350 Victoria St.
Toronto, Ontario                   Phone: (416) 979-5000 ext. 6835
M5B 2K3                            Fax: (416) 979-5220
Office: AB48D                      E-mail: [EMAIL PROTECTED]
(Enter through LB66)               Web: http://www.ryerson.ca/~blesser
______________________________________________________________________



--
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