[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

keep textField instance name in an array

Posted on 2011-02-25
3
Medium Priority
?
326 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 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

New feature and membership benefit!

New feature! Upgrade and increase expert visibility of your issues with Priority Questions.

Question has a verified solution.

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

This is a very simple example to help those of you who are still migrating from AS2 to AS3 understand the redesigned event model in AS3. In AS2.0, event functions (that is, the function to be performed when an event is fired) were stored as a pro…
Recently, I was asked to recommend a tracking system to be implemented on a clients website. As the entire site was built on flash, my first thought was to suggest custom built tracking system. However, our company at that point of time didn't h…
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…
The goal of the tutorial is to teach the user how to how to record live broadcast.
Suggested Courses
Course of the Month19 days, 2 hours left to enroll

834 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