This is a good solution -- I was going to suggest that in the
handleMouseRollOver function you can check currentTarget to see if
it's an instance of UITextField, Label or whatever, thus waiting until
the event has bubbled to the grandparent. But that requires hardcoding
the types into an if(..) statement, not ideal. In fact, hardly
different from the event.target.parent.parent code you had originally.

Yours sounds like the way to go.

On Wed, Nov 26, 2008 at 14:37, devenhariyani <[EMAIL PROTECTED]> wrote:
> Wow..you all have been very helpful! Thank you so much for your
> support. In the end I did not use the mouseChildren property, because
> I needed the child components to receive mouseover and mouseOut events.
>
> But, I did create a framework that fixed all of my event troubles, and
> below are some of the things I did. I hope it helps someone in the future:
>
> 1. I created a new custom Event class called MyCustomEvent. I then
> have the base compoenent listen specifically for this custom event,
> and whenever any of the children components receive a mouseover or
> mouseout event they dispatch a new MyCustomEvent which the parent
> class receives and is able to perform special effects such as stopping
> the move effect, zooming, etc. When creating the MyCustomEvent, the
> key was that I needed bubble set to "true" so that the event bubbles.
> The code is:
>
> public class MyEvent extends Event
> {
> public static const FREEZE:String = "matrixFreeze";
> public static const RESUME:String = "matrixResume";
>
> public function MyEvent(type:String, bubbles:Boolean=true,
> cancelable:Boolean=false)
> {
> super(type, bubbles, cancelable);
> }
>
> }
>
> 2. Whenever I am listening for events, I make sure that I am using
> currentTarget as opposed to target. before I was using target
> property to access activeEffects on the parent object, and this was
> giving me exceptions. That is because in my situation, target was the
> UITextField and the currentTarget was in fact the MyCustomMXML obj I
> was trying to access.
>
> HTH someone out,
> Deven
>
> --- In flexcoders@yahoogroups.com, "devenhariyani" <[EMAIL PROTECTED]>
> wrote:
>>
>> I apologize if the context of my question is not fully clear, and I
>> greatly appreciate you taking the time to respond. However, your
>> assumption is not correct.
>>
>> The way the applciation is working so that there is actually 30, 40 or
>> even more instances of the custom MXML components rendered on the
>> canvas at any given point. this is all determined at runtime, and
>> each instance of MyCustomMXMLComponent is moving across the canvas
>> with its very own instance of a Move Effect.
>>
>> To clarify the question:
>> My custom mxml component is called: MyCustomMXMLComponent.mxml it has
>> a Label and a Text Area inside of it. When a user does a mouse
>> rollover on the Label I want the MyCustomMXMLComponent to stop moving
>> and other actions to happen.
>>
>> I am unable to catch events inside of the MyCustomMXMLComponent.mxml
>> object, the code i use is:
>>
>> var instance:MyCustomMXMLComponent = new MyCustomMXMLComponent();
>> instance.addEventListner(MouseEvent.ROLL_OVER, handleMouseRollOver);
>>
>>
>> The problem is that when a user moves a mouse over the
>> MyCustomMXMLComponent a UITextField catches the event so when i have
>> the below code in the event handler it fails:
>>
>> //find the MoveInstance and pause
>> for(var i:int = 0; i < event.target.activeEffects.length; i++) {
>> if(event.target.activeEffects[i].className == 'MoveInstance')
>> event.target.activeEffects[i].pause();
>> }
>>
>> Why is the UITextField which is inside of the Label catchign the event
>> when I did not register an eventhandler for it to do anything??
>>
>> Is there a better way to catch the event so that the
>> MyCustomMXMLComponent can handle the event to stop the Move Effect???
>>
>> Thank you.
>>
>>
>>
>> --- In flexcoders@yahoogroups.com, Chet Haase <chaase@> wrote:
>> >
>> >
>> > I'm not sure I understand the whole context, but if I'm right that
>> there's just one of these custom components per app, and therefore one
>> Move effect running on it at any given time, isn't it easier to just
>> cache an instance to the effect itself and pause() it directly when
>> you get the rollover event?
>> >
>> > Chet.
>> >
>> >
>> >
>> > From: flexcoders@yahoogroups.com [mailto:[EMAIL PROTECTED]
>> On Behalf Of devenhariyani
>> > Sent: Friday, November 21, 2008 1:01 PM
>> > To: flexcoders@yahoogroups.com
>> > Subject: [flexcoders] Re: Architecture question using Move Effect
>> and Events
>> >
>> >
>> > below is the code that i am using. maybe this will help you see
>> what i'm trying to do, and help how i should be properly stopping the
>> Move Effect for UI components which are dynamically created at
>> runtime. Thanks!
>> >
>> > public function initApp:void() {
>> >
>> > //for each element in an ArrayCollection which was retrieved from a
>> HTTPService
>> >
>> > //get the element, create a new custom MXML component
>> >
>> > var uiobj:MyCustomMXMLComponent = new MyCustomMXMLComponent();
>> >
>> > this.canvas.addChild(uiobj);
>> >
>> > uiobj.lblTitle = "some title that i get from the array collection";
>> >
>> > uiobj.txaBrief = "some more text i get from the array collection";
>> >
>> > //add Move Effect to the ui obj to move it on the canvas.
>> >
>> > moveObj(uiobj);
>> >
>> > }
>> >
>> > public static function moveObj(obj:UIComponent):void {
>> >
>> > var mv:Move = new Move(obj);
>> >
>> > mv.xBy = -(500);
>> >
>> > mv.duration = 10000;
>> >
>> > mv.play();
>> >
>> > //add event listner to listen for mouse rollover event.
>> >
>> > obj.addEventListener(MouseEvent.MOUSE_OVER, handleMouseRollOver);
>> >
>> > obj.addEventListener(MouseEvent.MOUSE_OUT, handleMouseRollOut);
>> >
>> > }
>> >
>> > private static function handleMouseRollOver(event:MouseEvent):void {
>> >
>> > if(event.target.parent.parent.activeEffects[0])
>> >
>> > event.target.parent.parent.activeEffects[0].pause();
>> >
>> > else if(event.target.parent.activeEffects[0])
>> >
>> > event.target.parent.activeEffects[0].pause();
>> >
>> > }
>> >
>> > private static function handleMouseRollOut(event:MouseEvent):void {
>> >
>> > event.target.parent.parent.activeEffects[0].resume();
>> >
>> > }
>> >
>> >
>>
> ----------------------------------------------------------
>> >
>> > MyCustomMXMLComponent.mxml
>> >
>> > <mx:VBox xmlns:mx="http://www.adobe.com/2006/mxml";
>> horizontalScrollPolicy="off">
>> >
>> > <mx:Label id="lblTitle" text="DEFAULT TEXT TITLE" />
>> >
>> > <mx:TextArea id="txaBrief" text="DEFAULT BRIEF TEXT" visible="true"
>> color="#c0c0c0" />
>> >
>> > </mx:VBox>
>> >
>> > --- In flexcoders@yahoogroups.com, "devenhariyani" <devenhariyani@>
>> wrote:
>> > >
>> > > Hello,
>> > >
>> > > I'm struggling on wrapping my mind around the best way to
> architect a
>> > > particular feature i am developing. i have gotten my code to work,
>> > > but i want to improve it to make it work using a more stable and
>> > > scaleble design.
>> > >
>> > > QUESTION: Now, the problem is when a user rolls the mouse over a
>> > > custom MXML compoenent which already has a Move effect applied
> to it,
>> > > I want the MXML component to stop moving. The custom MXML component
>> > > has a Label, Text Area,and other components inside of it, but the
>> > > mouse roll over Event is caught by the inner most UITextField
>> > > component. Inside the Event Handler i have a very hacky way to stop
>> > > the Move Effect:
>> > >
>> > > event.target.parent.parent.activeEffects[0].pause();
>> > > > 1. how do i make the custom MXML component catch the event
>> instead of
>> > > the UITextField buried deep inside the component
>> > >
>> > > 2. how do i reference the MoveEffect for the MXML component without
>> > > having to use parent.parent.activeEffects[0] since that is basically
>> > > hardcoding.
>> > >
>> > > Any help would be greatly appreciated. For more information on my
>> > > situation, i've posted some info:
>> > >
>> > > GOAL: the feature is simple, i have a custome MXML component
> that has
>> > > a Label and a TextArea field inside of a Canvas. My flex application
>> > > makes HttpService to my server and returns data which i put into an
>> > > ArrayCollection. for each element in the ArrayCollection initialize
>> > > a new custom MXML component, I bind it to my custom MXML component
>> > > which i initialize and apply an effect to the MXML component so that
>> > > the component moves across the screen in various pla! ces. The
>> > > component should stop moving when a user rol! ls his/h er mouse
>> over the
>> > > component.
>> > >
>> > >
>> > > Thanks for all of your help!
>> > >
>> > > --Deven
>> > >
>> >
>>
>
> 

Reply via email to