Solved

keep textField instance name in an array

Posted on 2011-02-25
3
306 Views
Last Modified: 2012-05-11
Hi,

I have three movieClip in the library and each contain different number of text filed boxes. The textfield instances  are all named box1-box2..... They are in the library and not on the stage.

I have an XML file which is updatable and contains the value for these textfileds. Now base on the number of the text fields value I read from XML file, I pick one of these movieClips from the library and add it to the stage. I want to use a loop, using the number of valu in XML file, and give give the value to the textfiled using their instance names.

so far nothing worked out for me. I tried using array but no success.


What do you think I should do?

0
Comment
Question by:Angha110
3 Comments
 
LVL 39

Accepted Solution

by:
blue-genie earned 500 total points
Comment Utility
can i assume you're using AS3.

if you link your movieclips

ie  TextClip1 TextClip2 etc.
if you want to you can create one class and have each one extend them otherwise just link it in the library.

then based on the number of text fields in the xml create a new instance of whichever one required
add that to the stage.

then you'll know how many items there are
so use the for loop to assign the values.

how have you not managed to come right?
you can try upload your file and we can have a look.
0
 
LVL 12

Expert Comment

by:scooby_56
Comment Utility
A simple 'if' or 'switch' statement should do it...

//note: not working code...
if (myNodes.length == 1) {addChild (new Movie1())}
if (myNodes.length == 2) {addChild (new Movie2())}
if (myNodes.length == 3) {addChild (new Movie3())}

etc...

Does your project require that you use separate movieclip? or could you get away with creating one clip, with no textfields then with actionscript, dynamically add the correct number of text fields .

Alternatively instead of relying on counting the nodes, could you add another attribute in the XML that specifys which movie to use?

If you need specific examples, ill need to see some code. XML and the .fla


0
 

Author Comment

by:Angha110
Comment Utility
You are right, I should create the text fields with their instances dynamically. All these issue were because of having the text fields already created in those movie clips in library.
I am still curious how to manage them but for my project I will do it the right way.
0

Featured Post

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

Sometimes you know that one object has a specific child in it, but you can't find the child. This happened to me when I was trying to code some actionScript to make a toolbar work with its embedded buttons.  My partner had created the toolbar usi…
While working over numerous projects I often had the requirement for doing a screen capture in AS3.0. Unfortunately I found no "ready made" solutions in google search that suited my requirements. But I did come across some great resources which help…
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…
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.

743 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

13 Experts available now in Live!

Get 1:1 Help Now