?
Solved

setting a "dynamic" array .. ?

Posted on 2002-03-07
4
Medium Priority
?
187 Views
Last Modified: 2010-04-03
this code sets the array _root.clip4[5] to 1 as desired.

_root.clip4[5] = 1

i need to adapt this code to set a dynamic array (one made up from two variables (variableone and variabletwo)) to equal 1

i have tried this code;

"_root.clip" + xvariable + "[" + yvariable + "]" == 1

and many other variants but been unsuccesfull ... please please please can anyone help? many thanks
0
Comment
Question by:lexfrost
[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
4 Comments
 
LVL 4

Expert Comment

by:heddesheimer
ID: 6847679
try to compose the variable name into a string variable and use the eval() function to access the dynamic variable.

That should work

Marian
0
 
LVL 19

Expert Comment

by:webwoman
ID: 6847684
Your syntax is wrong if you're trying to set a value. Use
"_root.clip" + xvariable + "[" + yvariable + "]" = 1

== is checking to see if the expression is equal to 1, not setting it.

Have you tried it with no quotes?
0
 

Accepted Solution

by:
hwwong earned 300 total points
ID: 6849759
you can use either of the following expression for the dynamic array:
1) eval("_root.clip" + xvariable)[yvariable]
2) _root["clip" + xvariable][yvariable]


Here is the code that you can try:

clip4 = new Array();
clip4[5] = 1;
xvariable = 4;
yvariable= 5;
//output = eval("_root.clip" + xvariable)[yvariable];
output = _root["clip" + xvariable][yvariable];
trace(output);

Henry
0
 

Author Comment

by:lexfrost
ID: 6850634
eval("_root.clip" + xvariable)[yvariable]

many many thanks ..  !! as well as a lifesaving actionscript guru youre a top bloke..


thanks again,

lex
0

Featured Post

Independent Software Vendors: 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…
In my long career of working as an actionscript developer, I had spent sleepless night often working hard to solve some small problems which actually took a lot of my development time; later found out the solutions to be a line or two. Here are s…
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 what frame rate is, how to control it and what effect it has on the video.
Suggested Courses
Course of the Month7 days, 21 hours left to enroll

765 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