arrays - In Actionscript 3, how to create many instances of the same symbol? -
though coding, must make many copies of same movieclip placed on stage, each manipulated code-wise on own
for instance, have movieclip named mc
, wish have 99 copies of ít loaded onto stage, each in different x coordinate. should do?
i think on doing this:
step 1: in library, turning mc
class
step 2: placing following code in scene's script
var myarray:array = new array (var i:int = 0; i<99;i++) { var mcinstance:mc = new mc mc instance = myarray[i] movieclip.(myarray[i]).x = i*30 }
would make sense?
that's right idea, syntax little off. try this:
var myarray:array = []; (var i:int = 0; < 99;i++) { var mc:mc = new mc(); myarray[i] = mc; mc.x = * 30 }
as3 style conventions: use lowercamelcase variable names, don't omit constructor parens though optional, , create arrays using literals (source).
Comments
Post a Comment