troubleshooting Question

Swap Depths in AS3

Avatar of Karessa
Karessa asked on
Adobe Flash
4 Comments1 Solution945 ViewsLast Modified:
The code in the function  rollSection(evtObject:MouseEvent)  is intended to make the object in question come to the highest depth, but it doesn't work! Is it because the objects are buttons? If so, can I cast them as movie clips?


stop();

var thisDepth:Number;

//handle events for buttons… about, home, portfolio are labels names in timeline
stage1_btn.addEventListener(MouseEvent.CLICK, clickSection);
stage2_btn.addEventListener(MouseEvent.CLICK, clickSection);
stage3_btn.addEventListener(MouseEvent.CLICK, clickSection);
stage4_btn.addEventListener(MouseEvent.CLICK, clickSection);
stage5_btn.addEventListener(MouseEvent.CLICK, clickSection);
stage1_btn.addEventListener(MouseEvent.MOUSE_OVER, rollSection);
stage2_btn.addEventListener(MouseEvent.MOUSE_OVER, rollSection);
stage3_btn.addEventListener(MouseEvent.MOUSE_OVER, rollSection);
stage4_btn.addEventListener(MouseEvent.MOUSE_OVER, rollSection);
stage5_btn.addEventListener(MouseEvent.MOUSE_OVER, rollSection);
function clickSection(evtObj:MouseEvent) {
	trace("The "+evtObj.target.name+" button was clicked!");
	//go to the section clicked on...
	gotoAndStop(evtObj.target.name);
}

function rollSection(evtObject:MouseEvent) {
	trace("The "+evtObject.target.name+" button was rolled!");
	//bring to the highest depth
	this.setChildIndex(evtObject.target.name,this.numChildren-1);
}
ASKER CERTIFIED SOLUTION
Join our community to see this answer!
Unlock 1 Answer and 4 Comments.
Start Free Trial
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 1 Answer and 4 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros