Flash Games

 FAQ   Search   Members   Groups   Register  User Control Panel      Login 

Your time now:
Sat Nov 07, 2009 11:42 pm

All times are UTC + 1 hour




Post new topic Reply to topic  [ 2 posts ]  Bookmark and Share
Author Message
 Post subject: Simple Javascript variable problem
PostPosted: Thu Jun 18, 2009 9:17 am 
Offline

Joined: Thu Jun 18, 2009 9:15 am
Posts: 1
Sorry for actually asking this as it's a ridiculously simple problem, but I'm brand new to JavaScript.
I know how to do what I want to in ActionScript, but I'm not sure what the syntax is to accomplish it in JavaScript.
In ActionScript I've written a chunk of code that looks something like this:

---------------

var currentNumber = 1;
var picture1Video = " firstVideo.jpg";
var picture2Video = " secondVideo.jpg";

placeHolder1.loadMovie(this["picture"+(currentNumber)+"video"])

currentNumber++;

placeHolder2.loadMovie(this["picture"+(currentNumber)+"video"])

---------------


So basically I'm incrimenting currentNumber to change what variable placeHolder1 and placeHolder2 are looking at.

How do I write that in Javascript, so that a variable name being called is made up of a string and the contents of another variable, like ["picture"+currentNumber+"video"] ?

Cheers for any help!


Top
 Profile  
 
 Post subject: Re: Simple Javascript variable problem
PostPosted: Sat Jun 20, 2009 3:20 am 
Offline

Joined: Mon Nov 17, 2008 6:50 am
Posts: 7
I have no idea what actionscript does, but how about an array?

Code:
var arr = new Array("firstvideo.jpg", "secondvideo.jpg");
var idx = 0;

When you need the file, just use its index pos.
Code:
   placeholder.loadMovie(arr[idx]);
   idx++;


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 2 posts ] 

All times are UTC + 1 hour


Who is online

Users browsing this forum: No registered users and 4 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group - Flash Games - TNX Invitation Code - TNX Review


Webmaster - Excruciating - Johnathan - Kotik - Ash - Tomi - rangana - Phate - dflynn - Medley