Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6804609
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T19:29:15+00:00 2026-05-26T19:29:15+00:00

A guy on this forum told me to use this: Frame skipping on Flash

  • 0

A guy on this forum told me to use this:
Frame skipping on Flash
Instead of doing like thing.x -= 4;

So I did it:

package  {
    import flash.display.MovieClip;
    import flash.events.Event;
    import flash.events.MouseEvent; 
    import flash.utils.getTimer;


    public class Seamine extends MovieClip {

        private var core:Object;

        private var lastFrame:int = 0;
        private var thisFrame:int;
        private var pixelsPerSecond:Number = 100;
        private var percentToMove:Number; 

        public function Seamine():void{

            addEventListener(Event.ADDED_TO_STAGE, onadd);
        }

        private function onadd(e:Event){
            stage.addChild(this);
            addEventListener(Event.ENTER_FRAME, loop);
        }

        private function loop(e:Event):void{

            // Get the miliseconds since the last frame
            thisFrame = getTimer();
            percentToMove = (thisFrame - lastFrame) / 1000;
            // Save the value for next frame.
            lastFrame = thisFrame;
            // Update your system based on time, not frames.
            this.x -= pixelsPerSecond * percentToMove;


            if(this.x < 0 - this.width/2)
            {
                stage.removeChild(this);
                removeEventListener(Event.ENTER_FRAME, loop);
                removeEventListener(Event.ADDED_TO_STAGE, onadd);
            }

            if(GlobalVariables.GameOver == 1)
            {
                this.alpha -= .03;
            }

            if(this.alpha == 0)
            {
                this.alpha = 0;
                stage.removeChild(this);
                removeEventListener(Event.ENTER_FRAME, loop);
                removeEventListener(Event.ADDED_TO_STAGE, onadd);
            }

        }

    }

}

But for some reason, my “Seamine” do take the others x posistion? So it doesn’t start at the beginning. Example.

1 Seamine start, it have the right speed. Next Seamine spawn but this time, it doesn’t start at the “starting x value” because it starts at Seamine 1.

I do spawn the Seamines like this:

var tm_Seamine:Timer = new Timer (2000);

tm_Seamine.addEventListener(TimerEvent.TIMER, Spawn_Seamine);
tm_Seamine.start();

function Spawn_Seamine(e:Event){

    var SM:Seamine = new Seamine();  

    var RandomYValue_1_Box:Number = Math.ceil(Math.random()*500);

    addChild(SM); 
    SM.y = RandomYValue_1_Box;
    SM.x = 1000;    

    addEventListener(Event.ENTER_FRAME, Hit_SM)

    function Hit_SM (e:Event){

        if(SM.hitTestPoint(Player.x,Player.y, true))
        {
            GlobalVariables.GameOver = 1;
        }
    }

}
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-26T19:29:16+00:00Added an answer on May 26, 2026 at 7:29 pm

    getTimer() gets the number of milliseconds since the SWF started running, not the object. So if you’re using that amount of time to calculate the distance to move the object, it will be the same for all of your objects. Hence, all of your objects will move to the same position regardless of when the object was created.

    A simple fix would be to initialize lastFrame with getTimer() instead of 0.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

This question is language agnostic but I am a C# guy so I use
I'm currently doing this query to find the guy who makes the most calls:
I want to set a background image for my form/window like this guy but
Getting the same problem as this guy in the support forum for the parent
I've got pretty much the same problem as this guy: http://www.ruby-forum.com/topic/197440 . I'm trying
So yeah, I'm a Java guy in this crazy iPhone world. When it comes
This is a Windows Console application (actually a service) that a previous guy built
After reading this post I kinda felt in the same position as the guy
Somewhere some guy said (I honestly do not know where I got this from),
I'm a LAMP guy and ended up working this small news module for an

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.