|
Post by dk on Jul 15, 2014 2:03:27 GMT
Hello, I am trying to follow the Hippo turorial on setting the speed of a project so that it plays at a constant for all browsers. www.youtube.com/watch?v=LgdcR6us6f4#t=260I am having a hard time trying to copy the code as it is in low res and I am getting an error message so I must be writing something wrong. I am trying to set a background to scroll at a constant speed in all browsers but the error message I am getting is this: Error2: On Update: A "new" was expected. Here is the On Update code I used. var NewTime= Date(); var Change=NewTime.getTime()-LastTime.getTime(); LastTime = NewTime; BG.X+=Dir*Change*Speed; Here is the General code I used. var Dir=0; var.LastTime=new Date(); var Speed=.1; Can someone please tell me where I went wrong? Thanks dk
|
|
|
Post by Hippani on Jul 15, 2014 8:03:39 GMT
var.LastTime
should be...
var LastTime
(no . )
|
|
|
Post by dk on Jul 15, 2014 8:28:51 GMT
Hi Gordon. I changed the var and still getting error. Error 1: On Update a "new" was expected
My General code:
var Dir=0; var LastTime=new Date(); var Speed= 1;
The entire Update code:
var NewTime= Date(); var Change=NewTime.getTime()-LastTime.getTime(); LastTime = NewTime; BG.X+=Dir*Change*Speed; DOOR.X+=Dir*Change*Speed; ENTER.X+=Dir*Change*Speed; if(DOOR.X>(300-50) && DOOR.X<(300+50)){ ENTER.Visible=true; } else{ ENTER.Visible=false; }
Not sure what's happening....without the code it works fine. I also rechecked the syntax for errors with Jlint and it looks ok?
dk
|
|
|
Post by Hippani on Jul 15, 2014 9:57:17 GMT
Is there any chance you could send me the .hani to test?
|
|
|
Post by dk on Jul 15, 2014 10:06:11 GMT
Hi Gordon, Sure...thanks for looking. It's most likely my error seeing I am fumbling my way through things. Also the Background (Script ID BG) has stopped scrolling as well. TUR-KEY004PROB.hani (663.15 KB) dk
|
|
|
Post by Hippani on Jul 15, 2014 12:21:06 GMT
Sorry I missed this looking at your code.
var NewTime=new Date();
|
|
|
Post by Hippani on Jul 15, 2014 13:19:22 GMT
Also, this code has been updated since then, due to a new feature. You no longer need to calculate change. The value TimeChange is included automatically.
BG.X+=Dir*TimeChange*Speed; DOOR.X+=Dir*TimeChange*Speed; ENTER.X+=Dir*TimeChange*Speed; if(DOOR.X>(300-50) && DOOR.X<(300+50)){ ENTER.Visible=true; } else{ ENTER.Visible=false; }
|
|
|
Post by dk on Jul 15, 2014 14:07:55 GMT
Hi Gordon, Fantastic! Many thanks it works perfectly now.
Regards dk
|
|