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
Components for multimedia applications developers
Flash Member Controls
Ceiling and floor math functions
Jeff's Platform Game Engine v2
Get Rect of Vertexlist
ShapeWindow Xtra
MP3 Cross Fader
Rollover Sound
Masking Digital Video
Direct SMS Review
 

 

 

Behavior toggle a global variable with button

Added on 10/12/2004

 

Compatibilities:
behavior D8 D8_5 D9 Mac PC Shockwave US

This item has not yet been rated

Author: askeptic (website)

attach this behavior to a graphic sprite choose an on and off state member type in the global variable (boolean type only please, true false) now play the movie if your global is true then the sprite is on if your global is false then the sprite is off click on the sprite to toggle it great for those times you just want to toggle a global without having to write annother script. enjoy, -aSkeptic

--user defined
property myGlobal
property myOnMember
property myOffMember
--internal
property mySprite

on getPropertyDescriptionList me
  p_list = [:]
  p_list.addProp(#myGlobal, [#format : #string, #comment : "what global variable to manipulate?", #default : "gSomeSetting"])
  p_list.addProp(#myOnMember, [#format : #bitmap, #comment : "hot Member:", #default : sprite(the currentSpriteNum).member])
  p_list.addProp(#myOffMember, [#format : #bitmap, #comment : "cold Member:", #default : member(sprite(the currentSpriteNum).member.number + 1)])
  return p_list
end

on beginsprite me
  mysprite = sprite(me.spritenum)
end


on exitframe me
  doThing = ""
  result = 0
  put "global"  && myGlobal &return  after doThing
  put "result ="&& myGlobal          after doThing
  do doThing
  if result then
    mySprite.member = myOnMember
  else
    mySprite.member = myOffMember
  end if
end

on mousedown me
  doThing = ""
  result = 0
  put "global"  && myGlobal &return  after doThing
  put "result ="&& myGlobal          after doThing
  do doThing
  result = not result
  
  doThing = ""
  put "global"  && myGlobal &return  after doThing
  put myGlobal&&"= result"         after doThing
    do doThing
  
end

 


Contact

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

Send e-mail