2 Replies Latest reply on Dec 17, 2007 8:53 PM by Gregory Lafrance

    Effect Question

      The SWF File: http://darrinrobertson.com/loadcells/bin/IF_LoadCells.swf

      The project files: http://darrinrobertson.com/loadcells

      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.id = "BlackBox";
      prodTile.addEventListener(MouseEvent.CLICK, isClicked);

      var prodTile2:Canvas = new Canvas;
      prodTile2.width = 100;
      prodTile2.height = 100;

      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

      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 ,

        • 1. Re: Effect Question
          dave cragg
          Did you manage to find a solution?

          Here's an idea that doesn't use effects. (It's untested).

          Before using removeChild(), do something like the following:

          1. Set the visible of the object to be removed to false. (Add a hide effect perhaps.)
          2. Set up a timer with an appropriate delay and repeat count.
          3. Add a timer event handler, and reduce the width of the now invisible object.
          4. Add a timerComplete event handler that finally removes the object.
          • 2. Re: Effect Question
            Gregory Lafrance Level 6
            Maybe you could use the Move effect, and if all the tiles are the same size, you can use the tile width and padding to calculate the move.