Page 1 of 1

Need Help/Suggestion with Track Slider Control

PostPosted: Wed May 09, 2012 10:28 pm
by LauraMarie
Hello everyone!

I hate to make my first post here a request for help but I have been stuck on this for a couple days now and was hoping that maybe an experienced Neobooker may have a suggestion.

I am building an application that employs a ruler that measures screen pixels. The ruler starts at 0y and ends at 1200y. The length of the ruler GIF is 1160px with 760px showing on screen with the remaining hiding off the bottom of the screen. When the user moves the trackbar it needs to create a result that starts at 40px and as the slider is advanced subtracts value until it reaches a maximum value of -420.

The calculated result should move up the ruler GIF as the user moves the slide control downward. Once the maximum value is reached, the GIF file will be moved to to the screen position of -380y which would allow the bottom of the ruler to be in view.

I hope this makes sense?
Here is a screen shot of the interface which may help clarify.


Seems like a simple script but I am having trouble making the slider calculate the right result. Moving the slider up and down should move the ruler at the same time as the value changes..

I would really appreciate any help anyone can offer.

PostPosted: Thu May 10, 2012 4:46 am
by Gaev

1) Your image is not showing.

2) Perhaps you can post the General Properties (minimum, maximum values etc.) of the Track Bar object ... as well as your script (Value Changed, Value Changing etc.).

PostPosted: Thu May 10, 2012 8:20 am
by LauraMarie
Thanks Gaev for your reply.

I really don't have much to post in the way of an action script but this is what I have tried but has resulted in an Error result.

In the Page Action: SetVar " [CalcPos]" "430"

My picture object (ruler) is placed at:
Code: Select all
width: 41px
height: 1160

Code: Select all
Minimum Value: 0

Maximum Value: 470

Initial Value: 470

Result Variable: [SlidePos]

Value Changing
Code: Select all
Math "[SlidePos] -" "[CalcPos]" "[RulerPos]"

This initially will result in the value of [RulerPos] = 40
what I need is the result of [RulerPos] to decrease as the slider is moved down until the maximum value of -440 for [RulerPos] is achieved at the end of the slider position.

The desired result would be to use the Move Object action with these parameters:
Code: Select all
 MoveObject "right_ruler" "1297" "[RulerPos]"

Does this help?

PostPosted: Thu May 10, 2012 9:10 am
by Gaev

Thank you for the details.

Working backwards ...

1) MoveObject "right_ruler" "1297" "[RulerPos]" is correct ... I assume this is part of the TrackBar object's on Changing event script.

2) Math "[SlidePos] -" "[CalcPos]" "[RulerPos]" seems to have some typographical errors ... assuming you meant ... Math "[SlidePos]-[CalcPos]" "0" "[RulerPos]" ... this should work ... but when [SlidePos] reaches 0 ... the answer in [RulerPos] will be -430 (i.e. 0 minus 430) and not -440

3) Initially, the answer will be 40 (i.e. 470 minus 430) ... which seems to jive with the initial Y position of 40.

So, can you tell us what IS happening when you slide the Track Bar ? ... is the image not being repositioned at all ? ... is it being repositioned at a different Y position ?

Also, have you activated the Debugger to see what the values of the different variables are as you slide the Track Bar ?

PostPosted: Thu May 10, 2012 10:20 am
by LauraMarie
When I first move the trackbar the image does slightly move upwards 40 px but then it stops and I get an error under the value of [RulerPos]

What I need is real time movement of the ruler up and down with the ValueChanging event because if I put the MoveObject action ValueChanged event then the movement would not take place until the user releases the trackbar.

It needs to be able to both add and subtract the [RulerPos] value depending if the user is sliding the bar up or down. Again, I need this all to take place under the ValueChanging event so the user can move the ruler up and down with the slider interactively.

This seems to be a challenge but I am sure there must be some way t do it?

BTW: I am watching these values through the debugger in testing.

Thanks for your help!

PostPosted: Thu May 10, 2012 11:40 am
by Gaev

I looked at the pub you emailed me.

1) A number of images were missing ... as they were pointing to some folders in your computer's local disk.

2) The screen size was too big for my monitor ... so I reduced the X position of TrackBDesignGroup to 938 (instead of 1338).

3) But the main problem was that your Math command was incorrectly specified ... look at my comment in the previous post ... when I made the change, things appeared to work.

4) Unlike your statement in your second post ... the PageEnter section code was empty ... did not have the SetVar " [CalcPos]" "430" command in it.

Make the change to the Math command and insert the command in the PageEnter section ... and see if it works as expected.

PostPosted: Thu May 10, 2012 1:02 pm
by LauraMarie
Sorry about the missing image files. I used Thunderbird to attach those images to the email and it must have only attached the path? Anyway, I recreated what I am working on to another pub file since it is part of a much larger pub of the application. I forgot to add the default value for [CalcPos] to the test pub but it is present in mine. .

I am not at home now to work on the pub since I am at work and posting this from my iPhone but the tricky part is to get the value to change up and down based on the track bar. I was thinking of some kind of "If" statement checking the current [RulerValue] and either adding or substracting from the [CalcPos] value based in the [SlidePos] the move the ruler either up or down?

Like I said, not as simple as it appears.

PostPosted: Thu May 10, 2012 3:29 pm
by Gaev

I repeat ...

But the main problem was that your Math command was incorrectly specified
... make sure it is ...
Code: Select all
Math "[SlidePos]-[CalcPos]" "0" "[RulerPos]"

PostPosted: Thu May 10, 2012 5:31 pm
by LauraMarie

Yes, I have corrected the math object and it is working but it's not very smooth. If you slide it slowly it works okay but if you move it quicky it does not give the correct value until you move it again just a little.

I think the problem is for every pixel you move a math calculation takes place and variables are updated which is a lot of overhead. What I may do is create a secondary script in the Value Changed action that checks and corrects the position for when the user releases the track bar. This is not a major function of my application but one that needs to work correctly and give the correct result.

Thanks so much for your help.
I really appreciate it! :)

PostPosted: Mon May 14, 2012 10:55 am
by Neosoft Support
Yes, I have corrected the math object and it is working but it's not very smooth. If you slide it slowly it works okay but if you move it quicky it does not give the correct value until you move it again just a little.

Try putting the same code in the Track Bar's "Value Changed" and "Value Changing" actions.