?
Solved

keep textField instance name in an array

Posted on 2011-02-25
3
Medium Priority
?
320 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
[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 Comments
 
LVL 39

Accepted Solution

by:
blue-genie earned 2000 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

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

I know the transition can be hard. We got used to the ease of use ActionScript 2 had, but honestly, it became problematic later on, especially if designers were involved in the project and found it easy to add code as they saw fit. So, this artic…
This article describes a solution to a problem of subloading one movie into another when they have different SWF versions. Sometime back, I was working on an ActionScript project while I came across an interesting fact which I would like to share…
The goal of the tutorial is to teach the user how to how to load their YouTube profile onto Flash Media Live Encoder.
The goal of the tutorial is to teach the user how to set there setting in Adobe Flash Media Live Encoder and YouTube for optimal video and audio quality.
Suggested Courses

771 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