HTML5 Canvas drawing an image set in for loop only draws the last iteration image setResize HTML5 canvas to fit windowHow to draw an oval in html5 canvas?Resizing an image in an HTML5 canvasDrawing an SVG file on a HTML5 canvasUsing HTML5/Canvas/JavaScript to take in-browser screenshotsCanvas width and height in HTML5HTML5 Canvas vs. SVG vs. divDrawing a dot on HTML5 canvasHTML5 Canvas Resize (Downscale) Image High Quality?Node JS Promise TypeError: Cannot read property 'then' of undefined
Professor refuses to write a recommendation letter
Is there any reason to change the ISO manually?
Numerical minimum of a one-valued function
Would you recommend a keyboard for beginners with or without lights in keys for learning?
Can I transfer my Australian ETA to my new passport or must I re-apply?
Why do old games use flashing as means of showing damage?
Fantasy Military Arms and Armor: the Dwarven Grand Armory
Do we know what "hardness" of Brexit people actually wanted in the referendum, if there had been other choices available?
Draw the ☣ (Biohazard Symbol)
How do I anonymously report the Establishment Clause being broken?
Bidirectional Dictionary
What are some countries where you can be imprisoned for reading or owning a Bible?
Does an antenna tuner remove standing waves from a transmission line?
How can I oppose my advisor granting gift authorship to a collaborator?
Why did the VIC-II and SID use 6 µm technology in the era of 3 µm and 1.5 µm?
Does blackhole merging breaks their event horizon seggregation?
Tiny image scraper for xkcd.com
Are language and thought the same?
When making yogurt, why doesn't bad bacteria grow as well?
Why is に used with this verb?
Is a paralyzed creature limp or rigid?
Understanding question 77 in Golan's "Linear Algebra".
Is it possible to observe space debris with Binoculars?
How does the UK House of Commons think they can prolong the deadline of Brexit?
HTML5 Canvas drawing an image set in for loop only draws the last iteration image set
Resize HTML5 canvas to fit windowHow to draw an oval in html5 canvas?Resizing an image in an HTML5 canvasDrawing an SVG file on a HTML5 canvasUsing HTML5/Canvas/JavaScript to take in-browser screenshotsCanvas width and height in HTML5HTML5 Canvas vs. SVG vs. divDrawing a dot on HTML5 canvasHTML5 Canvas Resize (Downscale) Image High Quality?Node JS Promise TypeError: Cannot read property 'then' of undefined
.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty margin-bottom:0;
I am trying to draw an image using a image loader inside of a for loop. It draws all of the images on the last iteration only.
In the console it does't show the draw -> 0 or draw -> 1 it just shows the draw -> 2
Thanks for any help!!
Here is my code block:
// For every player run iteration
var pos="";
var iter="";
for (var i = 0; i < item.length; ++i)
// Position for players on account screen
if(i == 0) pos = "61px"; iter = 0; console.log("pos 0 -> " + iter);
if(i == 1) pos = "168px"; iter = 1; console.log("pos 1 -> " + iter);
if(i == 2) pos = "275px"; iter = 2; console.log("pos 2 -> " + iter);
console.log(i);
console.log("pos -> " + pos);
console.log("iter -> " + iter);
// Gets player name from string
let player = item[i].match( /([A-Z])w+/g );
// Create player div for mouse interaction
let player_el = $('<div class="cursor player" id="player'+ player +'"></div>');
$("#can_wrapper").append(player_el);
$("#player"+ player).css("position": "absolute", "height": "50px", "width": "50px", "left": ""+ pos +"", "top": "271px", "cursor": "grab", "cursor": "-webkit-grab");
// Get player name for hover action
let player_name_el = player;
document.styleSheets[0].addRule('#player'+ player +':hover::after','content: "'+player_name_el+'";');
/**
* Promisify loading an image
* @param String imagePath The web location of the image
* @returns Promise A Promise that will resolve to an Image
*/
function loadImage(imagePath)
return new Promise((resolve, reject) =>
let image = new Image();
image.addEventListener("load", () =>
resolve(image);
);
image.addEventListener("error", (err) =>
reject(err);
);
image.src = '../interface/images/body/' + imagePath;
);
let imageSources = ['v1456.png', 'vbody0.png','vhead14.png','v1960.png','v578.png','v1221.png', 'v3063.png']; // url and order
Promise
.all(imageSources.map(ii => loadImage(ii)))
.then((images) =>
images.forEach((image) =>
if (iter == 0) ctx.drawImage(image, 60, 270); console.log("draw -> 0");
if (iter == 1) ctx.drawImage(image, 167, 270); console.log("draw -> 1");
if (iter == 2) ctx.drawImage(image, 274, 270); console.log("draw -> 2");
console.log(iter);
);
).catch((err) =>
console.error(err);
);
javascript jquery html5 canvas
|
show 3 more comments
I am trying to draw an image using a image loader inside of a for loop. It draws all of the images on the last iteration only.
In the console it does't show the draw -> 0 or draw -> 1 it just shows the draw -> 2
Thanks for any help!!
Here is my code block:
// For every player run iteration
var pos="";
var iter="";
for (var i = 0; i < item.length; ++i)
// Position for players on account screen
if(i == 0) pos = "61px"; iter = 0; console.log("pos 0 -> " + iter);
if(i == 1) pos = "168px"; iter = 1; console.log("pos 1 -> " + iter);
if(i == 2) pos = "275px"; iter = 2; console.log("pos 2 -> " + iter);
console.log(i);
console.log("pos -> " + pos);
console.log("iter -> " + iter);
// Gets player name from string
let player = item[i].match( /([A-Z])w+/g );
// Create player div for mouse interaction
let player_el = $('<div class="cursor player" id="player'+ player +'"></div>');
$("#can_wrapper").append(player_el);
$("#player"+ player).css("position": "absolute", "height": "50px", "width": "50px", "left": ""+ pos +"", "top": "271px", "cursor": "grab", "cursor": "-webkit-grab");
// Get player name for hover action
let player_name_el = player;
document.styleSheets[0].addRule('#player'+ player +':hover::after','content: "'+player_name_el+'";');
/**
* Promisify loading an image
* @param String imagePath The web location of the image
* @returns Promise A Promise that will resolve to an Image
*/
function loadImage(imagePath)
return new Promise((resolve, reject) =>
let image = new Image();
image.addEventListener("load", () =>
resolve(image);
);
image.addEventListener("error", (err) =>
reject(err);
);
image.src = '../interface/images/body/' + imagePath;
);
let imageSources = ['v1456.png', 'vbody0.png','vhead14.png','v1960.png','v578.png','v1221.png', 'v3063.png']; // url and order
Promise
.all(imageSources.map(ii => loadImage(ii)))
.then((images) =>
images.forEach((image) =>
if (iter == 0) ctx.drawImage(image, 60, 270); console.log("draw -> 0");
if (iter == 1) ctx.drawImage(image, 167, 270); console.log("draw -> 1");
if (iter == 2) ctx.drawImage(image, 274, 270); console.log("draw -> 2");
console.log(iter);
);
).catch((err) =>
console.error(err);
);
javascript jquery html5 canvas
by the time theimageSources.map(ii => loadImage(ii))promises have resolved, i.e. before the .then callback is called, thefor (var i = 0; i < item.length; ++i)loop will have completed, anditerwill be 2 ... the big hint that you are doing it wrong is thatpos 2 -> 2is logged before anydrawis logged out - you'll need to rethink your code considerably - I can't even imagine what you're trying to achieve in what order
– Jaromanda X
Mar 28 at 3:53
I'm trying to draw the character artwork that is in the array for each iteration. i.imgur.com/yAOghrQ.png the red squares are the 3 iterations and the last iteration is what is being drawn. the images have to be in an image loader because they need to load in a specific manner so it stacks correctly
– timeba
Mar 28 at 4:03
Just using the same images for now as a place holder. After i get them to display correctly I will pull it dynamically from a database. Ill be honest I don't really know how the promise works
– timeba
Mar 28 at 4:10
Thanks ill see what i can try and figure out from your example
– timeba
Mar 28 at 4:16
what you need to remember is ... Promise .then is called asynchronously - so you need to take that into consideration
– Jaromanda X
Mar 28 at 4:19
|
show 3 more comments
I am trying to draw an image using a image loader inside of a for loop. It draws all of the images on the last iteration only.
In the console it does't show the draw -> 0 or draw -> 1 it just shows the draw -> 2
Thanks for any help!!
Here is my code block:
// For every player run iteration
var pos="";
var iter="";
for (var i = 0; i < item.length; ++i)
// Position for players on account screen
if(i == 0) pos = "61px"; iter = 0; console.log("pos 0 -> " + iter);
if(i == 1) pos = "168px"; iter = 1; console.log("pos 1 -> " + iter);
if(i == 2) pos = "275px"; iter = 2; console.log("pos 2 -> " + iter);
console.log(i);
console.log("pos -> " + pos);
console.log("iter -> " + iter);
// Gets player name from string
let player = item[i].match( /([A-Z])w+/g );
// Create player div for mouse interaction
let player_el = $('<div class="cursor player" id="player'+ player +'"></div>');
$("#can_wrapper").append(player_el);
$("#player"+ player).css("position": "absolute", "height": "50px", "width": "50px", "left": ""+ pos +"", "top": "271px", "cursor": "grab", "cursor": "-webkit-grab");
// Get player name for hover action
let player_name_el = player;
document.styleSheets[0].addRule('#player'+ player +':hover::after','content: "'+player_name_el+'";');
/**
* Promisify loading an image
* @param String imagePath The web location of the image
* @returns Promise A Promise that will resolve to an Image
*/
function loadImage(imagePath)
return new Promise((resolve, reject) =>
let image = new Image();
image.addEventListener("load", () =>
resolve(image);
);
image.addEventListener("error", (err) =>
reject(err);
);
image.src = '../interface/images/body/' + imagePath;
);
let imageSources = ['v1456.png', 'vbody0.png','vhead14.png','v1960.png','v578.png','v1221.png', 'v3063.png']; // url and order
Promise
.all(imageSources.map(ii => loadImage(ii)))
.then((images) =>
images.forEach((image) =>
if (iter == 0) ctx.drawImage(image, 60, 270); console.log("draw -> 0");
if (iter == 1) ctx.drawImage(image, 167, 270); console.log("draw -> 1");
if (iter == 2) ctx.drawImage(image, 274, 270); console.log("draw -> 2");
console.log(iter);
);
).catch((err) =>
console.error(err);
);
javascript jquery html5 canvas
I am trying to draw an image using a image loader inside of a for loop. It draws all of the images on the last iteration only.
In the console it does't show the draw -> 0 or draw -> 1 it just shows the draw -> 2
Thanks for any help!!
Here is my code block:
// For every player run iteration
var pos="";
var iter="";
for (var i = 0; i < item.length; ++i)
// Position for players on account screen
if(i == 0) pos = "61px"; iter = 0; console.log("pos 0 -> " + iter);
if(i == 1) pos = "168px"; iter = 1; console.log("pos 1 -> " + iter);
if(i == 2) pos = "275px"; iter = 2; console.log("pos 2 -> " + iter);
console.log(i);
console.log("pos -> " + pos);
console.log("iter -> " + iter);
// Gets player name from string
let player = item[i].match( /([A-Z])w+/g );
// Create player div for mouse interaction
let player_el = $('<div class="cursor player" id="player'+ player +'"></div>');
$("#can_wrapper").append(player_el);
$("#player"+ player).css("position": "absolute", "height": "50px", "width": "50px", "left": ""+ pos +"", "top": "271px", "cursor": "grab", "cursor": "-webkit-grab");
// Get player name for hover action
let player_name_el = player;
document.styleSheets[0].addRule('#player'+ player +':hover::after','content: "'+player_name_el+'";');
/**
* Promisify loading an image
* @param String imagePath The web location of the image
* @returns Promise A Promise that will resolve to an Image
*/
function loadImage(imagePath)
return new Promise((resolve, reject) =>
let image = new Image();
image.addEventListener("load", () =>
resolve(image);
);
image.addEventListener("error", (err) =>
reject(err);
);
image.src = '../interface/images/body/' + imagePath;
);
let imageSources = ['v1456.png', 'vbody0.png','vhead14.png','v1960.png','v578.png','v1221.png', 'v3063.png']; // url and order
Promise
.all(imageSources.map(ii => loadImage(ii)))
.then((images) =>
images.forEach((image) =>
if (iter == 0) ctx.drawImage(image, 60, 270); console.log("draw -> 0");
if (iter == 1) ctx.drawImage(image, 167, 270); console.log("draw -> 1");
if (iter == 2) ctx.drawImage(image, 274, 270); console.log("draw -> 2");
console.log(iter);
);
).catch((err) =>
console.error(err);
);
javascript jquery html5 canvas
javascript jquery html5 canvas
asked Mar 28 at 3:50
timebatimeba
407 bronze badges
407 bronze badges
by the time theimageSources.map(ii => loadImage(ii))promises have resolved, i.e. before the .then callback is called, thefor (var i = 0; i < item.length; ++i)loop will have completed, anditerwill be 2 ... the big hint that you are doing it wrong is thatpos 2 -> 2is logged before anydrawis logged out - you'll need to rethink your code considerably - I can't even imagine what you're trying to achieve in what order
– Jaromanda X
Mar 28 at 3:53
I'm trying to draw the character artwork that is in the array for each iteration. i.imgur.com/yAOghrQ.png the red squares are the 3 iterations and the last iteration is what is being drawn. the images have to be in an image loader because they need to load in a specific manner so it stacks correctly
– timeba
Mar 28 at 4:03
Just using the same images for now as a place holder. After i get them to display correctly I will pull it dynamically from a database. Ill be honest I don't really know how the promise works
– timeba
Mar 28 at 4:10
Thanks ill see what i can try and figure out from your example
– timeba
Mar 28 at 4:16
what you need to remember is ... Promise .then is called asynchronously - so you need to take that into consideration
– Jaromanda X
Mar 28 at 4:19
|
show 3 more comments
by the time theimageSources.map(ii => loadImage(ii))promises have resolved, i.e. before the .then callback is called, thefor (var i = 0; i < item.length; ++i)loop will have completed, anditerwill be 2 ... the big hint that you are doing it wrong is thatpos 2 -> 2is logged before anydrawis logged out - you'll need to rethink your code considerably - I can't even imagine what you're trying to achieve in what order
– Jaromanda X
Mar 28 at 3:53
I'm trying to draw the character artwork that is in the array for each iteration. i.imgur.com/yAOghrQ.png the red squares are the 3 iterations and the last iteration is what is being drawn. the images have to be in an image loader because they need to load in a specific manner so it stacks correctly
– timeba
Mar 28 at 4:03
Just using the same images for now as a place holder. After i get them to display correctly I will pull it dynamically from a database. Ill be honest I don't really know how the promise works
– timeba
Mar 28 at 4:10
Thanks ill see what i can try and figure out from your example
– timeba
Mar 28 at 4:16
what you need to remember is ... Promise .then is called asynchronously - so you need to take that into consideration
– Jaromanda X
Mar 28 at 4:19
by the time the
imageSources.map(ii => loadImage(ii)) promises have resolved, i.e. before the .then callback is called, the for (var i = 0; i < item.length; ++i) loop will have completed, and iter will be 2 ... the big hint that you are doing it wrong is that pos 2 -> 2 is logged before any draw is logged out - you'll need to rethink your code considerably - I can't even imagine what you're trying to achieve in what order– Jaromanda X
Mar 28 at 3:53
by the time the
imageSources.map(ii => loadImage(ii)) promises have resolved, i.e. before the .then callback is called, the for (var i = 0; i < item.length; ++i) loop will have completed, and iter will be 2 ... the big hint that you are doing it wrong is that pos 2 -> 2 is logged before any draw is logged out - you'll need to rethink your code considerably - I can't even imagine what you're trying to achieve in what order– Jaromanda X
Mar 28 at 3:53
I'm trying to draw the character artwork that is in the array for each iteration. i.imgur.com/yAOghrQ.png the red squares are the 3 iterations and the last iteration is what is being drawn. the images have to be in an image loader because they need to load in a specific manner so it stacks correctly
– timeba
Mar 28 at 4:03
I'm trying to draw the character artwork that is in the array for each iteration. i.imgur.com/yAOghrQ.png the red squares are the 3 iterations and the last iteration is what is being drawn. the images have to be in an image loader because they need to load in a specific manner so it stacks correctly
– timeba
Mar 28 at 4:03
Just using the same images for now as a place holder. After i get them to display correctly I will pull it dynamically from a database. Ill be honest I don't really know how the promise works
– timeba
Mar 28 at 4:10
Just using the same images for now as a place holder. After i get them to display correctly I will pull it dynamically from a database. Ill be honest I don't really know how the promise works
– timeba
Mar 28 at 4:10
Thanks ill see what i can try and figure out from your example
– timeba
Mar 28 at 4:16
Thanks ill see what i can try and figure out from your example
– timeba
Mar 28 at 4:16
what you need to remember is ... Promise .then is called asynchronously - so you need to take that into consideration
– Jaromanda X
Mar 28 at 4:19
what you need to remember is ... Promise .then is called asynchronously - so you need to take that into consideration
– Jaromanda X
Mar 28 at 4:19
|
show 3 more comments
1 Answer
1
active
oldest
votes
I would recommend moving function loadImage outside the loop
If you use let instead of var and move the declaration of pos and iter inside the for loop, then it should work
function loadImage(imagePath)
return new Promise((resolve, reject) =>
let image = new Image();
image.addEventListener("load", () =>
resolve(image);
);
image.addEventListener("error", (err) =>
reject(err);
);
image.src = '../interface/images/body/' + imagePath;
);
for (let i = 0; i < item.length; ++i)
let pos="";
let iter="";
// rest of your code remains unchanged
This now works as intended! Thanks again for all your help!
– timeba
Mar 28 at 4:32
add a comment |
Your Answer
StackExchange.ifUsing("editor", function ()
StackExchange.using("externalEditor", function ()
StackExchange.using("snippets", function ()
StackExchange.snippets.init();
);
);
, "code-snippets");
StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "1"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);
else
createEditor();
);
function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader:
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
,
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);
);
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55389889%2fhtml5-canvas-drawing-an-image-set-in-for-loop-only-draws-the-last-iteration-imag%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
I would recommend moving function loadImage outside the loop
If you use let instead of var and move the declaration of pos and iter inside the for loop, then it should work
function loadImage(imagePath)
return new Promise((resolve, reject) =>
let image = new Image();
image.addEventListener("load", () =>
resolve(image);
);
image.addEventListener("error", (err) =>
reject(err);
);
image.src = '../interface/images/body/' + imagePath;
);
for (let i = 0; i < item.length; ++i)
let pos="";
let iter="";
// rest of your code remains unchanged
This now works as intended! Thanks again for all your help!
– timeba
Mar 28 at 4:32
add a comment |
I would recommend moving function loadImage outside the loop
If you use let instead of var and move the declaration of pos and iter inside the for loop, then it should work
function loadImage(imagePath)
return new Promise((resolve, reject) =>
let image = new Image();
image.addEventListener("load", () =>
resolve(image);
);
image.addEventListener("error", (err) =>
reject(err);
);
image.src = '../interface/images/body/' + imagePath;
);
for (let i = 0; i < item.length; ++i)
let pos="";
let iter="";
// rest of your code remains unchanged
This now works as intended! Thanks again for all your help!
– timeba
Mar 28 at 4:32
add a comment |
I would recommend moving function loadImage outside the loop
If you use let instead of var and move the declaration of pos and iter inside the for loop, then it should work
function loadImage(imagePath)
return new Promise((resolve, reject) =>
let image = new Image();
image.addEventListener("load", () =>
resolve(image);
);
image.addEventListener("error", (err) =>
reject(err);
);
image.src = '../interface/images/body/' + imagePath;
);
for (let i = 0; i < item.length; ++i)
let pos="";
let iter="";
// rest of your code remains unchanged
I would recommend moving function loadImage outside the loop
If you use let instead of var and move the declaration of pos and iter inside the for loop, then it should work
function loadImage(imagePath)
return new Promise((resolve, reject) =>
let image = new Image();
image.addEventListener("load", () =>
resolve(image);
);
image.addEventListener("error", (err) =>
reject(err);
);
image.src = '../interface/images/body/' + imagePath;
);
for (let i = 0; i < item.length; ++i)
let pos="";
let iter="";
// rest of your code remains unchanged
edited Mar 28 at 4:23
answered Mar 28 at 4:11
Jaromanda XJaromanda X
38.8k4 gold badges36 silver badges57 bronze badges
38.8k4 gold badges36 silver badges57 bronze badges
This now works as intended! Thanks again for all your help!
– timeba
Mar 28 at 4:32
add a comment |
This now works as intended! Thanks again for all your help!
– timeba
Mar 28 at 4:32
This now works as intended! Thanks again for all your help!
– timeba
Mar 28 at 4:32
This now works as intended! Thanks again for all your help!
– timeba
Mar 28 at 4:32
add a comment |
Got a question that you can’t ask on public Stack Overflow? Learn more about sharing private information with Stack Overflow for Teams.
Got a question that you can’t ask on public Stack Overflow? Learn more about sharing private information with Stack Overflow for Teams.
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55389889%2fhtml5-canvas-drawing-an-image-set-in-for-loop-only-draws-the-last-iteration-imag%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
by the time the
imageSources.map(ii => loadImage(ii))promises have resolved, i.e. before the .then callback is called, thefor (var i = 0; i < item.length; ++i)loop will have completed, anditerwill be 2 ... the big hint that you are doing it wrong is thatpos 2 -> 2is logged before anydrawis logged out - you'll need to rethink your code considerably - I can't even imagine what you're trying to achieve in what order– Jaromanda X
Mar 28 at 3:53
I'm trying to draw the character artwork that is in the array for each iteration. i.imgur.com/yAOghrQ.png the red squares are the 3 iterations and the last iteration is what is being drawn. the images have to be in an image loader because they need to load in a specific manner so it stacks correctly
– timeba
Mar 28 at 4:03
Just using the same images for now as a place holder. After i get them to display correctly I will pull it dynamically from a database. Ill be honest I don't really know how the promise works
– timeba
Mar 28 at 4:10
Thanks ill see what i can try and figure out from your example
– timeba
Mar 28 at 4:16
what you need to remember is ... Promise .then is called asynchronously - so you need to take that into consideration
– Jaromanda X
Mar 28 at 4:19