0
votes

i have got a problem and cannot figure out. Everything is fine when i test the scene, i have added stop(); to my movie clip timeline and everything is fine until no code is added to the main stage. As soon as i start adding code to the stage, it starts looping? Because of this i'm stuck with a problem and cannot even develop further, because even mouse click events wont work of that looping... The code i am trying to add is just a simple move layer off stage after click on play button:

import fl.transitions.Tween;
import fl.transitions.easing.*;
import fl.transitions.TweenEvent;





introScreen.play_btn.addEventListener(MouseEvent.CLICK, clickAway);
    function clickAway(event:MouseEvent):void
    {
        moveScreenOff(introScreen);
    }

    function moveScreenOff(screen:MovieClip):void
    {
        //Move the screen off...
        var introTween = new Tween(screen,"x",Strong.easeInOut,screen.x,(screen.width)*-1,1,true);
        //When the motion has finished...
        introTween.addEventListener(TweenEvent.MOTION_FINISH, tweenFinish);
        function tweenFinish(e:TweenEvent):void
        {
            trace("tweenFinish");
            //Establish the game state...
            gameState = STATE_INIT_GAME;
            trace(gameState);
            //Fire off the gameLoop function at the frame rate of the movie...
            addEventListener(Event.ENTER_FRAME, gameLoop);
        }
    }
1
well the position IS a trainee and they gave me a task to create a basic flash app for android. What do you mean question has no info? There is no code since i came up with this problem prior to starting writing it up so... There is the link to the flash, i would really appreciate if someone can take a look and try to add any code, i was adding mouse event on click to bounce off the intro screen and it won't work ,instead it makes movie loop. filedropper.com/veinsv2ryoukos
As soon as i start adding code to the stage, it starts looping? -> Please show what code you have tried yourself adding. Otherwise, this question will be closed in no time as it has not shown much own effort so far, unfortunately.lpapp
Please edit it into the question. Use the {} code button to indent it.Pekka
i have added the code to the topic.ryoukos

1 Answers

0
votes

The reason your animations are looping continuously is because you have errors in your code.

Access of undefined property gameState.
Access of undefined property STATE_INIT_GAME.
Access of undefined property gameState.
Access of undefined property gameLoop.

You are trying to reference members that haven't been created yet or don't exist. Your main timeline starts at frame 1 with the code you referenced trying to access those variables and the gameLoop method. You need to setup the variables in the first frame to allow them to be referenced. i.e. under your import statements:

import fl.transitions.Tween;
import fl.transitions.easing.*;
import fl.transitions.TweenEvent;

var gameState:String;
const STATE_INIT_GAME:String = "GAME_INIT";

then you need to add the gameLoop function:

function gameLoop(e:Event):void {
    trace('game loop running');
}

If you don't want those variables and that function setup there then you need to go to the frame using gotoAndStop or gotoAndPlay where those functions and variables can be declared and/or initialized, and stored into memory. Then they will be accessible.