Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 4 of 4
  1. #1
    Regular Coder
    Join Date
    Aug 2005
    Posts
    365
    Thanks
    7
    Thanked 1 Time in 1 Post

    Question How to add replay button to this animation?

    Please have a look at the below action script, I got it somewhere on the internet. The transition is working fine but it stops after playing for 1 time. I wanna add a Replay Button so I could be able to play the animation again & again. Please help me how can I add a replay button?

    Here is the code...
    Code:
    //Declare variables
    xspacing = box._width;
    yspacing = box._height;
    depth = 0;
    box._visible = 0;
    smoothness = 90;
    //Calculate positions and values
    amH = Math.ceil(image._width/box._width);
    amV = Math.ceil(image._height/box._height);
    border._height = image._height+1;
    border._width = image._width+1;
    border._x = image._x-0.5;
    border._y = image._y-0.5;
    //Create grid
    for (i=0; i<amH; i++) {
    	for (var k = 0; k<amV; k++) {
    		box.duplicateMovieClip("box"+depth, depth);
    		cur = this["box"+depth];
    		cur._x = image._x+(xspacing*i);
    		cur._y = image._y+(yspacing*k);
    		depth++;
    	}
    }
    function fadeOut(startboxnr, speed) {
    	fadeMC(startboxnr, speed);
    }
    function fadeMC(mcnr, speed) {
    	this["box"+mcnr].onEnterFrame = function() {
    		this._alpha -= speed;
    		if (this._alpha<=smoothness) {
    			this.onEnterFrame = null;
    			continueFade(this, speed);
    			mcnr += 1;
    			fadeOut(mcnr, speed);
    		}
    	};
    }
    function continueFade(mc, speed) {
    	mc.onEnterFrame = function() {
    		this._alpha -= speed;
    		if (this._alpha<=0) {
    			delete this.onEnterFrame;
    		}
    	};
    }
    fadeOut(0, 5);

  • #2
    Senior Coder gnomeontherun's Avatar
    Join Date
    Sep 2007
    Location
    Houston
    Posts
    2,846
    Thanks
    10
    Thanked 238 Times in 229 Posts
    You need something to reset the alpha property. This is a simple reset if you put it on a button to reset the visibility to 100 for box0.

    Code:
    on (release)
    {
    box0._alpha = 100;
    }
    jeremy - gnomeontherun
    Educated questions often get educated answers, and simple questions often get simple answers.

  • #3
    Regular Coder
    Join Date
    Aug 2005
    Posts
    365
    Thanks
    7
    Thanked 1 Time in 1 Post
    Where to put that code? When I paste your code at the bottom of the action script window & then try to run, flash gives me a warning that such command is only associated with the buttons. Also, animation doesn't work.

    Please help, I am a newbie & trying to replay the animation

  • #4
    Senior Coder gnomeontherun's Avatar
    Join Date
    Sep 2007
    Location
    Houston
    Posts
    2,846
    Thanks
    10
    Thanked 238 Times in 229 Posts
    Right, that is because it should go on a button instead. Make a button that says replay or something, then attach this code to it.
    jeremy - gnomeontherun
    Educated questions often get educated answers, and simple questions often get simple answers.


  •  

    Posting Permissions

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