PDA

View Full Version : AS3 controlling movieclips.



squarelight
December 7th, 2007, 09:28 PM
I have a flash project that has several movieclips on the main timeline. One is a movie clip called displayTab that has 5 key frames that highlight graphically what button you have pressed. My buttons are grouped together in another movieclip called CategoryButtons. I'm really stuggling with this simple function in AS3. Previously, in AS2, I think it would have looked something like this:

on(release) {
_root.displayTab.gotoAndStop("video");
}

In AS3, after digging around for a while I came up with:

videoButton.addEventListener(MouseEvent.MOUSE_UP, change_tab);
function change_tab(evt:MouseEvent):void{
root.displayTab.gotoAndStop("video");
}

I know this is wrong but I'm not sure where to go from here.

Thanks, m

the_lar
December 9th, 2007, 10:21 AM
The movie clip where you're running the script doesn't inherently know anything about what root is. So you'd have to typecast root first, try changing this:

root.displayTab.gotoAndStop("video");

to this:

MovieClip(this.root).displayTab.gotoAndStop("video");
or you could say:
MovieClip(this.parent).displayTab.gotoAndStop("video");

squarelight
December 10th, 2007, 08:20 PM
That worked. thank you.