I think when u are removing or adding the child applying a move effect will do it
http://livedocs.adobe.com/
Main Topics
Browse All TopicsI'm building an app in Flex. I'm adding and removing children from a component. The children are Canvases and the parent is an HBox. When adding and removing children, rather than the Canvases jumping into their new places, I want them to slide. I've gone at this a few different ways now and always hit a block of one kind or another. Any ideas on how to get this effect?
This Question has been solved and asker verified All Experts Exchange premium technology solutions are available to subscription members.
Experts Exchange has been collecting answers to technology questions since 1996…3 million and counting! If you have a question, chances are we already have your answer.
If you can't find the exact answer you're looking for, ask our exclusive community of 50,000 experts. You’ll get a personalized answer from a trusted professional.
Thousands of free tech tips, tricks, how-to’s and tutorials are available in our peer reviewed articles section. See for yourself how smart our experts are, no login required.
Access the answers to your technology questions today.
30-day free trial. Register in 60 seconds.
Members of the expert community talk about why the experience at Experts Exchange is different than what you will find anywhere else.

Try it out and discover for yourself.
30-day free trial. Register in 60 seconds.
Join the community of experts here and help other tech pros by answering question in your area of expertise. You can earn FREE access to all Experts Exchange's premium features and resources.
I think when u are removing or adding the child applying a move effect will do it
http://livedocs.adobe.com/
The SWF File: http://darrinrobertson.com
The project files: http://darrinrobertson.com
Hi all, any help I could get on this issue would be very helpful.
I have a Flex application. In the application I have an HBox that I will be dynamically adding and removing child objects from.
Eventually I will create a class for the child objects, but right now the ActionScript that creates them is in the main application. Here is that code:
private function createTile():void
{
var prodTile:Canvas = new Canvas;
prodTile.width = 100;
prodTile.height = 100;
prodTile.setStyle("backgro
prodTile.id = "BlackBox";
prodHBox.addChild(prodTile
prodTiles.push(prodTile);
prodTile.addEventListener(
var prodTile2:Canvas = new Canvas;
prodTile2.width = 100;
prodTile2.height = 100;
prodTile2.setStyle("backgr
prodHBox.addChild(prodTile
}
The function createTile() creates two objects, one black and one gray. Eventually there will be more but for now createTile() keeps things simple.
In the SWF application, click the "Show" button to call the createTile() function.
Now, when you click the "Hide" button, the black box is removed. The funciton it calls is this one:
private function dropBlack():void
{
prodHBox.removeChild(prodT
}
What I'm trying to achieve is this:
Right now, when you remove the black box, the gray box instantly jumps to where the black box was. What I need to have happen is for the gray box to animate to it's new position where the black box was. I would like to to slide into place over time. Eventually I will also need to need it to slide out of the way when a new child is introduced.
I know this can be accomplished with effects, but for the life of me all the books, forums, Adobe docs, and web tutorials have shed little to no light on how to do this. Could be I've just been unlucky in my searching.
Does anyone know how to do what I need to do, or even where I might find a good tutorial or book that has the desired information?
Again, I'm in a tight spot at this point and any help would be extremely appreciated.
Thanks,
[d]
There are many ways of doing this to make it intresting and simple , lets resize the black canvas to 0,0 and then remove it, while resizing lets apply resize effect.
define this in the MXML
<mx:Resize id="resize" widthTo="0" heightTo="0" />
and then
private function createTile():void
{
var prodTile:Canvas = new Canvas;
prodTile.width = 100;
prodTile.height = 100;
prodTile.setStyle("backgro
prodTile.id = "BlackBox";
prodHBox.addChild(prodTile
prodTiles.push(prodTile);
prodTile.addEventListener(
prodTile.resizeEffect = "resize"
var prodTile2:Canvas = new Canvas;
prodTile2.width = 100;
prodTile2.height = 100;
prodTile2.setStyle("backgr
prodHBox.addChild(prodTile
}
I am not sure about the syntax please check that and let me know if there are any errors.
there are many other ways to do this too check
http://blog.flexexamples.c
Hi Gary and everyone else who responded to this question. Although you all had some very creative suggestions, none were what I was specifically looking for. But I did figure it out partially because your responses pointed me in the right direction so I'm splitting the points up.
Here are the steps I took to get the effect:
I used a Canvas container for the child tiles.
I placed the tiles programatically and used a Switch conditional to increment their X and Y coordinates. As the switch placed each one, it added the X and Y to an array called "positions". This array then contained the X and Y for every possible position in the canvas. The switch also added each child to another array called "tiles" and set a custom property called "inList" to "true".
When children are removed programatically, the childIndex changes. I then used the current childIndex number to call the positions array. I know had the current X and Y and the X and Y the tile needed to go to, this was enough to use a move effect. The same works in reverse when children are added.
To filter the tiles as to which ones needed to be added, removed, or left alone, and to keep them in order when adding children back, I created a function that compared them to search data and also to the inList boolean. I then evaluated them as being: on stage and needed to stay, on stage and needed to be removed, off stage and needed to remain off stage, or off stage and needed to be added. Based on the condition, the tile would be handled appropriately. Each time this condition looped, I used a count variable and then addChildAt(i) to make sure the tile was added back in the correct order.
I'll be posting the finished piece at www.darrinrobertson.com/in
Thanks again,
[d]
Business Accounts
Answer for Membership
by: chinu1310Posted on 2007-12-14 at 11:11:25ID: 20473737
When you add child canvas you assign them a showEffect property. In this property you can assign different effects like WipeDown ,Zoom,Fade etc.
flex/2/lan gref/mx/ef fects/pack age- detail .html
List of available effects with flex
http://livedocs.adobe.com/
Hope it helps
-CK