-
need some help guys!
A friend of mine asked me to make him a banner.
He told me that he wants to have the number 7 appear randomly on the banner then slide to a predetermined(fixed) set of coordonates which are already known.(let's say x=100,y=100)
I managed to make the number 7 appear randomly :
onClipEvent (load) {
setProperty(c1, _x, random(648));
setProperty(c1, _y, random(60));
}
//c1 is the instance name for the movieclip which shows the number 7
But I can't manage to get it to slide to those coordonates.
I tried using motion tweening but it didn't do the trick so if there's anybody out there who can help me please show me the way to do this.(I really don't want to dissapoint my friend).
I have a hunch that there will be some serious actionscripting envolved.
-
Hi,
Try something like this.
Code:
onClipEvent (load) {
x7 = Math.random() *648;
y7 = Math.random() *60;
setProperty(c1, _x, x7);
setProperty(c1, _y, y7);
}
onClipEvent(enterFrame){
finalx = 100;
finaly = 100;
//between 0.65 & 0.55 for bounce
rate = 0.6;
diffx = x7 - finalx;
diffy = y7 - finaly;
x7 = x7 - (diffx/rate);
y7 = y7 - (diffy/rate);
setProperty(c1, _x, x7);
setProperty(c1, _y, y7);
}
Hope this helps
If you don't like the 'bounce effect' change rate to say 10 for a smooth slide into position
-
One more question
Yes it works very well but it brings me to anothe problem.
The banner will contain several movieclips.Which sould play
on after another.The 777 thingy being the first.
Question:how can I make the three sevens dissapear after they have
reached the finalx & finaly coordonates, and how can I make the animation start all over again:(after all the other movies have finished playing.
I tried something like using setInterval(restart,20416)
restart=function()
{
x7 = Math.random() *468;
y7 = Math.random() *60;
setProperty(c1, _x, x7);
setProperty(c1, _y, y7);
finalx = 170;
finaly = 30;
}
This indeed restarted the animation of the three sevens.But after
a 3 consecutive replays of the banner a delay started to occur and
the three sevens started to appear later and later than expected.
I'm really stuck on this one.
:mrpimp:
-
Hi
Heres a work around that uses getTimer()
Hope it helps.
Code:
onClipEvent (load) {
x7 = Math.random() *648;
y7 = Math.random() *60;
setProperty(c1, _x, x7);
setProperty(c1, _y, y7);
finalx = 100;
finaly = 100;
counter = 0;
reset = FALSE;
interval = 20416;
}
onClipEvent(enterFrame){
time = getTimer();
if(counter< Math.floor(time/interval)){
counter++;
reset = TRUE;
}
if(reset){
x7 = Math.random() *648;
y7 = Math.random() *60;
setProperty(c1, _x, x7);
setProperty(c1, _y, y7);
finalx = 100;
finaly = 100;
reset = FALSE;
}
//between 0.65 & 0.55 for bounce
rate = 0.6;
diffx = x7 - finalx;
diffy = y7 - finaly;
x7 = x7 - (diffx/rate);
y7 = y7 - (diffy/rate);
setProperty(c1, _x, x7);
setProperty(c1, _y, y7);
}