A Flash Developer Resource Site

Results 1 to 3 of 3

Thread: movie clip as a button in AS2

  1. #1
    Junior Member
    Join Date
    Apr 2009
    Posts
    19

    movie clip as a button in AS2

    So I want to make some movie clips function as buttons to load some external swfs. I have this action script on the mc's:

    on (release)
    {
    loadMovie("Chuck.swf", "motionmc");
    }

    It was working when it was a button, but now nothing happens?

  2. #2
    Junior Member
    Join Date
    May 2009
    Location
    London
    Posts
    23
    Hello good_snow,

    Did you convert the button to a movie clip, if so then you have ended up with a button inside a movie clip, so your code: loadMovie("Chuck.swf", "motionmc"); which is loading chuck.swf into motionmc will not find "motionmc" because the button has changed level.

    To solve your problem either way, go into "motionmc" and place this inside it: trace(this); and run your movie;

    copy what ever was traced e.g _root.motionmc, and go back into your movie button, you want to be inside the movie button itself and do this, so double click the movie button to go into it, put this on the timeline:-

    Code:
    this.onRelease = function()
    {
    //replace _root.motionmc with what you got from your trace
    
    loadMovie("Chuck.swf", "_root.motionmc");
    }

  3. #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