Solved

Why does this button get hung up?

Posted on 2009-07-14
1
127 Views
Last Modified: 2013-11-11
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
Comment
Question by:brucegust
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
1 Comment
 
LVL 39

Accepted Solution

by:
blue-genie earned 500 total points
ID: 24856939
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

Instantly Create Instructional Tutorials

Contextual Guidance at the moment of need helps your employees adopt to new software or processes instantly. Boost knowledge retention and employee engagement step-by-step with one easy solution.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This is a very simple example to help those of you who are still migrating from AS2 to AS3 understand the redesigned event model in AS3. In AS2.0, event functions (that is, the function to be performed when an event is fired) were stored as a pro…
Recently, I was asked to recommend a tracking system to be implemented on a clients website. As the entire site was built on flash, my first thought was to suggest custom built tracking system. However, our company at that point of time didn't h…
In this tutorial viewers will learn how to create a basic motion tween animation in Flash Open a new document in Flash: Draw/import an image: Press CTRL + F8 to convert it into a graphic symbol: Select a frame (how long you want the tween to last): …
The goal of the tutorial is to teach the user how to select which audio input to use. Once you have an audio input plugged into the laptop or computer, you will go into the audio input settings and choose which audio input you want to use.

707 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question