Friday, July 22, 2011

Child Target Parent Path

How would you like to bite into a Nyum-nyum bun... only to discover a strand of someone's hair mixed up in the wet filling?

That's how the Nimble Nwee felt when it discovered Actionscript 3.0's convoluted (and poorly documented) method of targeting a parent clip, function or another object on the main timeline from a child timeline. Gone are AS 2.0's simpler and zestier 'root','parent','stage'

1. The following examples have won't target or scope from the parent or main level.
//property
trace(parent.nameOfClipTargeted.x)
trace(root.nameOfClipTargeted.x)
//eventhandler
parent.nameOfClipTargeted.addEventListner(MouseEvent.CLICK, myFunction)
//functions
MyCustomFunction(doSomething);


2. You must suffixed the following...
MovieClip(this.parent)
to your objects like so...
//
MovieClip(this.parent).nameOfClipTargeted.x
//
MovieClip(this.parent).nameOfClipTargeted.addEventListner(MouseEvent.CLICK, myFunction)

Not so Nyum-nyum!

No comments:

Post a Comment