I have a custom component Comp
that gets its position changed as a result of interactions with other components, etc. I check for changes in its position by constantly checking its position at fixed intervals. I'm looking for a better solution (maybe an event-based solution) to monitor its position so I don't have to check constantly myself.
The 2 possibilities are
the component itself is self-aware of its position on stage and reports to the main application (via an event) when it knows that its position changed. Is that possible? Are components self-aware of their position or changes to their position? and what event could I piggyback on when that happens?
the other option is that the main application can monitor the position of the component and takes action when that position changes. Is that possible? Can the main application detect changes in the position of its components, and again what event could possibly be used here?
If not, how could I detect when that component changes position without having to constantly check for it myself.
<?xml version="1.0" encoding="utf-8"?>
<s:Application xmlns:fx="http://ns.adobe.com/mxml/2009"
xmlns:s="library://ns.adobe.com/flex/spark"
xmlns:mx="library://ns.adobe.com/flex/mx"
xmlns:local="*">
<local:Comp id="comp" x="100" y="100" />
</s:Application>