At 06:03 +0800 04/11/2002, noelle cheng wrote:

>Oh and one last thing,  I have saved  all your useful replies as references.

And discarded mine, I assume. After all I am a *Macintosh* user. ;)

>Adjusting volume with a slider
>
>http://www.director-online.com/accessArticle.cfm?id=233
>
>
>I am a little lost.  Actually, I wanted to create a horizontal 
>slider. This article shows a vertical one.
>
>So I substituted all the locV for locH ,  mouseV for mouseH and 
>pSliderBottom for pSliderLeft in the  code.

Not a bad start... OK, here's the code, reworked, with some comments.

property pSoundChannel
property pRange
property pSliderBottom
property pDeltaFactor
property pMySprite
property pFlag

on getPropertyDescriptionList me
   set pdlist to [\
     #pSoundChannel: [#comment:"Which Sound Channel",\
                      #format:#integer,\
                      #default:1,\
                      #range:[#min:1,#max:8]] ]
   return pdlist
end getPropertyDescriptionList

on beginSprite me
   set pMySprite = the spriteNum of me
   set myTroughSprite = pMySprite - 1
   set pRange = the width of sprite myTroughSprite
   -- Note here that the range has been set to the sprite's
   -- width instead of height, as you want to make this
   -- a horizontal slider instead of a vertical one
   set pSliderBottom = the left of sprite \
     myTroughSprite
   -- Rather than rename the variable 'pSliderBottom' I've
   -- simply changed it so its value is equal to the left
   -- edge of the sprite instead of its bottom, again
   -- because you're going horizontal here.
   set pDeltaFactor = 256/pRange
   adjustVolume me
   set pFlag = FALSE
end

on mouseDown me
   set pFlag = TRUE
end

on mouseUp me
   set pFlag = FALSE
end

on mouseUpOutside me
   set pFlag = FALSE
end mouseUpOutside

on enterFrame me
   if pFlag = TRUE then
     if the mouseH >= pSliderBottom AND \
      the mouseH <= pSliderBottom + pRange then
       set the locH of sprite pMySprite = the mouseH
       -- Note the changes from mouseV and locV to
       -- mouseH and locH, as you surely did yourself.
       -- Note also the changes of the greater and less
       -- than testing.
       -- Finally note that I've changed
       --   'pSliderBottom - pRange'
       -- to
       --   'pSliderBottom + pRange'
       adjustVolume me
     end if
   end if
end

on adjustVolume me
   set myLocH = the locH of sprite pMySprite
   -- Again, locH instead of locV.
   set sliderChange = pSliderBottom + myLocH
   -- This was the change from - to + referenced in
   -- the article.
   set the volume of sound pSoundChannel = \
      sliderChange * pDeltaFactor
end


--

Enjoy!

-- 

              Warren Ockrassa | http://www.nightwares.com/
  Director help | Free files | Sample chapters | Freelance | Consulting
        Author | Director 8.5 Shockwave Studio: A Beginner's Guide
                    Published by Osborne/McGraw-Hill
          http://www.osborne.com/indexes/beginners_guides.shtml
[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!]

Reply via email to