Flash Component NumericStepper Behavior

From Director Online Wiki
Jump to: navigation, search

Description

Enables basic control over a flash component NumericStepper sprite

Director MX 2004, Director 11

Lingo

-- AstrO Controls :: NumericStepper
-- version 1.0b1-20Jul08
-- Created by Toby De Ieso
-- Modified by Toby De Ieso
 
 
property pSprite
property pMember
property pObject
property pActive
property pControlType
 
property pEventEnabled
property pEventCode
property pMaximum
property pMinimum
property pStepSize
property pValue
property pThemeColor
property pFontFamily
property pFontSize
property pFontStyle
property pFontWeight
property pTextDecoration
property pFontColor
property pFontDisabledColor
 
 
on isOKToAttach me, aSpriteType, aSpriteNum
  tReturn = FALSE
  if sprite(aSpriteNum).member.type = #flashComponent then tReturn = TRUE
  return tReturn
end
 
 
on getPropertyDescriptionList me
  tList = [:]
 
  tList.addProp(#pEventEnabled, [#comment:"run code on change:",#format:#boolean,#default:TRUE])
  tList.addProp(#pEventCode, [#comment:"code:",#format:#string,#default:"trace(sprite(me.spriteNum),me)"])
  tList.addProp(#pMaximum, [#comment:"maximum:",#format:#integer,#default:100])
  tList.addProp(#pMinimum, [#comment:"minimum:",#format:#integer,#default:0])
  tList.addProp(#pStepSize, [#comment:"stepSize:",#format:#integer,#default:1])
  tList.addProp(#pValue, [#comment:"value:",#format:#integer,#default:0])
 
  tList.addProp(#pThemeColor, [#comment:"themeColor:",#format:#string,#default:"haloGreen",#range:["haloGreen","haloBlue","haloOrange"]])
  tList.addProp(#pFontFamily, [#comment:"fontFamily:",#format:#string,#default:"_sans"])
  tList.addProp(#pFontSize, [#comment:"fontSize:",#format:#integer,#default:12])
  tList.addProp(#pFontStyle, [#comment:"fontStyle:",#format:#string,#default:"normal",#range:["normal","italic"]])
  tList.addProp(#pFontWeight, [#comment:"fontWeight:",#format:#string,#default:"normal",#range:["normal","bold"]])
  tList.addProp(#pTextDecoration, [#comment:"textDecoration:",#format:#string,#default:"normal",#range:["normal","underline"]])
  tList.addProp(#pFontColor, [#comment:"color:",#format:#color,#default:color(11,51,60)])
  tList.addProp(#pFontDisabledColor, [#comment:"disabledColor:",#format:#color,#default:color(132,131,132)])
 
  return tList
end
 
 
on beginSprite me
  pSprite = sprite(me.spriteNum)
  pMember = pSprite.member
  pActive = FALSE
 
  pMember.eventPassMode = #passNever
  pMember.buttonsEnabled = TRUE
  pMember.actionsEnabled = TRUE
  pMember.maximum = pMaximum
  pMember.minimum = pMinimum
  pMember.stepSize = pStepSize
  pMember.value = pValue
 
  pSprite.ink = 36
end
 
 
on exitFrame me
  if not(pActive) then
    pObject = pSprite.getVariable("_root",FALSE)
 
    pSprite.setStyle("themeColor",pThemeColor)
    pSprite.setStyle("fontFamily",pFontFamily)
    pSprite.setStyle("fontSize",pFontSize)
    pSprite.setStyle("fontStyle",pFontStyle)
    pSprite.setStyle("fontWeight",pFontWeight)
    pSprite.setStyle("textDecoration",pTextDecoration)
    pSprite.setStyle("color",("0x" & pFontColor.hexString().char[2..7]))
    pSprite.setStyle("disabledColor",("0x" & pFontDisabledColor.hexString().char[2..7]))
 
    pActive = TRUE
  end if
end 
 
on change(me)
  if pActive and pEventEnabled then do pEventCode
end