A Flash Developer Resource Site

Results 1 to 3 of 3

Thread: movie clip as a button in AS2

Threaded View

  1. #3
    Junior Member
    Join Date
    May 2009
    Location
    London
    Posts
    23
    Hello Embussy, to have different buttons spining the wheel, I have divided up the code, so you have two functions, over() and out(), check it out below. I have also included an fla attachment with a working example of two buttons calling the same wheel to spin. I put some variables for you to play around with, increase speed etc.

    This is a very simple and quick code, will work for small projects, but cannot be used to launch a rocket or anything like that.lol enjoy, hope it helps :

    Code:
    var startspeed    = 30;
    var maxSpeed     = 60;
    var halt             = 0;
    var accelerateBy = 1; //this will speed up speed up spinning as you increase
    var applyBrakeBy = 1; //play around with this to increase breaking
    
    btn1.onRollOver = over;
    btn1.onRollOut  = out;
    
    btn2.onRollOver = over;
    btn2.onRollOut  = out;
    
    function over()
    {
    	onEnterFrame = function()
    	{
    		startspeed += accelerateBy;
    		wheel_mc._rotation += startspeed;
    
    		if(startspeed >= maxSpeed)
    		{
    			startspeed = maxSpeed;
    		}
    	}
    	
    }
    
    function out()
    {
    	onEnterFrame = function()
    	{
    		startspeed -= applyBrakeBy;
    		wheel_mc._rotation += startspeed;
    		
    		if(startspeed <= halt)
    		{
    			startspeed = halt;
    			delete this.onEnterFrame;
    		}
    	}
    	
    }
    Attached Files Attached Files

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