简体   繁体   中英

get id inactionscript/flex

How to get all child ids of myCanvas1.Also for a specific mxml tag say <mx:Move /> how to get its id from action script

<?xml version="1.0" encoding="utf-8"?>
<mx:Application layout="absolute" xmlns:mx="http://www.adobe.com/2006/mxml">
<mx:Script>
<![CDATA[
    [Bindable("__NoChangeEvent__")]
    [Embed(source="fruits.jpg")]
    private var fruitImageClass:Class;

    public function clickhandler(event:Event):void
    {
     //How to get all childs of myCanvas1
    }
]]>
</mx:Script>
<mx:Canvas backgroundColor="#A9C0E7" borderStyle="solid" height="300" id="myCanvas1" width="300">
 <mx:Move id="fruitAnimation1" target="{fruitImage}" xTo="100" yTo="10" />
<mx:Move id="fruitAnimation2" target="{fruitImage2}" xTo="100" yTo="10" />
</mx:Canvas>


<mx:Canvas backgroundColor="#A9C0E7" borderStyle="solid" height="800" id="myCanvas" width="800">
    <mx:Image height="50" id="fruitImage" source="{fruitImageClass}" width="50" x="250" y="10" />
    <mx:Image height="50" id="fruitImage2" source="{fruitImageClass}" width="50" x="250" y="10" />


</mx:Canvas>
<mx:Button click="clickhandler(event)" label="Generate" x="100" y="316" />
</mx:Application>

The problem of your code is children of myCanvas1 are not visual components and this declaration has no sense. You shouldn't put your animations, effects and transitions into visual container. That's all what I can say about your question :)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM