0

I have an array of arguments like:

params["username"]= "john";

params["age"] = "25";

params["country"] = "France";

params["something"] = something;

which is VARIABLE and I need to pass it as rest argument :

nc.call("myMethod", params["username"], params["age"], params["country"]... );

params has not fixed size.

Is that possible ???

1
  • What is nc.call? Is that a call out to Javascript, NetConnection to FMS, other AS3 function? Why want you just pass params and let the receiving function handle a single object with multiple properties? Commented Feb 11, 2011 at 1:44

2 Answers 2

1

Depending on what exactly you're trying to do, it seems like you can just say nc.call("myMethod", params), can't you?

Or are you looking for the rest syntax for AS3? In that case, this may help: http://www.sephiroth.it/weblog/archives/2006/06/actionscript_3_rest_parameter.php

But be careful, it looks like you're trying to make a NetConnection call there and so if you're actually calling for instance a PHP function then this won't work. The rest operator (...) is used when defining your method signatures in AS3.

If you just want to pass an array of parameters to a PHP function via AMFPHP or something like that, do what I said in my first sentence and simply pass the params object. On the PHP side you would treat it as an associative array ($params->username, $params->age, etc)

Hope that helps, and if it doesn't please be a little bit more clear about what it is you're trying to accomplish!

Cheers, myk

Sign up to request clarification or add additional context in comments.

Comments

0

Focusing only on this one part of your question for now :

params has not fixed size.

Is that possible ???

Yes, it's absolutely possible when you treat the Array like it is a hash table. In fact, the Adobe livedocs specifically say you shouldn't do this. I'm guessing it's for reasons like these, to cut down on situations that arise from using it in a way that is ambiguous with a normal Object().

Anyway, Array.length ONLY returns a value between 0 and int.MAX_VALUE. If you've assigned a variable to an Array location that is not an integer between 0 and int.MAX_VALUE it will not be included in the .length property's return value.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.