This content has been marked as final. Show 5 replies
"chrun" <firstname.lastname@example.org> wrote in message
> I was wondering if anyone could give me a tip on how to do this...
> I am trying to seperate my code and MXML components a bit more. Currently
> I am
> lumping everything together in one awful MXML file. It's going just fine,
> have value objects storing values and seperate classes for functions and
> all of
> that lovely stuff going on...
> The problem is accessing the values of components. For instance, I have a
> canvas in my main app "myCanvas" containing a number of children.
> I would usually just do myCanvas.numChildren() to find out how many
> I would like to somehow do this with my external classes. I guess I would
> like to know the accepted method of sharing component properties
> throughout the
> classes I am using.
> Thanks a lot for any help whatsoever
If your classes are based on UIComponent, they will already have the
numChildren() function inbuilt. If they're data classes, write an interface
with the functions you expect to use and implement it on your classes. Then
you can cast your classes to IWhatever instead of the actual class, and Flex
will know you can do myIWhatever.numChildren(), regardless of the specific
Hey Amy thanks for answering. I am using a standard UIComponent (it's a canvas). I guess what I need to do is to be able to access it's properties application-wide. I have used a ValueObject singleton to do the same thing with variables and a singleton class to make functions available application-wide. (just learning this stuff). The problem is making the properties of the Canvas visible application-wide
So I have my main mxml document with this canvas "myCanvas".
I have another class with a load of functions. I would like to have a function in there which returns myCanvas.numChildren() but obviously myCanvas is not available to other classes at this point.
I am just not sure how to create the UIComponent and make it's properties known application-wide
Thanks again for your reply
You could use a MVC architecture to make it easier to access properties / methods application wide.
Or you could use custom events to pass data around, and ensure the desired data are properties of the event object.
Or you could use the Application.application property, or parentApplication, parentDocument.
"Greg Lafrance" <email@example.com> wrote in message
> You could use a MVC architecture to make it easier to access properties /
> methods application wide.
> Or you could use custom events to pass data around, and ensure the desired
> data are properties of the event object.
> Or you could use the Application.application property, or
Hi Greg and Amy. Thanks a lot for those replies - exactly what I was after, really useful stuff.