Solved

keep textField instance name in an array

Posted on 2011-02-25
3
308 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
ID: 34981354
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
ID: 34981414
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
ID: 34987457
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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

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. …
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…
The goal of the tutorial is to teach the user how to live broadcast using Flash Media Live Encoder and connecting it to YouTube to broadcast. Log into your Youtube account, choose live stream settings, start live stream from Flash Media Live Enc…
This Micro Tutorial will teach to how to utilize bit rate in Adobe Flash Media Live Encoder.

920 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

16 Experts available now in Live!

Get 1:1 Help Now