dcsimg
A Flash Developer Resource Site

Results 1 to 6 of 6

Thread: [F8] onEnterFrame on Buttons - Please Help!!

  1. #1
    Senior Member frostbite's Avatar
    Join Date
    Aug 2003
    Location
    Colorado
    Posts
    666

    [F8] onEnterFrame on Buttons - Please Help!!

    Flash 8:

    I have defined the functions menuOver and menuOut like this


    Code:
    var theArray:Array ;
    theArray = new Array(50) ;
    
    var theCircle:MovieClip ;
    
    var maxYV = 50 ;
    c1yv = new Array(maxYV) ;
    for (var z:Number = 0 ; z < maxYV ; z++) {
    	c1yv[z] = ( Math.random() * 2 ) + 1 ;
    }
    	
    var menuOver:Function = function(mc_blank:MovieClip):Void {
    
    	mc_blank.gotoAndPlay(2);
    	
    	for (var a:Number = 0 ; a < 50 ; a++) {
    		theCircle = attachMovie("circle","circle"+_root.getNextHighestDepth(), a+_root.getNextHighestDepth()) ;
    		var randSize:Number = Math.random() * 30 ;
    		theCircle._xscale = randSize ;
    		theCircle._yscale = randSize ;
    		theCircle._x = Math.random() * (mc_blank._width + 20) + (mc_blank._x - 10);
    		theCircle._y = -1 * (Math.random() * ( 30)) ;
    		theArray[a] = theCircle ;
    	}
    
    	mc_blank.onEnterFrame = function() {
    	
    	for (var a:Number = 0 ; a < 50 ; a++) {
    	    theArray[a]._y += c1yv[a] ;
    		if ( theArray[a]._y > 30 ) {
    			theArray[a]._y = 0 ;
    		}
    	}
    	
    	}
    	
    	return;
    }
    
    var menuOut:Function = function(mc_blank:MovieClip):Void {
    	//function block here
    	
    	mc_blank.gotoAndPlay(6);
    	
    	mc_blank.onEnterFrame = function () {
    		for (var a:Number = 0 ; a < 50 ; a++) {
    			theArray[a]._y += c1yv[a] ;
    			if ( theArray[a]._y > 30 ) {
    				theArray[a]._y = 0 ;
    			}
    		    theArray[a]._alpha -= 10;
    			if ( theArray[a]._alpha <= 0 ) {
    				delete mc_blank.onEnterFrame;
    			}
    		}
    	}
    	
    	
    	return;
    }

    I then have 6 buttons I place code like so to call the functions:

    Code:
    on(rollOver) {
    	menuOver(mc_home);
    }
    on(rollOut) {
    	menuOut(mc_home);
    }
    The problem: If you rollover a button it does everything correctly, rollout and it will fade it out no problem. However, if you rollover another button before the fade out is finished, the fadeout is canceled on the previous button and the animation on the new button just fades out and stops, skipping the rollover on the new button entirely.

    The solution: ? No clue! please help!
    Yarrg Matey!

  2. #2
    Busy doing nothing Boris the Frog's Avatar
    Join Date
    Jan 2001
    Location
    Derby, UK
    Posts
    305
    It seems to be your menu over script is making settings to your variable theCircle.
    If you press another button won't theCircle now be involved with the other button?
    Maybe this is causing the problem.
    --------------------------------------------------
    ‘There is no emoticon to express how I am feeling’ - Comic Book Guy
    There's an effective, simple solution to carbon sequestration... it's called 'coal', so leave it alone!
    There's an effective, simple solution to carbon capture....it's called 'trees', so plant some!

  3. #3
    Senior Member frostbite's Avatar
    Join Date
    Aug 2003
    Location
    Colorado
    Posts
    666
    Yeah I think I understand why the problem is happening, I just can't think of a reasonable way to fix it.
    Yarrg Matey!

  4. #4
    Busy doing nothing Boris the Frog's Avatar
    Join Date
    Jan 2001
    Location
    Derby, UK
    Posts
    305
    can you create a blank movieClip to attach theCircle to in menuOVer then remove it after menuOut has finished?
    --------------------------------------------------
    ‘There is no emoticon to express how I am feeling’ - Comic Book Guy
    There's an effective, simple solution to carbon sequestration... it's called 'coal', so leave it alone!
    There's an effective, simple solution to carbon capture....it's called 'trees', so plant some!

  5. #5
    Senior Member frostbite's Avatar
    Join Date
    Aug 2003
    Location
    Colorado
    Posts
    666
    nope, same thing...
    Yarrg Matey!

  6. #6
    Busy doing nothing Boris the Frog's Avatar
    Join Date
    Jan 2001
    Location
    Derby, UK
    Posts
    305
    Sorry I meant circle not theCircle
    --------------------------------------------------
    ‘There is no emoticon to express how I am feeling’ - Comic Book Guy
    There's an effective, simple solution to carbon sequestration... it's called 'coal', so leave it alone!
    There's an effective, simple solution to carbon capture....it's called 'trees', so plant some!

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