Solved

setting a "dynamic" array .. ?

Posted on 2002-03-07
4
185 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 75 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

Technology Partners: 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

Suggested Solutions

Title # Comments Views Activity
Flash player 17 install script .bat or .vbs 9 578
Adobe Presenter not Publishing Slide Theme 17 135
Flash Slides/Presnetation 4 81
Adobe Products Forum? 3 166
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…
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…
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.
This Micro Tutorial will teach to how to utilize bit rate in Adobe Flash Media Live Encoder.

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