[Last Call] Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 132
  • Last Modified:

Why does this button get hung up?

I'm using a script that I've used before without incident, you can see it below. But while it's never been a problem in the past, apparently there is some room for improvement as the animation will get hung up from time to time.

I've zipped up the fla file if you want to see it first hand. Any suggestions would be much appreciated. Bottom line: I need the animation to be flawless - it can't get hung up just because my user may quickly move their mouse from one button to the next.

Thanks!

Here's the link to the zip file: http://hihatwebdesign.com/Indelible.zip
onClipEvent(load){
 //is the cursor over the movie clip
 previouslyOver=false;
}
onClipEvent(enterFrame){
 currentlyOver=this.hitTest(_root._xmouse,_root._ymouse,true);
 //if there is a change, go to another frame
 if(!previouslyOver and currentlyOver){
 previouslyOver=true;
 this.gotoAndPlay("on");
 } else if (previouslyOver and !currentlyOver){
 previouslyOver=false;
 this.gotoAndPlay("off");
 }
}

Open in new window

0
brucegust
Asked:
brucegust
1 Solution
 
blue-genieCommented:
Hello. this is how i would do it.
firstly i wouldn't use onEnterFrame,
then i'd take the code off the movieclips and put in on the timeline
and i'd give my buttons instance names as per the array.

test it tell me how it goes.
also I'm guessing when they press it it must stay underlined.

blu
stop();
var btnArray:Array = new Array(bt1, bt2, bt3, bt4, bt5, bt6);
 
var currentObject:MovieClip = null;
 
function setUpButtons():Void {
	for (var i:Number = 0; i<btnArray.length; i++) {
		btnArray[i].onRollOver = function() {
			currentObject = this;
			trace("Current " + currentObject);
			currentObject.gotoAndPlay("on");
		}
		btnArray[i].onRollOut = function() {
			currentObject = this;
			trace("rollout object " + currentObject);
			currentObject.gotoAndPlay("off");
		}
	}
}
 
setUpButtons();

Open in new window

0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Tackle projects and never again get stuck behind a technical roadblock.
Join Now