[Last Call] Learn about multicloud storage options and how to improve your company's cloud strategy. Register Now

x
?
Solved

addChild(new thumb[0]); how? adding dynamic var with addChild

Posted on 2011-03-20
2
Medium Priority
?
532 Views
Last Modified: 2012-06-21
I currently have any array representing some linkage names from my library. The images are added to an instanced movieclip on stage.

var thumbs:Array = new Array("thumbSliderImage1","thumbSliderImage2","thumbSliderImage3");

Example where " thumbSliderImage1" is a linkage from library.

thumbSlider1.addChild(new thumbSliderImage1());

How would I go about replacing "thumbSliderImage1" with lets say an index from my array, like thumb[0] - thumbSlider1.addChild(new thumb[0]); ?
0
Comment
Question by:mrsam
[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
2 Comments
 
LVL 29

Accepted Solution

by:
dgofman earned 2000 total points
ID: 35176171
In Flex you can use Container APIs

http://help.adobe.com/en_US/FlashPlatform/reference/actionscript/3/mx/core/Container.html

removeChildAt(index:int):DisplayObject
[override] Removes a child DisplayObject from the child list of this Container at the specified index.

addChildAt(child:DisplayObject, index:int):DisplayObject
[override] Adds a child DisplayObject to this Container.

I will also suggest to add name for your new instances before adding into Container

var image:thumbSliderImage1 = new thumbSliderImage1();
image.name = "thumb0";
addChild(image);

In this case you can find this instance and index by name:

getChildByName(name:String):DisplayObject
[override] Returns the child whose name property is the specified String. Container

    getChildIndex(child:DisplayObject):int
[override] Gets the zero-based index of a specific child.


var image:thumbSliderImage1 = getChildByName("thumb0") as thumbSliderImage1;
if(image != null)
          index = getChildIndex(image);
0
 

Author Comment

by:mrsam
ID: 35318606
dgofman - you totally saved me with this - I cant say how much I appreciate you chipping in here!
0

Featured Post

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering 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

There are times in your Flash CS4 application when you want more than a simple pointer or a hand, and it's hard to find an ideal walk-through to tell you what to do.  I spent a few days recently learning my way around making custom cursors in Flash,…
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…
In this tutorial viewers will learn how to create a basic shape tween animation in Flash including shape hints for smooth animation Open a new document in Flash: Draw a shape: Select another frame (how long you want the tween to be): Right click and…
This Micro Tutorial will teach to how to utilize bit rate in Adobe Flash Media Live Encoder.

656 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