|
Post by Hippani on Mar 5, 2013 9:22:31 GMT
This is an example of how to make a button expand when you mouse over and contract when you mouse out. It requires some JavaScript knowledge to understand. Download .hani ProjectDemoCreate a button and turn off "Use Timeline", set it's script Id to Button1. In the movie -> General script, create a state variable and a way to track the time. var Button1State=0; var LastTime=new Date();
In the button mouse over: Button1State=1; In the button mouse out: Button1State=2; In the movie -> On Update script, calculate the width of the button depending on the state and the amount of time that has passed. //Calculate the change in time since the last update var NewTime=new Date(); var Change=.1*(NewTime.getTime()-LastTime.getTime()); LastTime=NewTime;
//Expand the button on state=1 if(Button1State==1&&Button1.Width<=120){ Button1.Width+=Change; Button1.Height+=Change; } //Contact the button on state=2 if(Button1State==2){ if(Button1.Width>=100){ Button1.Width-=Change; Button1.Height-=Change; }else{ Button1State=0; } }
|
|
|
Post by Vohaul on Mar 5, 2013 14:38:19 GMT
perfect, ill play with it tonight
|
|
|
Post by Vohaul on Mar 5, 2013 18:31:28 GMT
is it easy to control how fast or slowly it expands / contracts?
|
|
|
Post by Hippani on Mar 6, 2013 9:17:22 GMT
Yes,
var Change=.1*(NewTime.getTime()-LastTime.getTime());
.1 is the speed.
|
|