Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Westi on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

changing movie clip src using external variables?

Status
Not open for further replies.

iForget

Programmer
Jul 17, 2002
4
US
i have quite a complex vision, perhaps i can get some guidance here...

First off an overview:

There will be a grid of empty movieclips that will be arranged in the movie. These clips will be a place for loading other clips, depending on variables passed from an external txt file. The variables will be the individual characters, spaces, punctuation located in the txt file and the movie clips it loads will be pictures(i.e A for apple, etc). I would prefer not to rely on loadMovie as i will have over 100 or so .swfs to deal with.

So, my questions break down as follows:

1. Can i change the source of the movie clip in flash, similar to using the JS src.object. command or do i need to rely on loadMovie and external .swfs?

2. How do i break down the txt file's sentences into single character variables? I then need to load the movieclip corresponding to each individual letter, including blank clips for spaces.

3. Insted of having a predefined grid of empty movieclips, it would be more elegant to have it dynamicly generate a new clip adjacent to the previous one. Is this feasable?

Anyway, that's enough to get me started. Sorry if my post makes no sense..Thanks for any help:)
 
This shouldn't be too difficult to do.

1 It's probably going to be easier to have multiframe movieclips with a different graphic on every frame - rather than loading in loads of separate clips you rely on just a few which are already within the movie. Then if the 'apple' graphic is needed you just send the clip to that frame with a gotoAndStop().

2 You can take each individual character out of a string by getting the length of the string:

stringLen=mySentence.length;

you can also turn all the characters uppercase here (will become obvious why in a second):

mySentence=mySentence.toUpperCase();

then looping through it retrieving each character's code with:

mySentence.charCodeAt();

then you can use the number returned to send your graphics clip to the right frame ('A' is character code 65 so if you subtracted 64 from each returned character it would send your clip to the right frame alphabetically - assuming A is on the first frame - you'll probably need an ofset built in here though to accomodate spaces and punctuation etc).

3 By using attachMovie() you can pull the graphics clip from the library as and when you need it and position it where you want.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top