Solved

flash: how to add elements dynamically ?

Posted on 2011-02-21
1
349 Views
Last Modified: 2012-05-11
Hello, I have in my Fla (cs5) these symbols:
Backgorund1
Background2
Background3

All these extends MovieClips

My goal is to add them dynamically to stage accordign to level variable:
ex:

   var level:int = 1;
   
    var bg:MovieClip =new getClassByName("Background"+level);
   
    stage.addChild(bg);



Any idea on how to do that ?

Regards
0
Comment
Question by:yarekGmail
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
1 Comment
 
LVL 1

Accepted Solution

by:
nightmare3d earned 500 total points
ID: 34951676
hi,

you can do this:




var dynamicClass:String = "background" + String(level);
var classRef:Class = getDefinitionByName(dynamicClass) as Class;
var mc:MovieClip = new classRef();
addChild(mc)

Open in new window

0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Recently, I was asked to recommend a tracking system to be implemented on a clients website. As the entire site was built on flash, my first thought was to suggest custom built tracking system. However, our company at that point of time didn't h…
In my long career of working as an actionscript developer, I had spent sleepless night often working hard to solve some small problems which actually took a lot of my development time; later found out the solutions to be a line or two. Here are s…
The goal of the tutorial is to teach the user how to set there setting in Adobe Flash Media Live Encoder and YouTube for optimal video and audio quality.
The goal of the tutorial is to teach the user how to use the auto adjust feature and what the different options do. When your video is not working right you can choose the auto adjust feature to help choose your settings.
Suggested Courses

740 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question