Created
October 14, 2020 16:01
-
-
Save varyndev/f656eceaac1ef460fd97fbe324a63e39 to your computer and use it in GitHub Desktop.
Pieces of the load image problem
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| /* Load images into an array. | |
| * Use file picker UI to select image files: https://web.dev/read-files/ | |
| * Use File API to select an image. See https://davidwalsh.name/resize-image-canvas | |
| * Use PreloadJS to load the image. | |
| * Use CreateJS to display the image. | |
| * | |
| */ | |
| var queue; // PreloadJS load queue | |
| var userImages = []; // List of user selected image paths | |
| function loadItem(url) { | |
| //Add the event listener and handler | |
| queue.on("fileload", function(event) { | |
| var type = event.item.type; | |
| if(type == createjs.LoadQueue.IMAGE) { | |
| //make a CreateJS Bitmap object from the result | |
| var imgItem = event.result; | |
| image = new createjs.Bitmap(imgItem.src); | |
| stage.addChild(image); | |
| stage.update(); | |
| } | |
| }, null, true, options); | |
| //create a LoadItem and set the crossOrigin property | |
| var loadItem = new createjs.LoadItem().set({src:url, crossOrigin:"Anonymous"}); | |
| //load it | |
| queue.loadFile(loadItem); | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment