Hi List,
Has anyone ever created a volume dial to use with the cd pro xtra? Im
trying to create one, at the moment I have a horizontal slider with the
following lingo which works fine on both PC / MAC
on slippy me
-- get the limits of the slide
offset = sprite(markSprite).member.regPoint.locV + 1
put the rect of sprite barSprite + rect(0, offset, 0, -offset) into
barRect
put (the bottom of barRect - the top of barRect) into barLength
put the bottom of barRect into maxV
-- put maxV
put the top of barRect into minV
-- put minV
repeat while the stillDown
put min(max(the mouseV,minV),maxV) into v
-- put v -- limit slide
set the locV of sprite markSprite = v
put float(maxV-v)/(maxV-minV) into amt -- percentage
if the platform = "windows,32" then
baSetVolume("cd", integer(100*amt))
else
SetVolume(cd, integer(100*amt))
end if
updateStage
end repeat
End
However for the volume dial im having a bit of difficulty, I downloaded a
behaviour from media macros that is to control the sound channel in director
- can I modify this to work with the CD Pro xtra.... If so can you lend a
hand please - as im a bit unsure where the correct lingo should go, I have
so far:
-- DESCRIPTION --
on getBehaviorDescription me
return "\
DRAG TO ROTATE"&RETURN&RETURN&"\
Use the mouse to drag a sprite in a circle around its regPoint."&\
RETURN&RETURN&"\
PERMITTED MEMBER TYPES:"&RETURN&"This behavior works best with Flash and \
Vector Shape members, but can also be used with Bitmap, Picture and Text."&\
RETURN&RETURN&"\
The scroll bar of scrolling Text members does not rotate. If attached to a
\
sprite with a scrolling Text member, this behavior will convert the member
to \
one with a fixed box size."&RETURN&RETURN&"\
PARAMETERS: None"
end getBehaviorDescription
on getBehaviorTooltip me
return "\
Use with Flash and Vector Shape members, and"&RETURN&"\
also with Bitmaps, Picture and Text."&RETURN&RETURN&"\
Use the mouse to drag a sprite in a circle"&RETURN&"\
around its regPoint."
end getBehaviorTooltip
-- NOTES FOR DEVELOPERS --
-- Basically, this behavior compares the position of the mouse when it was
-- clicked on the sprite and its current position. First the slope between
-- the clickLoc and the loc of mySprite is converted to an angle. Turn me
-- (called on each prepareFrame) then repeates the operation for the current
-- mouseLoc and the current loc of mySprite. By subtracting one angle from
the
-- other, it knows how much the sprite should be turned from its original
-- position.
-- HISTORY --
-- 14 September 1998: written for the D7 Behaviors Palette by James Newton
-- 16 November 1998: ErrorAlert changed, made compatible with Draw Connector
-- PROPERTIES --
property spriteNum
property mySprite
property myMember
-- error checking
property getPDLError
-- internal properties
property myMouseDown
property myPrevAngle
property myClickAngle
property pLowLimit, pHighLimit
property pMarks, pClickAngle
-- EVENT HANDLERS --
on beginSprite me
Initialize me
end beginSprite
on mouseDown me
StartDrag me
end mouseDown
on prepareFrame me
if myMouseDown then
if the mouseDown then
Turn me
else
StopDrag me
end if
end if
end prepareFrame
-- CUSTOM HANDLERS --
on Initialize me -- sent by beginSprite
mySprite = sprite(me.spriteNum)
myMember = mySprite.member
memberType = myMember.type
range = (pHighLimit - pLowLimit) * 1.0000
pClickAngle = range/(pMarks-1)
if PermittedMemberTypes(me).getPos(memberType) then
case memberType of
#text:
if myMember.boxType = #scroll then
ErrorAlert (me, #scrollingText, myMember)
myMember.boxType = #fixed
end if
#vectorShape, #flash:
mySprite.viewPoint = point (0, 0)
mySprite.originMode = #center
mySprite.scaleMode = #autoSize
end case
else
-- Error checking
ErrorAlert (me, #invalidMemberType, memberType)
end if
end Initialize
on Forwarded_mouseDown me
-- The mouseclick was intercepted by a different behavior and forwarded
if not myMouseDown then
mouseDown me
return myMouseDown
end if
end mouseUp
on StartDrag me -- sent by mouseDown
if sprite (spriteNum).ink = 8 then
-- Matte ink
if the mouseMember <> sprite (spriteNum).member then
exit
end if
end if
myMouseDown = TRUE
sendAllSprites #Active_Sprite, myMouseDown
slope = the clickLoc - mySprite.loc
myClickAngle = GetAngle (me, slope)
myPrevAngle = mySprite.rotation
end StartDrag
on StopDrag me
myMouseDown = FALSE
sendAllSprites #Active_Sprite, myMouseDown
end StopDrag
on Turn me -- sent by prepareFrame
slope = the mouseLoc - mySprite.loc
newAngle = myPrevAngle + getAngle (me, slope) - myClickAngle
if newAngle < 0 then
newAngle = newAngle + 360
end if
newAngle = newAngle mod 360
if newAngle > pLowLimit and newAngle < pHighLimit then
whichClick = integer(newAngle/pClickAngle)
whichClick = baSetVolume ("cd", + 10)
newAngle = 0 + whichClick * pClickAngle
mySprite.rotation = newAngle
-- else
-- put newAngle
end if
end Turn
on GetAngle me, slope -- sent by Turn
deltaH = slope[1]
deltaV = slope[2]
if deltaH then
slope = float (deltaV) / deltaH
angle = atan (slope)
if deltaH < 0 then
angle = angle + pi
end if
else if deltaV > 0 then
angle = pi / 2
else if deltaV < 0 then
angle = (3 * pi) / 2
else
angle = 0
end if
-- Convert to degrees for .rotation
angle = (angle * 180) / pi
return angle
end GetAngle
-- ERROR CHECKING --
on ErrorAlert me, theError, data
-- sent by getPropertyDescriptionList, Initialize
case theError of
#getPDLError:
alert "\
Error: This behavior works only with the following members types:"&RETURN&\
permittedMemberTypes(me)&RETURN&RETURN&"\
Hit OK and then delete this behavior from the sprite."&RETURN&"\
For more information on deleting Behaviors, see the Help system."
if the optionDown then
return \
[ \
#getPDLError: \
[ \
#comment: "ERROR: Wrong member type. Click 'Cancel'.", \
#format: #string, \
#range: [""], \
#default: "" \
] \
]
end if
otherwise
-- Determine the behavior's name
behaviorName = string (me)
delete word 1 of behaviorName
delete the last word of behaviorName
delete the last word of behaviorName
-- Convert #data to useful value
case data.ilk of
#void: data = "<void>"
#symbol: data = "#"&data
end case
case theError of
#invalidMemberType:
alert "\
BEHAVIOR ERROR: Frame "&the frame&", Sprite "&me.spriteNum&RETURN&RETURN&"\
Behavior "&behaviorName&" only functions with the following member types:"&\
RETURN&permittedMemberTypes()&RETURN&RETURN&\
"Current type = "&data
halt
#scrollingText:
if the runMode = "Author" then
memberName = data.name
if memberName = "" then
memberName = string (data)
delete memberName.word [1]
delete the last char of memberName
else
memberName = QUOTE&memberName"E
end if
alert "\
BEHAVIOR ERROR: Frame "&the frame&", Sprite "&me.spriteNum&RETURN&"\
Behavior "&behaviorName&RETURN&RETURN&"\
Scroll bars of Text members cannot be rotated. The boxType of the member
"&\
memberName&" has been set to #fixed."
end if
end case
end case
end ErrorAlert
on getPropertyDescriptionList me
if not the currentSpriteNum then exit
-- Error check: does current sprite contain appropriate member type?
theMember = sprite(the currentSpriteNum).member
memberType = theMember.type
permittedTypes = PermittedMemberTypes(me)
if not permittedTypes.getPos(memberType) then
return errorAlert (me, #getPDLError, permittedTypes)
end if
set pdlist to [:]
addprop pdlist, #pLowLimit, [#comment:"Lowest limit", #format:#integer,
#default:0, #range:[#min:0, #max:360]]
addprop pdlist, #pHighLimit, [#comment:"Highest limit", #format:#integer,
#default:180, #range:[#min:0, #max:360]]
addprop pdlist, #pMarks, [#comment:"How many click marks?",
#format:#integer, #default:8]
return pdlist
end getPropertyDescriptionList
on PermittedMemberTypes me
-- sent by:
-- getBehaviorDescription
-- getPropertyDescriptionList
-- Initialize
return [#bitmap, #flash, #picture, #text, #vectorShape]
end PermittedMemberTypes
Cheers,
Dan ;)
[To remove yourself from this list, or to change to digest mode, go to
http://www.penworks.com/lingo-l.cgi To post messages to the list, email
[EMAIL PROTECTED] (Problems, email [EMAIL PROTECTED]). Lingo-L is for
learning and helping with programming Lingo. Thanks!]