Solved

keep textField instance name in an array

Posted on 2011-02-25
3
314 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

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

Suggested Solutions

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. …
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…
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 set there setting in Adobe Flash Media Live Encoder and YouTube for optimal video and audio quality.

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