dcsimg
A Flash Developer Resource Site

Results 1 to 4 of 4

Thread: need some help guys!

  1. #1
    Junior Member
    Join Date
    Jun 2002
    Posts
    9

    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.

  2. #2
    Senior Member of Toon Army lucky-black-cat's Avatar
    Join Date
    Aug 2002
    Location
    Benarraba Andalucia Spain
    Posts
    303
    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
    Last edited by lucky-black-cat; 11-07-2002 at 06:43 AM.
    http://www.property-in-the-sun.com
    Cheap Holidays in Andalucia Spain for Flash Programmers from 2005!

  3. #3
    Junior Member
    Join Date
    Jun 2002
    Posts
    9

    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 againafter 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.

  4. #4
    Senior Member of Toon Army lucky-black-cat's Avatar
    Join Date
    Aug 2002
    Location
    Benarraba Andalucia Spain
    Posts
    303
    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);
    }
    http://www.property-in-the-sun.com
    Cheap Holidays in Andalucia Spain for Flash Programmers from 2005!

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  




Click Here to Expand Forum to Full Width

HTML5 Development Center