The Oddest Thing....

MouseOver interaction with Volume

Ok So I'm making an MP3 controller in DesktopX.. I decide to use MouseOver interaction for the Volume control (MouseOver "+" Volume goes up, MouseOver "-" Volume goes down).. And this is what happened and I swear I'm not making this up.. When I set the Volume to go up by 1 each time it only gets to 16% Volume (If I use another method to turn up the volume and try again it goes to 36% and so forth), but it work fines if I'm taking 1 each time.. Here's the code:

:: This is for the "-" control
Sub Object_OnMouseEnter
Object.SetTimer 1, 1
End Sub

Sub Object_OnTimer1
If System.Volume <= 0 Then
System.Volume = 0
Object.KillTimer 1
Else
System.Volume = System.Volume - 1
End If
End Sub

Sub Object_OnMouseLeave
Object.KillTimer 1
End Sub

:: This is for the "+" Control
Sub Object_OnMouseEnter
Object.SetTimer 1, 1
End Sub

Sub Object_OnTimer1
If System.Volume => 100 Then
System.Volume = 100
Object.KillTimer 1
Else
System.Volume = System.Volume + 1
End If
End Sub

Sub Object_OnMouseLeave
Object.KillTimer 1
End Sub

It works fine having "+ 2" instead though!.. Any answers are welcome
3,297 views 4 replies
Reply #1 Top
Hey Cyberium,

hope your well ...

I'm no pro at scripting ... but I figure this should work ...

EG: for the "+" Control :

-------------------------------------

Sub Object_OnMouseEnter
Object.SetTimer 1, 1
End Sub

Sub Object_OnMouseLeave
Object.KillTimer 1
End Sub

Sub Object_OnTimer1
If System.Volume < 100 Then
System.Volume = System.Volume + 1
Else
Object.KillTimer 1
End If
End Sub

-------------------------------------

It 'should' work, but I just tried it and got the exact same problem you did.

Hell knows ...

Let us know if u get it right ...

Good Luck !!
Reply #2 Top
YAY !!!

GOT IT ...

It's actually quite silly that it doesn't work the way we tried originally, but I ended up finding a solution ...

Don't ask why it is the way it is ... it just is ... lol

I've done it so that you can just copy and paste the scripts into the objects ...
Here you go ...

------------------------------
VOLUME UP CONTROL
------------------------------

Dim sysvol

sysvol = System.Volume

Sub Object_OnMouseEnter

sysvol = System.Volume
Object.SetTimer 1, 1

End Sub


Sub Object_OnMouseLeave

Object.KillTimer 1

End Sub


Sub Object_OnTimer1

If sysvol < 100 Then
sysvol = sysvol + 1
System.Volume = sysvol
Else
Object.KillTimer 1
End If

End Sub


Sub Object_OnScriptExit

Object.KillTimer 1

End Sub

------------------------------
VOLUME DOWN CONTROL
------------------------------

Sub Object_OnMouseEnter

Object.SetTimer 1, 1

End Sub


Sub Object_OnMouseLeave

Object.KillTimer 1

End Sub


Sub Object_OnTimer1

If System.Volume > 0 Then
System.Volume = System.Volume - 1
Else
Object.KillTimer 1
End If

End Sub


Sub Object_OnScriptExit

Object.KillTimer 1

End Sub

------------------------------

I hope it works on your side too !! ... and it's really a pleasure !!
Let me know if it works ...

Thanks,
HaemOGObliN
Reply #3 Top
Wow Haemo! That works like a dream Ku!

Have MSN? We can trade Scripting tips on there.. almost every object I make now involves a script at some point even if its just positioning! If ya get chance Add Me [email protected] (old address.. too lazy to change it...)
Reply #4 Top
I would suggest you post scripts here: http://scratchpad.wikia.com/wiki/DesktopX

The overall goal of this Wiki is to provide DesktopX coders with a resource from which to draw on pre-made code snippets and tutorials. Theres no need to be trying to remember how to properly assemble an XmlHTTP object, or a basic File System Object. Instead, we offer a place to grab quick assemblies of code to be used in whatever projects necessary. Please feel free to contribute with tutorials and script segments!