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
Lingo MarkUp Xtra
myExcel
Set Properties of a Flash Sprite
Export Text for proofing
macromedia.director.basics
bambino
File Save Button
sets custom cursors
NTI CD Maker
Case sensitive string comparison
 

 

 

Behavior Fill Gradient to a Vector Shape

Added on 6/13/2000

 

Compatibilities:
behavior D7 D8 Mac Shockwave

This item has not yet been rated

Author: KumarK

Fill Gradient to a Vector Shape

---- written for Director 8 ---
---- Kumar.K kumark@icode.com ----

--- Custom Properties ---
property sourcemember,WhereTo,StartR,StartG,StartB,EndR,EndG,EndB,Gradtype

--- Get Behavior Description List ---
on getPropertyDescriptionList me
  VectorMembersList=searchVectorMember (me)
  descriptionlist = [:]
  spriteassignlist=["Mouse Up","Mouse Down", "Mouse Enter","Mouse Leave"]
  frameassignlist=["Exit Frame","Enter Frame"]
  if VectorMembersList.count > 0 then
    addprop descriptionlist,#sourcemember,[#comment:"Source Vector Shape Cast member :",  \
    #format:#String,#range:VectorMembersList,#default:VectorMembersList[1]]
  else
    addprop descriptionlist,#sourcemember,[#comment:"Source Vector Shape Cast member :",#format:#Graphic,#default:1]
  end if
  addprop descriptionlist,#StartR,[#comment:"Red Value(Starting Color) :",#format:#Integer,#range:[#min:0,#max:255],#default:50]
  addprop descriptionlist,#StartG,[#comment:"Green Value(Starting Color) :",#format:#Integer,#range:[#min:0,#max:255],#default:50]
  addprop descriptionlist,#StartB,[#comment:"Blue Value(Starting Color) :",#format:#Integer,#range:[#min:0,#max:255],#default:50]
  addprop descriptionlist,#EndR,[#comment:"Red Value(End Color) :",#format:#Integer,#range:[#min:0,#max:255],#default:50]
  addprop descriptionlist,#EndG,[#comment:"Green Value(End Color) :",#format:#Integer,#range:[#min:0,#max:255],#default:50]
  addprop descriptionlist,#EndB,[#comment:"Blue Value(End Color) :",#format:#Integer,#range:[#min:0,#max:255],#default:50]
  addprop descriptionlist,#Gradtype,[#comment:"Select Gradient Type :",#format:#string,#range:["Linear","Radial"],#default:"Linear"]
  if the currentspritenum <> 0 then
    addprop descriptionlist, #WhereTo, [#comment:"Where To Assign this Script ?", #format:#String,#range:spriteassignlist,#default:spriteassignlist[1]]
  else
    addprop descriptionlist, #WhereTo, [#comment:"Where To Assign this Script ?", #format:#String,#range:frameassignlist,#default:frameassignlist[2]]
  end if  
  return descriptionlist
end getPropertyDescriptionList
--- Get Behavior Description List ---


-- Get Behavior description --
on getBehaviorDescription
  return "This Behavior Fills a Vector Graphics member with Gradient Color " & RETURN & RETURN & \
  "Parameters" & RETURN & \
  "* Source Vector Cast member." & RETURN & \
  "* Starting Color." & RETURN & \
  "* End Color." & RETURN & \
  "* Where to attach this Script"
end
-- Get Behavior description --

-- events --
on mouseUp me
  if WhereTo="Mouse Up" then
    FillGradient
  end if
end

on mouseDown me
  if WhereTo="Mouse Down" then
    FillGradient
  end if
end

on mouseEnter me
  if WhereTo="Mouse Enter" then
    FillGradient
  end if
end

on mouseLeave me
  if WhereTo="Mouse Leave" then
    FillGradient
  end if
end

on enterframe
  if WhereTo="Enter Frame" then
    FillGradient
  end if
end

on ExitFrame
  if WhereTo="Exit Frame" then
    FillGradient
  end if
end
-- events --

-- custom handlers --
on FillGradient
  if member(sourcemember).type = #vectorShape then
    member(sourcemember).fillmode=#gradient
    case Gradtype of
      "Linear":member(sourcemember).gradientType=#linear
      "Radial":member(sourcemember).gradientType=#Radial
    end case
    member(sourcemember).fillcolor=rgb(StartR,StartG,StartB)
    member(sourcemember).endcolor=rgb(EndR,EndG,EndB)  
  end if
end
-- custom handlers --


------ Availbale for both Frame & Sprite Script ------
on isOKToAttach (me, aSpriteType, aSpriteNum)
case aSpriteType of
#graphic:
return true
#script:
return True
end case
end isOKToAttach
------ Availbale for both Frame & Sprite Script ------

------ Search for Vector Member ------
on searchVectorMember me
VectorMembersList = []
maxCastLib = the number of castLibs
repeat with theCastLib = 1 to maxCastLib
maxMember = the number of members of castLib theCastLib
repeat with memberNumber = 1 to maxMember
theMember = member(memberNumber, theCastLib)
if theMember.type = #vectorShape then
if theMember.name = EMPTY then
VectorMembersList.append(theMember)
else
VectorMembersList.append(theMember.name)
end if
end if
end repeat
end repeat
return VectorMembersList
end
------ Search for Vector Member ------  

 


Contact

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

Send e-mail