actionscript 3 - AS3 function running before variables are defined! -


I am trying to add an init () function to a movie clip, but when I see the function running from View 1 Set in movie clips are not yet defined ... Movie clips were drawn from the library to the stage.

scene1:

  mc.init (null);  

Movie Clip:

  var _default = 5; Function init (num) {if (num == null) {trace (_default); } Else {trace (num); }}  

This is "undefined" tracing rather than "5"; Is there any way to fix this problem?

The problem is that any code is placed directly into the headline, the timeline will always contain code directly in the movie clip Will run before.

The way to move around this will be the first time the Flash plugin will end and call the first movie clip, and then call the function

Timeline:

  addEventListener (Event.ENTER_FRAME)  

, OnEnterFrame); Function Centerframe (E: Event): Zero {myObject.init (faucet); RemoveEventListener (Event.ENTER_FRAME, onEnterFrame); }

In this way, the timeline will wait for the first frame to call the init function of your movie clip.


Comments

Popular posts from this blog

windows - Heroku throws SQLITE3 Read only exception -

lex - Building a lexical Analyzer in Java -

python - rename keys in a dictionary -