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

x
?
Solved

setting a "dynamic" array .. ?

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

Hire Technology Freelancers with Gigs

Work with freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely, and get projects done right.

Question has a verified solution.

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

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. …
Sometimes you know that one object has a specific child in it, but you can't find the child. This happened to me when I was trying to code some actionScript to make a toolbar work with its embedded buttons.  My partner had created the toolbar usi…
In this tutorial viewers will learn how to create a basic shape tween animation in Flash including shape hints for smooth animation Open a new document in Flash: Draw a shape: Select another frame (how long you want the tween to be): Right click and…
The goal of the tutorial is to teach the user how to select the video input device. Make sure you have an input device that in connected and work and recognized by Adobe Flash Media Live Encoder and select it in the “video input” menu.
Suggested Courses

873 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