I have a very strange problem with a simple test I'm trying to do in AS3.
I have two functions on my first frame:
function function1 ():void {
trace ('function1 executed');
mc.gotoAndStop (2);
function2 ();
}
function function2 ():void {
trace ('function2 executed');
var test_mc:test_lib = new test_lib ();
addChild (test_mc);
}
As you can see, function1 changes the frame on "mc" and also calls function2, which adds a child movie clip from the library in the stage.
Function1 is called from inside another simple movie clip, on the 60th frame, like so:
Object(parent).function1 ();
This child movie clip that is added, is just a black square with a trace action on it's first frame.
The trace action should work as soon as the child is added, but it's not.
However, if I remove or comment the line mc.gotoAndStop(2)
, the trace action works normally. It also works if I put the mc.gotoAndStop(2)
AFTER I call the function2.
I can't see why this is happening.
This happened on a larger project that I was working so I decided to isolate the problem on a new file, and create the example above. This is very weird.