[Last Call] Learn about multicloud storage options and how to improve your company's cloud strategy. Register Now

x
?
Solved

setting a "dynamic" array .. ?

Posted on 2002-03-07
4
Medium Priority
?
188 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

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

Question has a verified solution.

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

Introduction This article is primarily concerned with ActionScript 3 and generally specific to AVM2.  Most suggestions would apply to ActionScript 2 as well, and I've noted those tips that differ between AS2 and AS3. With the advent of ActionS…
The last time I worked with Flash and Socket connections was in AS1. A recent project required flash connecting to a Socket, and sending receiving information - we figured it would be easy enough - we all know about the socket policy documents and c…
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 what frame rate is, how to control it and what effect it has on the video.
Suggested Courses

650 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