Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

html5 canvas loads image oddly

Posted on 2013-05-12
4
Medium Priority
?
341 Views
Last Modified: 2013-05-13
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
Comment
Question by:jagguy
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
  • 2
4 Comments
 
LVL 82

Expert Comment

by:leakim971
ID: 39160253
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
 

Author Comment

by:jagguy
ID: 39160278
bit it isnt an  'if', it does load and then assign an image. it reads back to front for me.
0
 
LVL 82

Accepted Solution

by:
leakim971 earned 2000 total points
ID: 39160286
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
 

Author Comment

by:jagguy
ID: 39160561
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

Google Certified Professional - Cloud Architect

This course (1 of 3) is designed to help students who are interested in Google Cloud Platform (GCP) to become familiar with the platform, navigate the console and learn its capabilities. It will also prepare students for the Google Cloud Architect certification exam.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

International Data Corporation (IDC) prognosticates that before the current the year gets over disbursing on IT framework products to be sent in cloud environs will be $37.1B.
Boost your ability to deliver ambitious and competitive web apps by choosing the right JavaScript framework to best suit your project’s needs.
In this tutorial viewers will learn how to customize the background color and font color of highlighted text using the ::selection element in CSS Begin by defining the selected text as an element in CSS by typing "::selection": Style the ::selection…
The viewer will receive an overview of the basics of CSS showing inline styles. In the head tags set up your style tags: (CODE) Reference the nav tag and set your properties.: (CODE) Set the reference for the UL element and styles for it to ensu…

688 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question