• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 347
  • Last Modified:

html5 canvas loads image oddly

Hi,
My code works to load an image(s) on a canvas in html.
My question is why does this work .
To me I should not be abkle to trigger an onload function until the image has been assigned.

for (i=0;i<arr1.length;i++){
		images[i] = new Image();
 		images[i].onload = onImgLoad; //how does event trigger if there is nothing to load
 		images[i].src = arr1[i]; // the image to load doesnt happen until next line
	}

Open in new window

0
jagguy
Asked:
jagguy
  • 2
  • 2
1 Solution
 
leakim971PluritechnicianCommented:
I read it like : << if this event occur on this element >>

onclick : if something/someone click on this
onload : if something/someone load this
0
 
jagguyAuthor Commented:
bit it isnt an  'if', it does load and then assign an image. it reads back to front for me.
0
 
leakim971PluritechnicianCommented:
remove line 4 and wait. wait. wait. :)
line 4 is your trigger if the "source" is valid else you have onerror if error loading this
0
 
jagguyAuthor Commented:
Ok I might close this thread.
let me get this right  that the onload function doesnt trigger until a src is attached so in this sense it is in the right order.
images[i].onload = onImgLoad; //how does event trigger if there is nothing to load
images[i].src = arr1[i]; // the image to load doesnt happen until next line

Open in new window

0

Featured Post

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

  • 2
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now