|
|
#1 |
|
Junior Member
Join Date: Jul 2001
Posts: 25
|
maki "psuedo-slider" help
hi all. can someone out there tell me why this script doesn't work? it's supposed to cause a layer ("push") to slide across a 70 pixel area in time to the song which is playing.
#include "../../../lib/std.mi" global layer mybutton; global group mybuttongroup; global timer mytimer; system.onscriptloaded() { mybuttongroup = getscriptgroup(); mybutton = mybuttongroup.findobject("Push"); mytimer = new timer; mytimer.setdelay(1000); } system.onplay() { mytimer.start(); } mytimer.ontimer() { if (system.getplayitemlength() > 0) { float played = system.getposition(); played = played / system.getplayitemlength(); int setX = 70 * played; mybutton.resize(setX,20,20,20); mybutton.fx_update(); } } i realize there is nothing in there to bring the layer back to the beginning, but i'm just trying to get the guts work at this point. i also realize that i really don't know what i'm doing here, so it might be something stupid. in case it's important, "push" is defined in my player.xml simply as a 20 X 20 layer at x="100" and y="20". thanks in advance! |
|
|
|
|
|
#2 |
|
Nullsoft Newbie
(Moderator) Join Date: Mar 2001
Location: Sheffield, England
Posts: 5,568
|
the best way to set the co-ords of a layer is to use guiobject.setxmlparam("x",integertostring(setX));
or whatever DO NOT PM ME WITH TECH SUPPORT QUESTIONS |
|
|
|
|
|
#3 |
|
Major Dude
|
First off, you don't need the Fx_Update() line. Resize is not a layer fx function. So you can remove that.
I suspect that it doesn't work because you are doing floating point division and storing the value to an int. try doing something like this. code: or code: the point of all this being, that i don't think maki will convert the type for you. Consider it like typecasting in c++. int setx = (int)(70*played), its just that maki uses a function call (system.integer(double d)) to do the same thing. But like will fisher said, SetXmlParam might be a better choice, It really depends on you and how you want to do this and what you want to do with it latter. To me they both have good and bad points. |
|
|
|
|
|
#4 |
|
Junior Member
Join Date: Jul 2001
Posts: 25
|
thanks to both of you for the input. i'll have to try both methods to see which one works best.
|
|
|
|
![]() |
|
|||||||
| Thread Tools | Search this Thread |
| Display Modes | |
|
|