AS3 function running before variables are defined!
Posted
by Jeffrey
on Stack Overflow
See other posts from Stack Overflow
or by Jeffrey
Published on 2010-06-15T21:38:25Z
Indexed on
2010/06/15
21:42 UTC
Read the original article
Hit count: 217
I am trying to add an init() function to a MovieClip, but when I run the function from scene1 the variables that were set in the MovieClip are not defined yet... The MovieClip was dragged to the stage from the library.
scene1:
mc.init(null);
MovieClip:
var _default = 5;
function init(num) {
if(num == null) {
trace(_default);
} else {
trace(num);
}
}
This is tracing "undefined" instead of "5"; Is there a way of fixing this problem?
© Stack Overflow or respective owner