?
Solved

Using dynamic variables with Load Vars

Posted on 2008-01-26
2
Medium Priority
?
634 Views
Last Modified: 2010-04-21
HI All,

I am writing actionscript to get variables from a database using php. I have used the LoadVars object and can set a variable using the following line of code which works

_root.show1=myLoadVar.display1

In this case myLoadVar is an instance of the Loadvars class and display1 is one of a series of variables sent from php.

I need to make the right hand side of the expression dynamic eg(display1, display2, display3 etc)

I have tried using eval but it does not work.

Thanks for any help.

Richard
0
Comment
Question by:RICHARDH
2 Comments
 
LVL 14

Accepted Solution

by:
trigger-happy earned 500 total points
ID: 20751624
You can try this. Just take note that i = 0 at the start so you might want to change that to var i = 1 if ever you want to start from 1.

--trigger-happy
for(var i = 0; i<somenumber; i++){
     _root["show"+i] = myLoadVar["display"+i];
}

Open in new window

0
 

Author Closing Comment

by:RICHARDH
ID: 31406135
Many thanks for the help.
0

Featured Post

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Here are some practices and techniques that can be adopted into your Flash/Flex application development process. Note: Not all "performance tips" provide an immediately-recognizable benefit.   This article does not include timing validation data,…
While working over numerous projects I often had the requirement for doing a screen capture in AS3.0. Unfortunately I found no "ready made" solutions in google search that suited my requirements. But I did come across some great resources which help…
The goal of the tutorial is to teach the user how to how to record live broadcast.
This Micro Tutorial will teach to how to utilize bit rate in Adobe Flash Media Live Encoder.
Suggested Courses

600 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