Link to home
Start Free TrialLog in
Avatar of jagguy
jagguyFlag for Australia

asked on

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

Avatar of leakim971
leakim971
Flag of Guadeloupe image

I read it like : << if this event occur on this element >>

onclick : if something/someone click on this
onload : if something/someone load this
Avatar of jagguy

ASKER

bit it isnt an  'if', it does load and then assign an image. it reads back to front for me.
ASKER CERTIFIED SOLUTION
Avatar of leakim971
leakim971
Flag of Guadeloupe image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of jagguy

ASKER

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