オブジェクト名に変数を使う


/ Published in: ActionScript 3
Save to your folder(s)



Copy this code and paste it in your HTML
  1. var mc:MovieClip = generateMCByString(nameOfLibraryItem);
  2. mc.x = 400;
  3. mc.y = -50;
  4. addChild(mc);
  5.  
  6. function generateMCByString(id:String):MovieClip
  7. {
  8. var mcObj:Object = null;
  9. mcObj = getDefinitionByName(id.toString());
  10. return (new mcObj()) as MovieClip;
  11. }

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.