PDA

View Full Version : Repeat until button released


zipzaptrump
12-27-2005, 09:53 AM
Is there a way to have a button "repeat" an action like turning up the video players volume while it is being held down and then stop when the button is released? I am looking to be able to turn up the volume gradualy until the button is released thus keeping from having to "click" "click" "click"......

Can you please give an example if possible? Thanks

P.S I would like to refrain from using a slider.
Thanks!! :)

yosik
12-27-2005, 10:25 AM
One way would be to use Flash .
Another would be to use Worm's Mouse.dll. There are a few posts about it on the forum.

Yossi

Worm
12-27-2005, 11:21 AM
No need for the DLL in v6.

yosik
12-27-2005, 12:19 PM
Right Worm. I forgot about this Page Event. :yes
Thanks

Yossi

zipzaptrump
12-28-2005, 12:08 AM
Wow! Thanks for the fast reply. I'll give er a try and let you know if this works for me.
Cool Beans Man.. :)

zipzaptrump
12-28-2005, 12:34 AM
Thanks yosik and worm.
One last question cause I'm a total nube.
How do I get it to actually controll the volume?
The buttons work fine but don't controll the volume on my video.
Is there some extra code I need to add?
Thank's for your time.

zipzaptrump
12-28-2005, 12:51 AM
I tried adding this to the buttons on click event.

MediaPlayer.SetVolume("Plugin1", MediaPlayer.GetVolume("Plugin1")+nVol);

It does controll the volume but sets it to 100% as soon as I click.
Am I even close? Thanks for your time.

Mina
12-28-2005, 01:13 AM
One way would be to use Flash .
Another would be to use Worm's Mouse.dll. There are a few posts about it on the forum.

Yossi

Sorry to interupt but which thread holds this dll ?
I cannot follow worm's example because i use the timer event for other functions.

zipzaptrump
12-28-2005, 09:02 AM
Worm, I just totally blew my own mind.
Why you ask? Well, I have absolutely no programming knowledge period outside some decent html skills that were self taught. Can you believe I figured out what I needed to do! Check this out.....
I added this to your code in the "on timer"

result = nVol
MediaPlayer.SetVolume("Plugin1", result);

result = MediaPlayer.GetVolume("Plugin1");
Label.SetText("Label1", result)

Totally works. Hey pat myself on the back man!
Thanks for the help and the boosted confidence!

Worm
12-28-2005, 09:15 AM
:yes :yes Awesome Job! :yes :yes

It is amazing what one can do with AMS with little or no programming experience. To me, it is one of the greatest marvels of the application. For instance, you imply you have little or no programming/scripting experience, yet you were able to figure out what needed to be done. I, on the other hand, do quite a bit of programming/scripting in my daily life, yet am challenged by the very same software.

Worm
12-28-2005, 09:17 AM
Sorry to interupt but which thread holds this dll ?
I cannot follow worm's example because i use the timer event for other functions.

Use a series of IF statement in the On Timer to allow for multiple events. Otherwise you'll be cutting the use of the timer significantly by limiting to one purpose.

zipzaptrump
12-28-2005, 09:28 AM
Worm, Thanks for the complement. :yes
The only thing I have noticed with my adding to your great example is that now if I grab the slider on windows media player it's stuck it refuses to move as if the code is forcing it back to 50% volume. Can you figure out why? That is beyond my skill as of now.
Thanks again keep up the good work.

Worm
12-28-2005, 09:37 AM
More than likely its the positioning of your statements in the On Timer event. The idea is to only set the volume in the On Timer event when the mouse button is down on the button. If you have the SetVolume action outside of the ifs then the volume is being set everytime the On Timer event is fired.

See the attached example.

zipzaptrump
12-28-2005, 09:48 AM
More than likely its the positioning of your statements in the On Timer event. The idea is to only set the volume in the On Timer event when the mouse button is down on the button. If you have the SetVolume action outside of the ifs then the volume is being set everytime the On Timer event is fired.

See the attached example.
I totally forgot to think about the fact that the scripting will do what it's told in numerical order. I'll study your example later when I get a chance. :yes

Hopefully this thread will be very helpful to people that ran into a similar problem as it is a great solution and a great learning example for us all.
Thanks again you are da man!

Intrigued
12-28-2005, 05:18 PM
Worm, for sure, often goes above and beyond. He's an asset to any organization I'm sure!

Corey
12-28-2005, 05:34 PM
if I were an IT manager I'd pay whatever I had to in order to get Worm on board. :yes

stickck
12-28-2005, 06:01 PM
Use a series of IF statement in the On Timer to allow for multiple events. Otherwise you'll be cutting the use of the timer significantly by limiting to one purpose.
THANKS WORM! i didnt know that. i've been only using the timer event for only 1 item.

alright! im done for the day. i learned my 1 new thing.


chris

Mina
12-29-2005, 06:48 AM
Use a series of IF statement in the On Timer to allow for multiple events. Otherwise you'll be cutting the use of the timer significantly by limiting to one purpose.

I already considered doing that but the problem is that i have to set the timer every 1 sec. I will figure something out, Thanks

Worm
12-29-2005, 07:04 AM
If you are needing the timer to fire every second for one event, and every 100 ms for another, use a simple counter to fire both

On Show Event

Page.StartTimer(100);


On Timer Event

if ctr == nil then
ctr = 0;
end

ctr=ctr+1;

if Math.Floor(ctr/2) == ctr/2 then
--It's been 200ms
end

if Math.Floor(ctr/5) == ctr/5 then
--It's been 500ms
end

if ctr==10 then
--It's been a second
ctr=0;
end

Mina
12-29-2005, 06:47 PM
If you are needing the timer to fire every second for one event, and every 100 ms for another, use a simple counter to fire both

On Show Event

Page.StartTimer(100);


On Timer Event

if ctr == nil then
ctr = 0;
end

ctr=ctr+1;

if Math.Floor(ctr/2) == ctr/2 then
--It's been 200ms
end

if Math.Floor(ctr/5) == ctr/5 then
--It's been 500ms
end

if ctr==10 then
--It's been a second
ctr=0;
end


Perfect :yes

Intrigued
12-29-2005, 08:07 PM
I never realized the value of the use of Math.Floor() in this respect. Worm is an AMS God stuck in a human body, I just know it.

:D

Worm
12-29-2005, 10:21 PM
There are quite a few ways to do that. You could use Math.Mod too

if Math.Mod(ctr/2)==0 then, etc...