Contents
Articles
Behaviors
Books
Director News
Director Web Sites
FAQ
Games
Mailing Lists
News Groups
Project Examples
Reviews
Software
Tools
Useful Web Sites
Utilities
Xtras

Don't miss these
Generic behavior to emulate a Keystroke
Amplitude Xtra Review
Set Registration Point of Sprite
Shockwave Safe Xtras
Increase/ Decrease ViewScale Property of a Flash Member
Send E-mail Via Browser
Animated Cursor
Buddy API
To activate previous instance and quit
Ripple Follow Mouse on Rollover-Alphamania
 

 

 

Behavior Coloring Book

Added on 12/12/1999

 

Compatibilities:
behavior D7 D8 Mac PC Shockwave

This item has not yet been rated

Author: MediaMacros (website)

This is a simple behavior to turn vector, shape and bitmap members into swatches and coloring book elements.

--Copyright 1999 Chuck Neal
--chuck@mediamacros.com
--If you find this code helpful, send me an e-mail and let me know. :-)

property spriteNum, whichPart, whatType, setColor

global gColoringBookColor

on getPropertyDescriptionList me
  p_list = [:]
  if ([#shape, #vectorShape, #bitMap]).getOne(sprite(the currentSpriteNum).member.type) <> 0 then
    p_list.addProp(#whichPart, [#format : #symbol, #comment : "Which Part", #default : #Swatch, #range : [#Swatch, #ColorArea]])
    if sprite(the currentSpriteNum).member.type = #vectorShape then
      whatColor = sprite(the currentSpriteNum).member.fillColor.paletteIndex
    else
      whatColor = sprite(the currentSpriteNum).forecolor
    end if
    p_list.addProp(#setColor, [#format : #integer, #comment : "What color", #default : whatColor])
  else
    if the currentSpriteNum > 0 then
      alert "This behavior is only for shapes, bitmaps, and vector shapes."
    end if
  end if
  return p_list
end

on beginSprite me
  whatType = sprite(spriteNum).member.type
  if whatType = #vectorShape then
    theColor = paletteIndex(setColor)
    myFillColor = color(#rgb, theColor.red, theColor.green, theColor.blue)
    sprite(spriteNum).member.fillColor = myFillColor
  else
    sprite(spriteNum).forecolor = setColor
  end if
  case whichPart of
    #swatch :
      if whatType = #vectorShape then
        if gColoringBookColor = void then
          gColoringBookColor = sprite(spriteNum).member.fillColor.paletteIndex
        end if
      else if whatType = #shape or whatType = #bitmap then
        if gColoringBookColor = void then
          gColoringBookColor = sprite(spriteNum).forecolor
        end if
      end if
      sprite(spriteNum).cursor = 281 --dropper
    #ColorArea :
      sprite(spriteNum).cursor = 259 --bucket
  end case
end

on mouseUp me
  case whichPart of
    #swatch :
      if whatType = #vectorShape then
        gColoringBookColor = sprite(spriteNum).member.fillColor
      else if whatType = #shape or whatType = #bitmap then
        gColoringBookColor = sprite(spriteNum).foreColor
      end if
    #ColorArea :
      if whatType = #vectorShape then
        theColor = paletteIndex(gColoringBookColor)
        myFillColor = color(#rgb, theColor.red, theColor.green, theColor.blue)
        sprite(spriteNum).member.fillColor = myFillColor
      else if whatType = #shape or whatType = #bitmap then
        sprite(spriteNum).foreColor = gColoringBookColor
      end if
  end case
end

on getBehaviorDescription me
  describe = "This behavior works on vector shapes, shapes, and bitmaps to create both color swatches as well as coloring book elements." & return
  describe = describe & "Create 1 bit bitmaps, shapes or vector shapes for swatches and elements for the coloring book and drop this behavior on each. Choose a default color and start the project running for a fully playable coloring book."
  return describe
end  

 


Contact

MMI
36 South Court Sq
Suite 300
Newnan, GA 30263
USA

Send e-mail