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
Linking 1 sprite to another by location
Wait for DirectMedia Xtra Sprite v. 2.0
DisplayMode Xtra
Change the LineSize of a Shape Sprite
QTGrabSprite
XML Parser List Converter
Planet Orbiter
Scroll Wheel Lock Behavior
cXtraPieChart
Import text as cast members
 

 

 

Behavior Color Picker

Added on 11/29/2000

 

Compatibilities:
behavior D8 Mac PC Shockwave

Rating:

Author: HasanKazmi (website)

It requires two members one to be used as a button and other to be used as a Color Picker. The Button member can be of any type that can be used as a button. The Color Picker must be a bitmap, with colors the color on the bitmap that will be clicked will become the color of the member as per the function selected in the Behaviour parameters.

Download PC Source    Download Mac Source
--786
--Behaviour: Color Picker
--Changes the back and fore colors of a member on mouseup
--By: Hasan Yasar Kazmi
--Hamdard University Islamabad Pakistan
--dir@37.com
--Dated: 21/Nov/2000.
--Instructions
-- It requires two members one to be used as a button and other to be used as a Color Picker.
--The Button member can be of any type that can be used as a button.
--The Color Picker must be a bitmap, with colors the color on the bitmap that will be clicked will become
--the color of the member as per the function selected in the Behaviour parameters.

property spritenum,location, ColorPicker,TgtMember, ButtonMember,Function

on getPropertyDescriptionList  
  set description = [:]
  addProp description, #ColorPicker, [#default: 1,#format:#integer, #comment: "Number Of Member Containing Colors"]
  addProp description, #TgtMember, [#default: 1,#format:#integer, #comment: "Number Of Sprite to Change"]
  addProp description, #Function, [#default: "Color",#format:#String, #comment: "Color Property To Change",range:["Color","bgColor"]]
  return description
end

on getBehaviorDescription
  return "Color Picker Button for "
end

on beginsprite me  
  spritenum = the spritenum of me
  set location =   sprite(spritenum).loc
  member(ColorPicker).regPoint = point(0,0)
  set ButtonMember =sprite(spritenum).member.membernum
  sprite(spritenum).ink=0
  updatestage
end

on mouseup me  
  set the keyboardFocusSprite = 0
  if sprite(spritenum).member = member(ButtonMember) then    
    sprite(spritenum).member = member(ColorPicker)
    sprite(spritenum).width = member(ColorPicker).width
    sprite(the spritenum of me).height = member(ColorPicker).Height    
  else if sprite(Spritenum).member = member(ColorPicker) then    
    set mempt=  mapstagetomember(sprite(spritenum), the mouseloc)
    ColRefRGB=member(ColorPicker).image.getPixel(mempt)    
    case (Function) of    
      "Color": member(Sprite(TgtMember).membernum).Color = ColRefRGB
      "bgColor":member(Sprite(TgtMember).membernum).bgColor = ColRefRGB
    end case
    updatestage
    sprite(the spritenum of me).member = member(ButtonMember)
    sprite(the spritenum of me).width = member(ButtonMember).width
    sprite(the spritenum of me).height = member(ButtonMember).Height
  end if
  sprite(spritenum).loc = location
  updatestage
end

on mouseleave me
  sprite(the spritenum of me).member = member(ButtonMember)
  sprite(the spritenum of me).width = member(ButtonMember).width
  sprite(the spritenum of me).height = member(ButtonMember).Height
end  

 


Contact

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

Send e-mail