Solved

flash: how to add elements dynamically ?

Posted on 2011-02-21
1
340 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
1 Comment
 
LVL 1

Accepted Solution

by:
nightmare3d earned 500 total points
Comment Utility
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

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

This is intended to introduce all collision detection principles in flash, their strengths, weaknesses and workarounds. The main method for Collision Detection in flash is using hitTestObject. But unless you'll be pushing rectangular shapes without …
The last time I worked with Flash and Socket connections was in AS1. A recent project required flash connecting to a Socket, and sending receiving information - we figured it would be easy enough - we all know about the socket policy documents and c…
The goal of the tutorial is to teach the user how to how to record live broadcast.
The goal of the tutorial is to teach the user what frame rate is, how to control it and what effect it has on the video.

728 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

Need Help in Real-Time?

Connect with top rated Experts

9 Experts available now in Live!

Get 1:1 Help Now