Iβm kind of jumping in headfirst into some Flex / AIR stuff. I have a pretty solid background with AS3, but considering Flexβs inherent hierarchical complexity (compared to regular Flash), I ran into a problem.
Suppose you have an application in which almost everything is related to events (general). Access to elements in the immediate vicinity of the purpose of the event or the purpose of the event itself is trivial. However, I am trying to find the most practical (readable: best, most effective) way to find children who are far from the current context.
I know there are functions like getChildAt() and getChildByName() , but this assumes a parent context; What if the element (Flex) you are looking for is a few parents, a sibling, and then a few children? We take for granted things like jQuery that make it easy, but obviously we don't have that luxury in AS3.
Are there any of the following statements? Is there a better way?
Iterate through the parents and parents of the parents until you find a breakpoint, find a sibling and repeat the game through the children and their children until you find your goal;
Store key objects in the global object storage (sic) and reference them as needed (yech)
Use a specific point notation to achieve the goal, including elements (for example, skins and their containers - again).
Any thoughts would be appreciated.
Edit:
To clarify, let's take the empty Flex 4 AIR application. Obviously, we have WindowedApplication as the root and add two SkinnableContainer children with the identifiers navContainer and mainContainer respectively. Both have custom skins. Inside mainContainer , we have another SkinnableContainer with vertical layout and mainContent ID, and as one of its child objects it has an object (anyone can do it - BorderContainer spark, possibly) with identifier animatedBox , for example. Inside navContainer we have a Button spark that has a listener rating for MouseEvent.CLICK . As part of this function, we will want to access the animatedBox ( nativeWindow.mainContainer.mainContent.animatedBox ) and animate it to change, say, its width.
The goal is to access this remote DisplayObject ( animatedBox ) in such a way that it is as unobtrusive and efficient as possible, although it meets Flex standards that I obviously did not already have. :)
source share