PDA

View Full Version : Help with JSFL AddNewRectangle


Go_Cats_Go!
04-06-2004, 03:50 PM
How do I substitute a variable in for the named arguments in the addNewRectangle method of JSFL?

Instead of this:
flash.getDocumentDOM().addNewRectangle({left:0,top :0,right:100,bottom:100},0);
I need to do this:
flash.getDocumentDOM().addNewRectangle({left:myvar[0],top:myvar[1],right:myvar[2],bottom:myvar[3]},0);

I keep getting the message "argument number is not valid". I've tried building the parameter string ahead of time, and I've tried using the eval() function, but still can't get past this error.

Anybody else have any ideas?

Thanks!

cMan
08-17-2004, 04:49 AM
nothing wrong with your code except the way you probably defined your array().

here are 3 ways.

var myvar = [ 0, 0, 100, 100 ];
or
var myvar = new Array();
myvar[0] = 0;
myvar[1] = 0;
myvar[2] = 100;
myvar[3] = 100;
or
var myvar = new Array();
myvar.push( 0 );
myvar.push( 0 );
myvar.push( 100 );
myvar.push( 100 );

------------

any of those 3 ways you choose will work with your code.

flash.getDocumentDOM().addNewRectangle({left:myvar[0],top:myvar[1],right:myvar[2],bottom:myvar[3]},0);