Hey guys, it's been a while.

Got a question I'm working on transfering my whole webpage to flash movie so its more interactive and what not. So far I've only got as far as adding in the banner and some of the navigation. I wanted each of these buttons on my page to animate by shaking violently when the user hovers the mouse over them. I did this so far by using motion tweens and mouse over functions in actionscript3. Now I actually got this to work perfectly for one button. However when i add a second button into the equation, the second button won't animate. Can anyone help me with this?

Also if any of you guys know of some great tutorials for beginers using flash CS5 it would also be a great help, I really want to master this program.

Dani AI

Generated

A focused checklist and a compact, reliable pattern for hover-triggered animations in Flash CS5 / AS3.

This thread shows the typical symptoms: one clip responds and another does not. Common, non-speculative places to check are symbol type (use MovieClip for timeline animation), whether the instance actually exists on the frame where the code runs, and whether children inside a clip are intercepting mouse events. pointed the discussion toward instance names; that is useful but not the whole story — the snippet below shows a robust way to attach the same handlers to many clips and reliably target the clip that was hovered.

var myButtons:Array = [btnA, btnB]; // instance names placed on the stage

for each (var b:MovieClip in myButtons) {
  b.buttonMode = true;
  b.mouseChildren = false; // prevents inner objects from stealing events
  b.addEventListener(MouseEvent.MOUSE_OVER, onOver);
  b.addEventListener(MouseEvent.MOUSE_OUT, onOut);
}

function onOver(e:MouseEvent):void {
  var clip:MovieClip = MovieClip(e.currentTarget); // currentTarget is the listener owner
  clip.gotoAndPlay("shake"); // prefer frame labels inside the clip
}

function onOut(e:MouseEvent):void {
  var clip:MovieClip = MovieClip(e.currentTarget);
  clip.gotoAndStop("idle");
}

Troubleshooting tips: verify unique instance names in the Properties panel; place the code on the same frame that contains the instances (or add listeners after you create the instances); prefer frame labels over raw numbers for readability; convert SimpleButton symbols to MovieClips if you need timeline animation; look for null-reference errors in the Output panel to detect timing/instance-name problems. If timeline-based clips still feel fragile, consider driving the shake with a tween library or programmatic position tweens instead of clip timelines.

Note: Flash/SWF workflows are legacy for web delivery; for new projects use modern HTML5/CSS3/JS approaches. For maintaining legacy SWF or AIR apps, the above pattern keeps multiple hover-animations predictable and easy to scale.

Recommended Answers

All 5 Replies

STill need help with the linking thing if anyone's got the help :-(

Heres the code if it helps at all

butt2.addEventListener(MouseEvent.MOUSE_OVER, fl_MouseOverHandler_12);

function fl_MouseOverHandler_12(event:MouseEvent):void
{
	// Start your custom code
	// This example code displays the words "Moused over" in the Output panel.
	trace("Moused over");
	gotoAndPlay(1);
	// End your custom code
}

keep in mind that this is only one of the two buttons or "tweens" there movie clips with in the swf. I used this same code on the first button which works but it won't work on the second.

Member Avatar for Member #334542

The above code is exactly fine, may be the naming convention would be a problem. Ensure that you have the name butt2 as an instance name of your button or movieclip.

thanks Raj you the man!

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.