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 3494840
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 18, 20262026-05-18T12:03:13+00:00 2026-05-18T12:03:13+00:00

I have an annoying problem. I’ve googled a bit and can’t really find any

  • 0

I have an annoying problem. I’ve googled a bit and can’t really find any good answers, so I’m hoping to find some help here.

I’m getting this error, which seems to be fairly common:

TypeError: Error #1006: update är inte en funktion.  // = update is not a function (english)
at se.qmd.spaceInvaders::ShipHandler/onEnterFrame()

Update definently is a function, so I really can’t understand what the problem is.

My setup. I’m using Flashdevelop. I have a Main class, which is set as the document class in my fla file.
I have a package structure with my Main class in the src folder, and my subclasses in se.qmd.spaceInvaders and se.qmd.starLight. I also use TweenMax and keep it in the “normal” package structure from the src folder.

In the Main class I add to the stage an instance of the class LeGun – which is also an “exported” movieclip in the fla file, an instance of the class StarHandler and an instance of the class ShipHandler. I also have a keyboard listener which with the help of an enterframe function moves my instance of the LeGun class.
Fine, no problems. The StarHandler works like it should, and the ShipHandler works as it should up until i call 1 or 2 methods in the Ship class – which is also an “exported” movieclip in the fla file. The Ship class is of course the class that contains the Ship that is handled by the ShipHandler.

I’m including my ShipHandler and Ship classes below, and hope it doesn’t make the post excede some length.
ShipHandler.as :

package se.qmd.spaceInvaders {

import flash.display.MovieClip;
import se.qmd.spaceInvaders.Ship;
import flash.display.Stage;
import flash.events.Event;

public class ShipHandler extends MovieClip {

    private var _shipArray:Array = [];
    private const NUM_START_SHIPS:int = 25;
    private var s:Stage = null;

    private var _directionX:Number = 1;
    private var _directionY:Number = 1;
    private var _velocityX:Number;
    private var _velocityY:Number;

    private const YBORDER_TOP:int = 50;
    private const YBORDER_BOTTOM:int = 525;

    public function ShipHandler(o:Stage) {

        s = o; // tar emot stage från main
        createObjects();

        this.addEventListener(Event.ENTER_FRAME, onEnterFrame);
    }   

    private function createObjects():void {

        for (var i:int = 0; i < NUM_START_SHIPS; i++) {

            var aShip:Ship = new Ship();
            aShip.x = Math.random() * (s.stageWidth - aShip.width) + aShip.width / 2;
            aShip.y = Math.random() * (s.stageHeight - aShip.height -135) + aShip.height / 2 + 55;
            this.addChild(aShip);
            _shipArray.push(aShip);
            aShip.startMove(Math.random(), Math.random());
        }           
    }   

    private function onEnterFrame(e:Event):void {

        for (var i:int = 0; i < _shipArray.length; i++) {

            var aShip:Ship = _shipArray[i] as Ship;
            aShip.update();
        }   
    }
}
}

Ship.as :

package se.qmd.spaceInvaders {

import flash.display.MovieClip;
import flash.events.Event;

public class Ship extends MovieClip {

    private var _directionX:Number = 1;
    private var _directionY:Number = 1;
    private var _velocityX:Number;
    private var _velocityY:Number;

    private const YBORDER_TOP:int = 50;
    private const YBORDER_BOTTOM:int = 525;

    public function Ship() {

        //s = o; // tar emot stage  
        this.addEventListener(Event.ADDED_TO_STAGE, onAddedToStage);
    }

    private function onAddedToStage(e:Event):void {

        removeEventListener(Event.ADDED_TO_STAGE, onAddedToStage);

        this.width = 50;
        this.height = 18;           
    }

    public function update():void {

        // x led vänster kant
        if(this.x <= this.width / 2) {

            this.x = this.width / 2;
            _directionX *= -1;
        }

        // x led höger kant
        if(this.x >= 800 - this.width / 2) {

            this.x = 800 - this.width/2;
            _directionX *= -1;
        }

        // y led top kant
        if(this.y <= YBORDER_TOP + this.height/2) {

            this.y = YBORDER_TOP + this.height / 2;
            _directionY *= -1;
        }

        // y led botten kant
        if(this.y >= YBORDER_BOTTOM - this.height/2) {

            this.y = YBORDER_BOTTOM - this.height / 2;
            _directionY *= -1;
        }

        this.x += _velocityX * _directionX;
        this.y += _velocityY * _directionY;
    }

    public function startMove(directionX:Number, directionY:Number):void {

        trace(directionX, directionY);
        _velocityX = 10;
        _velocityY = 10;

        if (directionX < 0.5) {

            _directionX = -1;
        }

        if (directionY < 0.5) {

            _directionY = -1;
        }
    }

    public function changeDirection():void {

        _directionX *= -1;
        _directionY *= -1;
    }   
}
}

As soon as i call either the methods startMove or update from the ShipHandler, i get the error i wrote above.
Would appreciate any help as it seems to me I must be doing something fundamentally wrong…

  • 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-18T12:03:14+00:00Added an answer on May 18, 2026 at 12:03 pm

    It sounds to me like Ship is just a MovieClip (which is a dynamic class and hence the compiler is not complaining when you’re trying to access a method that does not exist at compile-time.) MovieClips don’t have an update() method, so when you try to invoke it, it cannot be found on the Ship instance.

    Is the MovieClip in your FLA file really exported as se.qmd.spaceInvaders.Ship (and not just Ship)? If it’s just Ship, that would explain why your written class is not assigned as the class of your ship graphics, leaving it to be just a simple MovieClip which would explain this error.

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

Sidebar

Related Questions

I have come across an annoying problem while writing some PHP4 code. I renamed
I have a very annoying problem and I'm trying to find the simplest solution
Hey guys, I have another really annoying problem in IE. I am using a
I have a simple but realy annoying problem: I just can't manage to type
I have this annoying problem with Internet Explorer. First some code, so it will
I have a really annoying problem. My app is published in the AppStore. Everytime
At my company we have a really annoying problem with our linker (ld 2.17).
I have recently discovered an annoying problem in some large program i am developing;
I have this annoying problem. I've used some kind of key combination and now
I have an interesting/annoying problem with some VBScripts running on Windows 2003 Server (they

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.