11-02-2007, 01:03 PM
|
#1
|
|
Registered User
Join Date: Oct 2005
Posts: 7
|
Calculating scores between swfs
Hi,
I'm trying to make a game which requires a main swf to calculate 3 scores from 3 different swfs...
My main file is main.swf
The 3 files are level1, level2 and level3
I just need to add the score from each of the above files and depending on the outcome, run an animation on the main.swf.
Can anyone help me with this please?
Thanks in advance
|
|
|
11-02-2007, 02:44 PM
|
#2
|
|
Banned by AS.org Staff
Join Date: Jan 2007
Location: Montréal, Québec
Posts: 14,073
|
Are the files really loaded on other levels, or is that just a figure of speech and the different levels are in fact loaded in a container clip within the main movie?
You should maybe attach your .fla(s).
|
|
|
11-02-2007, 03:41 PM
|
#3
|
|
Registered User
Join Date: Oct 2005
Posts: 7
|
calculating scores
Hi,
Thanks for replying. Please see the Flash files attached, I have the main.swf which declares the score as 0 in the first frame. In the files named level1, level2 and level3, I'm incrementing the score value by 1 if the button on the screen is pressed. Back on the main.swf, I have stated that if the score is 3, trace ("you win")...what am I doing wrong?
Thanks again
|
|
|
11-02-2007, 05:13 PM
|
#4
|
|
Banned by AS.org Staff
Join Date: Jan 2007
Location: Montréal, Québec
Posts: 14,073
|
Try this...
ActionScript Code:
loadMovie("level1.swf",1);
_global.score = 0;
this.onEnterFrame = function(){
trace(_global.score);
if (_global.score == 3){
trace ("you win!")
delete this.onEnterFrame;
// other actions here...
}
};
|
|
|
11-02-2007, 06:16 PM
|
#5
|
|
Registered User
Join Date: Oct 2005
Posts: 7
|
It worked, thanks very much; I really appreciate this! Could I ask what the line
"delete this.onEnterFrame;" does?
|
|
|
11-02-2007, 08:07 PM
|
#6
|
|
Banned by AS.org Staff
Join Date: Jan 2007
Location: Montréal, Québec
Posts: 14,073
|
It deletes the onEnterFrame function, that was used to constantly monitor the value of score, because it's no longer needed, when your condition is met... It's just better practice, to delete unneeded onEnterFrame's, rather than letting them run on, which it will do if you don't delete it, adding unnecessary stress on the processor...
|
|
|
11-03-2007, 10:07 AM
|
#7
|
|
Registered User
Join Date: Oct 2005
Posts: 7
|
Right, I get it now, thanks so much for that
|
|
|
11-03-2007, 04:09 PM
|
#8
|
|
Banned by AS.org Staff
Join Date: Jan 2007
Location: Montréal, Québec
Posts: 14,073
|
Grrrrrrrrrreat!
|
|
|
| Thread Tools |
|
|
| Display Modes |
Rate This Thread |
Linear Mode
|
|
Posting Rules
|
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is Off
|
|
|
All times are GMT. The time now is 09:28 AM.
///
|
|