Load content from library onto stage


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

Add content to stage from Library through code and use the content.


Copy this code and paste it in your HTML
  1. // METHOD 1
  2. // Add Content
  3. var someMc:String = "this_mc";
  4. var newClass = getDefinitionByName(someMc);
  5. var mcAdded= new newClass ();
  6. addChild(mcAdded);
  7.  
  8.  
  9. // Use Content
  10. var someString:String = "mcAdded";
  11. var selectedInstance = getChildByName( someString);
  12.  
  13. selectedInstance.x = 210;
  14.  
  15. // METHOD 2
  16. // In the MovieClip properties, set it to export for ActionScript and give it a class name.
  17.  
  18. //In your code.
  19. var MC = new yourMCclassName();

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.