flash: how to add elements dynamically ?

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

All these extends MovieClips

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

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

Any idea on how to do that ?

Question by:yarekGmail
1 Comment

Accepted Solution

nightmare3d earned 500 total points
ID: 34951676

you can do this:

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

Open in new window


Featured Post

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
SWF won't scale? 4 527
Error 2032 in all the browser 6 2,850
Adobe flash player fails to install 12 312
word is recognized as adobe and adobe as IE files 14 51
This is a very simple example to help those of you who are still migrating from AS2 to AS3 understand the redesigned event model in AS3. In AS2.0, event functions (that is, the function to be performed when an event is fired) were stored as a pro…
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 this tutorial viewers will learn how to create a basic motion tween animation in Flash Open a new document in Flash: Draw/import an image: Press CTRL + F8 to convert it into a graphic symbol: Select a frame (how long you want the tween to last): …
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.

856 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