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
MailTo Xtra
Audio cutting off early
Mix-FX Flash animation builder
Spell Check Xtra
Sprite controls
Opening Local HTML pages
MAAD FTP Xtra
Compound Interest
Export JPEG
SM scroll slowdown
 

 

 

Behavior Progressive Blend on Rollover

Added on 2/6/2001

 

Compatibilities:
behavior D7 D8 Mac PC Shockwave

This item has not yet been rated

Author: RossClutterbuck

Use the script on a bitmap, then define the steps and whether the action is on mouseenter and/or mouseleave.

-- USER PROPERTIES --
property myStartBlend, myEndBlend, myBlendStep, boolPosBlend
property userStepsNumber, userRollInFade, userRollOutFade

-- INTERNAL SCRIPTING PROPERTIES --
property mySprite

on beginSprite me
  mySprite = sprite(me.spriteNum)
  
  myBlendStep = (myEndBlend - myStartBlend) / userStepsNumber
  
  -- create positive number if myBlendStep is negative...
  if myBlendStep < 0 then
    myBlendStep = myBlendStep - (myBlendStep * 2)
  end if
  
  mySprite.blend = myStartBlend
  
  if myStartBlend < myEndBlend then
    boolPosBlend = TRUE
  else
    boolPosBlend = FALSE
  end if
end

on prepareFrame
  if mySprite.rollover = TRUE then
    if userRollInFade = TRUE then
      if mySprite.blend <> myEndBlend then
        if boolPosBlend = TRUE then
          FadeUp myEndBlend
        else
          FadeDown myEndBlend
        end if
      end if
    else
      mySprite.blend = myEndBlend      
    end if
  else
    if mySprite.blend <> myStartBlend then
      if userRollOutFade = TRUE then
        if boolPosBlend = TRUE then
          FadeDown myStartBlend
        else
          FadeUp myStartBlend
        end if
      else
        mySprite.blend = myStartBlend
      end if
    end if
  end if
end

-- CUSTOM HANDLERS --

on FadeUp myTargetCheck
  myBlendValue = mySprite.blend
  
  myBlendValue = myBlendValue + myBlendStep
  
  if myBlendValue >= myTargetCheck then
    myBlendValue = myTargetCheck
  end if
  
  mySprite.blend = myBlendValue
end

on FadeDown myTargetCheck
  myBlendValue = mySprite.blend
  
  myBlendValue = myBlendValue - myBlendStep
  
  if myBlendValue <= myTargetCheck then
    myBlendValue = myTargetCheck
  end if
  
  mySprite.blend = myBlendValue
end

-- AUTHORTIME PROPERTY HANDLERS --

on getPropertyDescriptionList me
  set myProperties = [:]
  
  addProp myProperties, #myStartBlend,¬
    [#comment: "Initial blend value of sprite:",¬
     #format:  #integer,¬
     #range:   [min: 0, max: 100],¬
     #default: 50¬
    ]
  
  addProp myProperties, #myEndBlend,¬
    [#comment: "Final blend of sprite:",¬
     #format:  #integer,¬
     #range:   [min: 0, max: 100],¬
     #default: 100¬
    ]
  
  addProp myProperties, #userStepsNumber,¬
    [#comment: "Number of stages to blend over:",¬
     #format:  #integer,¬
     #range:   [min: 4, max: 25],¬
     #default: 10¬
    ]
  
  addProp myProperties, #userRollInFade,¬
    [#comment: "Use blending effect on mouse over?",¬
     #format:  #boolean,¬
     #default: TRUE¬
    ]
  
  addProp myProperties, #userRollOutFade,¬
    [#comment: "Use blending effect on mouse out?",¬
     #format:  #boolean,¬
     #default: TRUE¬
    ]
  
  return myProperties
end

on isOKToAttach me, spriteType, spriteNum
  case spriteType of
    #graphic:
      return sprite(spriteNum).member.type <> #digitalvideo
    #script:
      return FALSE
  end case
end

 


Contact

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

Send e-mail