A Flash Developer Resource Site

Results 1 to 9 of 9

Thread: [RESOLVED] Smooth Button Animation - onRelease??

  1. #1
    Member
    Join Date
    Jul 2008
    Posts
    73

    resolved [RESOLVED] Smooth Button Animation - onRelease??

    I've been following the tutorial "Creating Smooth Button Animation in Flash": http://www.republicofcode.com/tutori...ttonanimation/

    As with most menus, when the button is selected it needs to stay highlighted so the user knows which section they are in. The tutorial left this bit out.

    I've been unsuccessful so far. Can anyone help finish it?

    Code:
    import mx.transitions.Tween;
    import mx.transitions.easing.*;
    
    for (i=1; i<=4; i++) {
    	var current_btn = this["my"+i+"_btn"];
    
    	current_btn.onRollOver = function() {
    		var currentAlpha = this.cover_mc._alpha;
    		var myHoriTween:Tween = new Tween(this.cover_mc, "_alpha", Strong.easeOut, currentAlpha, 0, 0.5, true);
    	};
    
    	current_btn.onRollOut = function() {
    		var currentAlpha = this.cover_mc._alpha;
    		var myHoriTween:Tween = new Tween(this.cover_mc, "_alpha", Regular.easeIn, currentAlpha, 100, 0.5, true); 
    	};
    
    	current_btn.onRelease = function() {
    		//code here
    	};
    }
    I've attached the .fla
    Attached Files Attached Files
    Last edited by Playdoe; 01-20-2010 at 09:19 AM.

  2. #2
    Senior Member vinayak.kadam's Avatar
    Join Date
    Oct 2006
    Location
    gotoAndPlay("Pune");
    Posts
    831
    Can you please 'Save As' your FLA in CS3 and re-upload. Not everybody here posses Flash CS4 and above!
    As ever,
    Vinayak Kadam

  3. #3
    Member
    Join Date
    Jul 2008
    Posts
    73
    Reuploaded as CS3.

  4. #4
    :
    Join Date
    Dec 2002
    Posts
    3,518
    Code:
    import mx.transitions.Tween;
    import mx.transitions.easing.*;
    
    var iscurrent = this["my"+1+"_btn"];
    var currentAlpha = iscurrent.cover_mc._alpha;
    var myHoriTween:Tween = new Tween(iscurrent.cover_mc, "_alpha", Strong.easeOut, currentAlpha, 0, 0.5, true);
    
    for (i=1; i<=4; i++) {
    	var current_btn = this["my"+i+"_btn"];
    
    	current_btn.onRollOver = function() {
    		var currentAlpha = this.cover_mc._alpha;
    		var myHoriTween:Tween = new Tween(this.cover_mc, "_alpha", Strong.easeOut, currentAlpha, 0, 0.5, true);
    	};
    
    	current_btn.onRollOut = function() {
    		if (iscurrent != this) {
    			var currentAlpha = this.cover_mc._alpha;
    			var myHoriTween:Tween = new Tween(this.cover_mc, "_alpha", Regular.easeIn, currentAlpha, 100, 0.5, true);
    		}
    	};
    
    	current_btn.onRelease = function() {
    		//code here
    		var currentAlpha = iscurrent.cover_mc._alpha;
    		var myHoriTween:Tween = new Tween(iscurrent.cover_mc, "_alpha", Regular.easeIn, currentAlpha, 100, 0.5, true);
    		iscurrent = this;
    	};
    }

  5. #5
    Member
    Join Date
    Jul 2008
    Posts
    73
    Ah, the saviour returns. Thank you Dawsonk.

  6. #6
    Member
    Join Date
    Jul 2008
    Posts
    73
    Dawsonk, I'm trying to get exactly the same result for the main menu page as with the gallery http://board.flashkit.com/board/showthread.php?t=808542. So when the user selects the category it shows the preloader, then fades out the current gallery and fades in the new one.

    The one difference is on entering the site to not load a gallery into the container but a welcoming swf.

    The gallery was coded for xml. I'm struggling to alter it so it works with the on stage buttons.

    I've attached the main menu page and some dummy swfs and also the original Gallery file. Would you be able to take a look at it for me?
    Last edited by Playdoe; 01-21-2010 at 07:17 AM.

  7. #7
    :
    Join Date
    Dec 2002
    Posts
    3,518
    Dont' forget to give MC instances a name... (holder2)
    Code:
    var mcl:MovieClipLoader = new MovieClipLoader();
    var mclL:Object = new Object();
    mcl.addListener(mclL);
    
    import mx.transitions.Tween;
    import mx.transitions.easing.*;
    
    var iscurrent;
    var swfArray = ["welcome.swf", "gallery.swf", "photography.swf", "graphics.swf", "contact.swf"];
    var currentAlpha = iscurrent.cover_mc._alpha;
    var myHoriTween:Tween = new Tween(iscurrent.cover_mc, "_alpha", Strong.easeOut, currentAlpha, 0, 0.5, true);
    
    for (i=1; i<=4; i++) {
    	var current_btn = this["my"+i+"_btn"];
    	current_btn.num = i;
    	current_btn.onRollOver = function() {
    		var currentAlpha = this.cover_mc._alpha;
    		var myHoriTween:Tween = new Tween(this.cover_mc, "_alpha", Strong.easeOut, currentAlpha, 0, 0.5, true);
    	};
    
    	current_btn.onRollOut = function() {
    		if (iscurrent != this) {
    			var currentAlpha = this.cover_mc._alpha;
    			var myHoriTween:Tween = new Tween(this.cover_mc, "_alpha", Regular.easeIn, currentAlpha, 100, 0.5, true);
    		}
    	};
    
    	current_btn.onRelease = function() {
    		callFullImage(this.num);
    		var currentAlpha = iscurrent.cover_mc._alpha;
    		var myHoriTween:Tween = new Tween(iscurrent.cover_mc, "_alpha", Regular.easeIn, currentAlpha, 100, 0.5, true);
    		iscurrent = this;
    	};
    }
    var j = 1;
    var target_MC;
    loader._visible = false;
    function callFullImage(myNumber) {
    	if (j == 1) {
    		target_MC = holder1;
    		j = j+j;
    	} else {
    		target_MC = holder2;
    		j = 1;
    	}
    	myURL = swfArray[myNumber];
    	var fullClipLoader = new MovieClipLoader();
    	var fullPreloader = new Object();
    	fullClipLoader.addListener(fullPreloader);
    	fullClipLoader.loadClip(+myURL,target_MC);
    	fullPreloader.onLoadStart = function() {
    		loader._visible = true;
    	};
    	fullPreloader.onLoadProgress = function() {
    		filesize = target_MC.getBytesTotal();
    		loaded = target_MC.getBytesLoaded();
    	};
    	fullPreloader.onLoadComplete = function() {
    		loader._visible = false;
    		if (j == 1) {
    			target_MC._alpha = 0;
    			var fadeOut1:Tween = new Tween(holder1, "_alpha", Regular.easeIn, 100, 0, 0.5, true);
    			fadeOut1.onMotionFinished = function() {
    				setTimeout(display,50);
    				function display() {
    					var fadeIn:Tween = new Tween(target_MC, "_alpha", Regular.easeIn, 0, 100, 0.5, true);
    				}
    			};
    		} else {
    			target_MC._alpha = 0;
    			var fadeOut2:Tween = new Tween(holder2, "_alpha", Regular.easeIn, 100, 0, 0.5, true);
    			fadeOut2.onMotionFinished = function() {
    				setTimeout(display2,50);
    				function display2() {
    					var fadeIn2:Tween = new Tween(target_MC, "_alpha", Regular.easeIn, 0, 100, 0.5, true);
    				}
    			};
    		}
    	};
    }
    callFullImage(0);

  8. #8
    Member
    Join Date
    Jul 2008
    Posts
    73
    That's perfect. Thank you so much. My website is in sight

  9. #9
    Senior Member vinayak.kadam's Avatar
    Join Date
    Oct 2006
    Location
    gotoAndPlay("Pune");
    Posts
    831
    Dawsonk is really great....good work by him...I appreciate!
    As ever,
    Vinayak Kadam

Tags for this Thread

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