Simple syntax query
Hi there Gurus!
Just a quick noob problem, could anyone please tell me how I need to imput these array values?
Arrays:
var houseRef = new Array();
houseRef['L1a'] = new Array (250,100,350,700 );
houseRef['L1b'] = new Array (600,100,350,700);
houseRef['L1c'] = new Array (950,100,350,700);
Using array values:
Goal:
context.drawImage(img, 250, 100, 350, 700 , 0, 0, 200, 400);
This works:
context.drawImage(img, houseRef['L1a'][0],houseRef['L1a'][1],houseRef['L1a'][2],houseRef['L1a'][3], 0, 0, 200, 400);
This doesnt:
context.drawImage(img, houseRef['L1a'] , 0, 0, 200, 400);
Thanks for your help in advance!
You have to do it the way it works. The other way is just setting the 2nd parameter to an array. It will not break an array out to 4 arguments.
Eric
Awesome, thats really good to know Eric!
One other query then, can you see a way to accomplish with a less code intensive method? Like a series of numeric variables rather than an array?
Not too sure what the options are when youre wanting to use a series of numbers like this.
Thanks again!
Code:
for(var ind in houseRef){
var pnt = houseRef[ind];
context.drawImage(img, pnt[0], pnt[1], pnt[2], pnt[3], 0, 0, 200, 400);
}
And again, thanks heaps Eric!
Thread Information
Users Browsing this Thread
There are currently 1 users browsing this thread. (0 members and 1 guests)
Tags for this Thread
Posting Permissions
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
Forum Rules
Bookmarks