MXML attributes like mouseOver="..." set up event handlers, not effects.
In ActionScript, you have to use code like

    img.addEventListener("mouseOver",
        Delegate.create(this, myMouseOverHandler));

to dynamically attach an event handler; you can't simply set properties
in createChild's initObj to do this. The purpose of the
Delegate.create() is to make 'this' be the application (or component)
when myMouseOverHandler() is called.

MXML attributes like mouseOverEffect="..." set up effects. But, as with
event handlers, I don't think you can't use the createChild()'s initObj
to do this; it's really only for setting normal properties, not events,
effects, or styles. Instead, I think you have to use setStyle() to set
effects dynamically, as in

    img.setStyle("mouseOverEffect", "myZoom");

If I'm wrong about this, Jason can correct me.

The reason that your code compiles, even though it doesn't execute as
you intend, is that the Object literal notation { ... } in ActionScript
creates a plain Object filled with name-value pairs. Unlike the MXML
compiler, which understands what the attribute
mouseOver="popToTop(event.target)" should mean, the ActionScript
compiler doesn't know that when you write

    { mouseOver: "popToTop(event.target)" }

you are trying to create an event; the AS3 compiler simply compiles this
in the same way as it would compile

    { foo: "bar" }

- Gordon



-----Original Message-----
From: flexcoders@yahoogroups.com [mailto:[EMAIL PROTECTED] On
Behalf Of Prasad Dhananjaya
Sent: Tuesday, September 27, 2005 6:40 PM
To: FlexML
Subject: [flexcoders] setting effects to createChild()

Hi All,

Can someone tell me how to set
effects(mouseOver,mouseOverEffect,mouseOut,mouseOutEffect,mouseUpevents)
to createChild().Below line is not working(and giving no compile
errors). Checked several docs. But found nothing helpful.

var img=target.createChild(mx.controls.Image,"", 
                          {source:img23, x:9, y:2,
                          mouseOverEffect:"myZoom",
                          mouseOver:"popToTop(event.target)", 
                          mouseOverEffect:"myZoom",
                          mouseOut:"restore(event.target)",  
                          mouseOutEffect:"cut", 
                          mouseUp:"doubleClickDestroyChild(event)"});


P.S.
What I want to do is to set effects to all createChild components
which are on the canvas.Is there any way to do this easily.

Thanks,
Prasad








--
Flexcoders Mailing List
FAQ: http://groups.yahoo.com/group/flexcoders/files/flexcodersFAQ.txt
Search Archives:
http://www.mail-archive.com/flexcoders%40yahoogroups.com 
Yahoo! Groups Links



 




------------------------ Yahoo! Groups Sponsor --------------------~--> 
Most low income households are not online. Help bridge the digital divide today!
http://us.click.yahoo.com/cd_AJB/QnQLAA/TtwFAA/nhFolB/TM
--------------------------------------------------------------------~-> 

--
Flexcoders Mailing List
FAQ: http://groups.yahoo.com/group/flexcoders/files/flexcodersFAQ.txt
Search Archives: http://www.mail-archive.com/flexcoders%40yahoogroups.com 
Yahoo! Groups Links

<*> To visit your group on the web, go to:
    http://groups.yahoo.com/group/flexcoders/

<*> To unsubscribe from this group, send an email to:
    [EMAIL PROTECTED]

<*> Your use of Yahoo! Groups is subject to:
    http://docs.yahoo.com/info/terms/
 


Reply via email to