Solved

How Do I Dynamically Delete DisplayObjects from Movie Clip?

Posted on 2009-04-02
5
590 Views
Last Modified: 2013-11-11
Hi

So I have the code for creating a new object of a movie clip I have  made called listContainer. Everything on the display object side works great, they display nicely on the screen

However, when I want to delete a certain object from the stage, how would I do this?

I tried with

interestListMC.removeChildAt(#)

but it's hard to guess the numbers to deelte, since each display object produces 2 children (in my case)

is there any way to delete a certain child? by ID or something other than index? Thanks.
var listContArry:MovieClip = new listContainer();
interestListMC.addChild(listContArry);

Open in new window

0
Comment
Question by:dsrnu
[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
  • 3
  • 2
5 Comments
 
LVL 12

Expert Comment

by:scooby_56
ID: 24052086
if you have added at design and typed in an instance name inthe properties panel,  you can remove using this
removeChild(getChildByName('box1')); //box1 is the instance name

if you added dynamically with actionscript then use the variable name
interestListMC.removeChild(listContArry); //using your variable name
0
 

Author Comment

by:dsrnu
ID: 24052576
I add the listContainer boxes dynamically, as user clicks a button

so I have code to add the listeContainer, but each listContainer is the same object name as its a for loop as in the code section

how Do I identifiy certain boxes according to their ID and delete them? I have the variable id in the obj parameter that identifies the  id of the object

would I be able to append that ID onto the listContArry variable?

Thanks!


for each(var obj:Object in interestObjArry) {
var listContArry:MovieClip = new listContainer();
interestListMC.addChild(listContArry);
listContArry.x = 25;
listContArry.y = pos_y;
pos_y += 140;
listContArry.idText.text = obj.id;
}

Open in new window

0
 
LVL 12

Accepted Solution

by:
scooby_56 earned 500 total points
ID: 24053365
Use the 'name' property

set it when creating your mc within the looop
listContArry.name = "myMovie_" + obj.id

then you can remove using getChildByName()
removeChild(getChildByName('myMovie_' + idFromSomeWhere))
0
 

Author Comment

by:dsrnu
ID: 24054064
thank you! works great
0
 

Author Closing Comment

by:dsrnu
ID: 31565701
Thanks!
0

Featured Post

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying 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
Flash media server 1 336
Add 'birds singing' to homepage 5 116
Adobe Presenter not Publishing Slide Theme 17 135
Is it possible to insert an Adobe Flash video in a .net  web page ? 2 109
I come across a lot of question about how to access things in the document class from a movieclip, or accessing something from a movieclip in the document class. It took me a while to figure this out but once I did it makes life so much easier. …
I have found that much of my time doing support ends up being a constant repetition of the same steps to different people.  Early on I stated using web pages with Frequently Asked Questions (FAQs) to alleviate most of the burden.  Sometimes this jus…
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 select the video input device. Make sure you have an input device that in connected and work and recognized by Adobe Flash Media Live Encoder and select it in the “video input” menu.

726 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