Pass in an varying number of parameters.


/ Published in: ActionScript 3
Save to your folder(s)

This allows a varying amount of parameters to be passed into a function. Which is helpful if the amount of parameters passed in could change.
The trace in this example returns test3.


Copy this code and paste it in your HTML
  1. testfunction("test1","test2","test3","test4")
  2.  
  3.  
  4. function testfunction(...testValues)
  5. {
  6. var values:Array = new Array();
  7. values = testValues;
  8.  
  9. trace(testValues[2]);
  10. };

Report this snippet


Comments


You need to login to view comments.