473,386 Members | 1,820 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,386 software developers and data experts.

variable as POST key with URLVariables in AS3?

Hello,
I have an array of data objects that I would like to send from my .swf to a server-side script. I would like to loop through the array and assign a variable key name to each name-value pair, for example:

Expand|Select|Wrap|Line Numbers
  1. myVars = new URLVariables;
  2. for(i in objectArray){
  3. var keyName = 'obj_' + i;
  4. myVars.keyName = objectArray[i].data;
  5. }
  6.  
But when I try to use this method, the parser treats 'keyName' as a string.

Is it possible to do this? or do I have to write a very long switch/case statement?

Your insight is appreciated!
many thanks,
thesmithman
Sep 15 '09 #1
1 4981
Hi thesmithman,

So, have you found the solution?
(I know it's an old thread, hehe.. But I ended up here from google.)

I didn't find the solution within flash itself, but here is what I did to get it works.

Instead of setting URLVariables object property, I use its constructor. Since the constructor can only hold one name/value pair, I make a single tricky name/value pair (v) containing all variables.

Expand|Select|Wrap|Line Numbers
  1. var fvParameters:Object = LoaderInfo(this.loaderInfo).parameters;
  2. var key:String;
  3. var val:String;
  4. var flashVars:String = "v=";
  5.  
  6. for (key in fvParameters) {
  7.     flashVars += key + ":" + String(fvParameters[key]) + ";";
  8. }
  9.  
  10. // length-1 to remove last ; character
  11. urlVariables = new URLVariables(substr.(0, (flashVars.length - 1)));
  12.  

On server side I can extract the 'v' variable content, using php:

Expand|Select|Wrap|Line Numbers
  1. $v = split(';', $_GET['v']);
  2. while (list($key, $val) = each($v)) {
  3.     $tmp = split(":", $val);
  4.     $vars[$tmp[0]] = $tmp[1];
  5. }
  6.  

Regards,
Ihsan.
Dec 6 '10 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

3
by: Ko Ko | last post by:
Dear All, I am wondering how to pass one variable from one php file to another continuously or discontinuously. For example, variable $a is declared in file1.php. I like to use that variable in...
3
by: Thomas Hoheneder | last post by:
Hello, I use PHP 4.3.10 and want to deliver a post variable from a PHP page to itself. In my page mypage.php I have a hidden field named "dbaction" and a form button. When clicking the form...
5
by: flemming eriksen | last post by:
Dear NG. IIS5 (and II6) , ASP 3.0.; W2k, WS03. A websolution has a login-page, transaction page (just reading data), and logout-page Under heavy load I get in the IIS-Log : Too many...
3
by: Geoff Winsor | last post by:
Hi, I am experiencing a problem with recalling a session variable which stores whether a person is logged in to a "members only" section of a website. This area of the site has been working...
5
by: Chuck Anderson | last post by:
I have finally started coding with register_globals off (crowd roars - yeay!). This has created a situation that I am not sure how I should handle. I have scripts (pages) that can receive an...
10
by: Mason Barge | last post by:
I have a standard POST form consisting of two types of input: text input and textarea. The form downloads current settings from a mysql database. The user can update the information by modifying...
5
by: pavloutefkros | last post by:
sorry for creating a new post but this is totally different from the previous one. Here is the problem (which is very hard to explain, so i will use a paradigm): i submit a form and the post...
5
by: Twayne | last post by:
Hi, If ever a newbie wants to know how much he has to learn yet, he only has to look here<g>!! ANYway: PHP 5.2.5; XP Pro SP2+, local Apache Server My actual question is: How do I get a...
2
by: JWest46088 | last post by:
I'm making a contact form, and I keep getting two errors when I try previewing it in a web browser. ReferenceError: Error #1065: Variable Button is not defined. ReferenceError: Error #1065:...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.