• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
0

stop() not working?

New Here ,
Jul 08, 2012 Jul 08, 2012

Copy link to clipboard

Copied

stop() won't work in the code i want it in or just a new project to test it. it is in the first frame. In both of them it still continues the code and everything works fine.

I used this to test it :

stop();

trace("abc");

And here is the code i'm working on:

    

stop();

addEventListener(Event.ENTER_FRAME,LoadingProgress)

function LoadingProgress(evt:Event){

    if(this.currentFrame == 1){

        var moviebytesloaded:int = this.root.loaderInfo.bytesLoaded

        var moviebytesleft:int = this.root.loaderInfo.bytesTotal

        var movieKloaded = moviebytesloaded / 1024;

        var movieKleft = moviebytesleft / 1024;

        var loadLoc1:int = stage.width / 2;

        var loadLoc2:int = stage.height / 2;

        var loadingText:TextField = new TextField()

       

        loadingText.text = "Loading: "+movieKloaded+"K/ "+movieKleft+"K";

        loadingText.x = loadLoc1;

        loadingText.y = loadLoc2;

        trace("LoadingProgress")

       

        }

    }

var gravity:Number = .0098;

var accelY = 6;

var accelX =10;

var dragX = .5;

ball.x = 10;

ball.y = 10;

addEventListener(Event.ENTER_FRAME,Gravity)

addEventListener(Event.ENTER_FRAME,Throw)

addEventListener(Event.ENTER_FRAME,Drag)

addEventListener(Event.ENTER_FRAME,CheckCollision)

function CheckCollision(evt:Event){

    if (floor.hitTestObject(ball)){

        accelY = 0;

        accelX = 0;

        ball.y + .0098;

        dragX = 0;

       

        }

    }

function Drag(evt:Event){

    ball.x -= dragX;

    }

function Throw(evt:Event){

    ball.x += accelY;

    ball.y += accelX;

    }

function Gravity(evt:Event){

    ball.y -= gravity;

    }

TOPICS
ActionScript

Views

914

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines

correct answers 1 Correct answer

LEGEND , Jul 09, 2012 Jul 09, 2012

The stop() command is a timeline command, not a command to inhibit execution of code. 

If you do not want any other code to execute until a certain time, then you need to not execute any other code until then.  That means you do not want to be assigning things like your various ENTER_FRAME listeners until they are wanted.  Otherwise, they will execute immediately.

Votes

Translate

Translate
Contributor ,
Jul 09, 2012 Jul 09, 2012

Copy link to clipboard

Copied

What do you want to stop here? Can you please explain your problem clearly. I will try to solve that as my level best.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Jul 09, 2012 Jul 09, 2012

Copy link to clipboard

Copied

I'm trying to stop everything so I can put in a loading screen and load the entire thing right away rather than stream it.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Jul 09, 2012 Jul 09, 2012

Copy link to clipboard

Copied

The stop() command is a timeline command, not a command to inhibit execution of code. 

If you do not want any other code to execute until a certain time, then you need to not execute any other code until then.  That means you do not want to be assigning things like your various ENTER_FRAME listeners until they are wanted.  Otherwise, they will execute immediately.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Jul 16, 2012 Jul 16, 2012

Copy link to clipboard

Copied

Thanks that helped me figure it out.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Jul 16, 2012 Jul 16, 2012

Copy link to clipboard

Copied

LATEST

You're welcome

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines