I've been driving myself crazy over this one for a while.
I have one MovieClip nested inside another, and I'm having trouble passing events from the nested to the parent. I'm trying to do this all through scripting, as the MC's are actually custom classes which extend MovieClip.
Here's a sample: - MainClip.as:
ActionScript Code:
class MainClip extends MovieClip
{
var nest:nestedClip;
function MainClip()
{
var obj:Object = new Object;
obj.click = function(evt)
{
trace("clicked");
}
nest.addEventListener("click", obj);
}
}
And, nestedClip.as
ActionScript Code:
import mx.events.EventDispatcher
class nestedClip extends MovieClip
{
// Supposedly EventDispatcher adds bodies here
// when initialize is called
function dispatchEvent() {};
function addEventListener() {};
function removeEventListener() {};
function nestedClip()
{
trace(this);
mx.events.EventDispatcher.initialize(this);
onPress = function()
{
doSomething();
}
}
function doSomething()
{
trace("doSomething called");
dispatchEvent({target:this, type:"click"});
}
}
Basically, it'll trace the name of the nested clip, then "doSomething called", and that's all. I can also call doSomething() from within the parent clip, with the same result.
Thanks in advance for any help,
-C