3 Replies Latest reply on Aug 6, 2010 10:49 AM by kglad

    Colorable, Draggable Objects - Needs Improvement (AS2:CS5)

    kerry@rocknlearn Level 1

      fishtankcap.jpg

       

      I've made a simple little flash game (pictured above - couldn't see a way to attach the .fla). The basic idea is that you have three little sea creatures, a fish bowl, and some color buttons. You can click on a color button and then click on a creature, and it colors the creature that color. You can also drag the creature to one of three invisible (but intuitively placed) targets in the fish bowl. To do this, I did the following:
      Color Buckets:
      Make each one a button with the following code:

      Code:
      on (release) {
           _root.fillColor = 0x"your hex code here"
           _root.brush.gotoAndStop(1);
      }

      Colorable Creatures:

       

      Make each one a movie clip (button would also work, but not with the way I made them drag) with the following code:

       

      Code:
      on (press) {
           color = new Color(this);
           color.setRGB(_root.fillColor);
           delete color;
      }

      Dragging:

       

      I used the dragNdrop component from FlashValley (

      http://www.flashvalley.com/fv_components/dragNdrop/). You drag the drag component onto each creature, drag a target component onto each target (must be a movie clip), and drag a setup component somewhere out of sight. You then take all of these things and make them a movie clip, export for actionscript with the class set as dragNdrop, and voila. You now have draggable objects that snap to target.

       

       

      Some problems / room for improvement:
      1) I can't figure out how to give the creatures an un-colorable border.
      2) I can't figure out a way to turn off the coloring once they want to pick up the creatures.

       

      #2 is the biggest issue, as we would like for the kids to have a big bank of fish, color them based on something (math problems, phonics puzzles, etc), then drop them into a tank without re-coloring them. At the moment, the kid would have to remember to click on the right color before moving, or move them when they color them, neither of which are optimal.

       

      Any ideas?