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" <[EMAIL PROTECTED]> 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