Copy link to clipboard
Copied
I get a “Nan” error on score counter to when player has choose level from menu
I made a score counter and if has player start level 1 and if has win,counter is keep working to next level.( Level = frame ) it's not exist any issue so far.
But when player has choice to level on menu and start level 2,counter is not work.Level 2 start from to frame 116.I get a "NaN" error.
I write a code like this scrore frame 1
var Scorecounter:Number = 0;And Score_t1 it's a dynamic text.Use counter code on frame one
function checkButtonsone():void { if(fisoneclicked21 && fistwoclicked) { Scorecounter = Scorecounter + 10; Score_t1.text = (Scorecounter).toString(); acmessage.visible = true; acmessage.play(); gotoAndPlay(116);//LEVEL 2 } }and on level 2
function checkButtonponelev2():void { if(fish1clickedleveltwo && fishtwoclickedleveltwo && fishthreeclickedleveltwo) { Scorecounter = Scorecounter + 10; Score_t1.text = (Scorecounter).toString(); famessage.visible = true; famessage.play(); } }I'm not using keyframe beetwen two levels.So score frame continue until last frame.(285)
Message was edited by: Burak Ozyurt / I fix some issue
Here is the Solution.
Well, I've no idea why timeline scripting not working for you (you might want to trace Scorecounter if it inits though), but I can suggest a "global" variable solution. Create a class file ScoreHolder.as and put it in the same folder as your *.fla
package
{
public class ScoreHolder
{
static public var score:Number = 0;
}
}
Then import it in any frame where you want to access the score value:
import ScoreHolder;
function checkButtonsone():void
{
if (fisoneclicked21 && fi
Copy link to clipboard
Copied
where's the level 2 code?
is that in a loaded swf?
Copy link to clipboard
Copied
No. Levels are at same time line just start at diffrent frames.
//Score Frame 1 line
var Scorecounter:Number = 0;
I'm using code for each fish like this.
//Fish move code
var b3sekseni:Number=7;
var y3sekseni:Number=8;
var speedyuc:Number=75;
stage.addEventListener(Event.ENTER_FRAME,hareketuc);
function hareketuc(oly:Event) {
balik3.x+=b3sekseni;
balik3.y+=y3sekseni;
if ((balik3.x>=stage.stageWidth-balik3.width/2)|| (balik3.x <= balik3.width/2 )) {
b3sekseni*=-1;
}
if ((balik3.y>=stage.stageHeight-balik3.height/2)|| (balik3.y <= balik3.height/2 )) {
y3sekseni*=-1;
}
}
balik3.mouseEnabled = false;
//Enabled for mause
balik1.mouseEnabled = true;
balik2.mouseEnabled = true;
balik3.mouseEnabled = true;
//The fishes stop moving and player make his choice.
stop();
stage.removeEventListener(Event.ENTER_FRAME, hareket);
stage.removeEventListener(Event.ENTER_FRAME, bhareket);
stage.removeEventListener(Event.ENTER_FRAME, hareketuc);
acmessage.visible = false
//Corelattion for true fish
var fisoneclicked21:Boolean = false;
var fistwoclicked:Boolean = false;
balik1.addEventListener(MouseEvent.CLICK, greenButton);
function greenButton(event:MouseEvent):void
{
fisoneclicked21 = true;
checkButtonsone()
}
balik2.addEventListener(MouseEvent.CLICK, redButton);
function redButton(event:MouseEvent):void
{
fistwoclicked = true;
checkButtonsone()
}
function checkButtonsone():void
{
if(fisoneclicked21 && fistwoclicked)
{
Scorecounter = Scorecounter + 10;
Score_t1.text = (Scorecounter).toString();
acmessage = true;
acmessage.play();
gotoAndPlay(116);//LEVEL 2
}
}

Copy link to clipboard
Copied
LEVEL 2
// Move code for fish (balik62)
var x6l2eksen:Number=7;
var y6l2eksen:Number=8;
var speedyl6:Number=75;
stage.addEventListener(Event.ENTER_FRAME,hareket6liki);
function hareket6liki(oly:Event) {
balik62.x+=x6l2eksen;
balik62.y+=y6l2eksen;
if ((balik62.x>=stage.stageWidth-balik62.width/2)|| (balik62.x <= balik62.width/2 )) {
x6l2eksen*=-1;
}
if ((balik62.y>=stage.stageHeight-balik62.height/2)|| (balik62.y <= balik62.height/2 )) {
y6l2eksen*=-1;
}
}
balik62.mouseEnabled = false;
*** Same codes for Level 2.I was put the score counter code for level 2 at my first message.
Copy link to clipboard
Copied
click file>publish settings>swf>and tick 'enable debugging'. retest.
the problematic line number will be in the error message.
what line of code is mentioned in the error message?
and what did you do to trigger the error message (after going to frame 116)?
Copy link to clipboard
Copied
Not exist 'enable debugging' on settings.
Can you watch this video kglad I record my issue.
Copy link to clipboard
Copied
'permit debugging'
Copy link to clipboard
Copied
Nothing seems to any error
Output
Test Movie terminated.
Debug session terminated.
and no compiler errors.
Copy link to clipboard
Copied
i know it's not a compiler error. it's a runtime error.
restest with debugging enabled and trigger the error and explain what you did to trigger the error.
Copy link to clipboard
Copied
Like I say score counter is not counting,if I start at level 2.
I test it with permit debug and output say..
"Test Movie terminated"
Copy link to clipboard
Copied
1. copy and paste the error message.
2. how is checkButtonponelev2() called?
Copy link to clipboard
Copied
1. No any error message at nowhere
2
var fish1clickedleveltwo:Boolean = false;
var fishtwoclickedleveltwo:Boolean = false;
var fishthreeclickedleveltwo:Boolean = false;
balik12.addEventListener(MouseEvent.CLICK, f1l2);
function f1l2(event:MouseEvent):void
{
fish1clickedleveltwo = true;
checkButtonponelev2()
}
balik22.addEventListener(MouseEvent.CLICK, f2l2);
function f2l2(event:MouseEvent):void
{
fishtwoclickedleveltwo = true;
checkButtonponelev2()
}
balik32.addEventListener(MouseEvent.CLICK, f3l2);
function f3l2(event:MouseEvent):void
{
fishthreeclickedleveltwo = true;
checkButtonponelev2()
}
function checkButtonponelev2():void
{
if(fish1clickedleveltwo && fishtwoclickedleveltwo && fishthreeclickedleveltwo)
{
Scorecounter = Scorecounter + 10;
Score_t1.text = (Scorecounter).toString();
acmessage1.visible = true;
acmessage1.play();
}
}
Copy link to clipboard
Copied
so your problem is solved.
Copy link to clipboard
Copied
No.Please watch it video again..if you miss here is. bandicam 2017 01 14 15 31 43 918 - YouTube
Copy link to clipboard
Copied
it looks like you're testing a scene instead the entire movie. test the movie so frame 1 plays before you advance to your 2nd scene.
Copy link to clipboard
Copied
The game have a 2 level I test it all scene as you see at the video.First of,I test a game nonstop.Then test level from menu for level 2.
Offcourse it works when I directed to level1 but is not any problem with that.Player has choice starting from level 2 or over.And the counter is not running when player start level 2.
Copy link to clipboard
Copied
where's that menu located?
Copy link to clipboard
Copied
On the "menusec" scene.So it's on diffrent scene
Copy link to clipboard
Copied
Here is the Solution.
Well, I've no idea why timeline scripting not working for you (you might want to trace Scorecounter if it inits though), but I can suggest a "global" variable solution. Create a class file ScoreHolder.as and put it in the same folder as your *.fla
package
{
public class ScoreHolder
{
static public var score:Number = 0;
}
}
Then import it in any frame where you want to access the score value:
import ScoreHolder;
function checkButtonsone():void
{
if (fisoneclicked21 && fistwoclicked)
{
ScoreHolder.score += 10;
Score_t1.text = ScoreHolder.score.toString();
acmessage.visible = true;
acmessage.play();
gotoAndPlay(116);//LEVEL 2
}
}
Get ready! An upgraded Adobe Community experience is coming in January.
Learn more