Ask a Question related to Macromedia Dynamic HTML, Design and Development.
-
Andigo #1
Javascript img declaration loop
Is it possible to create a loop to create a series of new images, rather than
explicitly declaring each. So, rather than the following two lines repeated 75
times for grid1 through grid75 ...
grid1 = new Image();
grid1.src = "images/nav/grid.png";
is it possible instead to do something like this:
for (var i = 1; i < 75; ++i)
{
var myGrid = eval("grid" + i);
myGrid = new Image();
myGrid.src = "images/nav/grid.png";
}
The above code isn't working (or I wouldn't be posting :) ... ) but I'm
unclear whether the concept is flawed or I just haven't gotten the syntax
right. I've tried a handful of other syntax constructions, but they haven't
worked either.
Thanks,
Andy
Andigo Guest
-
javascript array and loop question
I'm passing in a comma delimited list as a parameter to a function. Ex. the argument passed in holds the following values: 1, 2, 3, 4, 5, I need... -
Can a film loop play once, then loop on the last frame(s)?
I need a film loop to play once, then loop playback on the last frame so I can keep the LOOP of the film loop set. This will allow the tell commands... -
Film loop rollovers working with tell sprite, but only if Loop is checked
on mouseWithin me cursor 280 tell sprite 40 --the sprite containing the film loop sprite(60).member = member("networkmapsbuttonroll") --swapping... -
Urgent: Repeat loop and Film loop clash!
Hi All, Scenario I have a script running in which the spelling which was typed in by the student is corrected. The alphabets are moved to... -
loop in javascript
Hi! I have a menu-system in JavaScript. The menu is displayed by two js functions ( DrawMenuBar and DrawSubMenu ). the first function displays... -
Troyan #2
Re: Javascript img declaration loop
The code you posted worked. The problem was the name of the var,
that was always the same. Using that way, you will be creting 75 times
the same variable. I'll need to use an array or declare variables with
diferent names (using eval).
Example with array:
var j,a=new Array();
for (j=0; j<75; j++) {
a[j]=new Image(); a[j].src='images/nav/grid.png';
} //Creates 75 index of the array "a" (0-74).
Example with eval:
var j,tmpV;
for (j=1; j<=75; j++) { varAtual=eval('variabelNumber'+(j+1));
varAtual=new Image(); varAtual.src='images/nav/grid.png';
} //Creates 75 variables with names "varNum1", "varNum2"... till
"varNum75".
[]s
--
- Rio de Janeiro, Brasil
- Troyan <dnunes[at]email[dot]com>
Troyan Guest
-
Andigo #3
Re: Javascript img declaration loop
Thank you very much. I'll give it a try. Regards, Andy
Andigo Guest



Reply With Quote

