Flasher Archive

[Previous] [Next] - [Index] [Thread Index] - [Previous in Thread] [Next in Thread]


Subject: RE: fundamental question
From: Paul Willoughby
Date: Tue, 13 Feb 2001 13:15:36 -0000

Hi Tim,

You're definitely on the right track, but there's a few things you need to
know about before this will work. You'll see in the 'for' loop there are 3
conditions. The first one initialises a variable for counting loops, the
second one sets the limit for the number of loops and the third says how
much to increase the loop counting variable each loop (i++ just means add 1
to i). For the second condition I put in the variable 'totalUnits', but this
doesn't mean anything unless it's initialized somewhere else. Basically,
totalUnits (or whatever you want to call it) needs to refer to the total
amount of 'loc' movie clips in your movie. In fact, you don't even really
need a variable for this. If you know there are 50 'loc' movieclips and it's
not likely to change you could just as easily have:

for(i=1;i<50;i++)

If the number of units is likely to change I'd store this variable in the
text file.

If your movie clips are called loc1, loc2 etc. I wouldn't give the variables
the same name in the text file. Flash shouldn't get confused between the
variable and instance names, but when you're programming you might! Call
them vLoc1, vLoc2 so you know they are variables.

Another thing is your load variables is loading them into level 0. What I
was suggesting was loading them into a target movie clip, because you can
then get the clip to act as soon as it receives the variables. Thinking
about it, loading them into level 0 is probably better, but you would need
some kind of loop to check when the variables are loaded. Add a variable at
the end of your text file something like 'finished=1'. So here's my
(revised) suggestion for setting this up:

3 frames for loading the variables on one layer. It loops round till the
'finished' variable from the text file has loaded -

Frame 1
finished = 0
loadVariablesNum ("text.txt", 0);

Frame 2
No code, just label it "loop"

Frame 3
If(loaded == 1){
play();
}else{
gotoAndPlay("loop");
}

Then in the fourth frame on another layer, put an empty movie clip with
these actions on it (not in the first frame, actually on the object actions
for the movie clip). The onClipEvent(load) means it only acts once -

OnClipEvent(Load){
for(i=1;i<totalunits;i++){

if (_root["vLoc" + i] == "sold")// if the variable value
vLocX is 'sold'...{

_root["loc" + i].gotoAndStop("sold"); //tell the
clip locX to go to sold state

}else if (_root["vLoc" + i] == "unsold")// if the variable
value vLocX is 'unsold'...{

_root["loc" + i].gotoAndStop("unsold"); //tell the
clip locX to go to unsold state

// add a little error handling if the variable contains
neither value

}else{

trace("vLoc" + i " doesn't have a value");
}
}

You might need to remove the comments for this to work properly. The logic
of this is pretty straightforward and it all relys on having movie clips and
variables in a sequence you can loop through. If it doesn't make sense,
stare at it until it does, always works for me :~) Seriously though, I'll be
a lot happier if you learn something from my suggestions than if I'm just
writing it for you.

Cheers!

paul

PS wotz 'lorem'?


> -----Original Message-----
> From: Tim Hawkins [tim [dot] hawkinsatuk [dot] easynet [dot] net (mailto:tim [dot] hawkinsatuk [dot] easynet [dot] net)]
> Sent: 13 February 2001 11:44

>
> loc1=sold&loc2=unsold&loc3=sold
>
> I then placed your code in the first frame of the movie clip.

> and replaced the "mcUnit" with "loc" as i thought this
> referred to the movie
> clip instance name minus numbering ???? as below
>
>
> OnClipEvent(Data){
> for(i=1;i<totalunits;i++){
> if (_root["loc" + i] == "sold"){
> _root["loc" + i].gotoAndStop("sold")
> }else{
> _root["loc" + i].gotoAndStop("unsold")
> }
> }
>
> Followed by a stop action.

> Then added a load variables on the first frame of the main time line
>
> loadVariablesNum ("text.txt", 0);
>
> Followed by a stop action




[Previous] [Next] - [Index] [Thread Index] - [Next in Thread] [Previous in Thread]