Flash CS3 / Flex 2 AS3 Error #1026

ActionScript Error #1026: Constructor functions must be instance methods.

Description:
You will get Flash / Flex Error 1026 if you have assigned the constructor of a class to be static. What you most likely wanted to do was create a static method within your class that can be called directly from the class itself rather than from an instance of the class. You are probably trying to create something like the Math.round() method within the Math class. This is a static method and can be called directly from the class.

Fix:
Remove the keyword ‘static’ from the constructor function within your class.

Bad Code:

public class MyStaticMethod
{
public static function MyStaticMethod()
{
public static function theRealStaticMethod (inputString):int

Good Code:

public class MyStaticMethod
{
public function MyStaticMethod()
{
public static function theRealStaticMethod (inputString):int

I hope that you didn’t bang your head against the wall with AS3 Error 1026. It is an simple ActionScript Error to fix with a strange description.

Happy Flashing

7 thoughts on “Flash CS3 / Flex 2 AS3 Error #1026

  1. Most of you will have found the error by now I guess, but I thought I’ll post the resolution here for the matter of completion as I just happend to stumble upon the same error myself:
    You get this Error if you try to Export a Symbol as a class which happens to have a MovieClip inside it with the same name. So, here’s my advice: Name every Movieclip, you want to export xxxxMc. The one good thing about that approach is, that you’re always clear about the nature of your classes being movieclips when you see the tailing “Mc”. The other thing is that you can avaid hassles like those. I got my codeless asset.fla fixed and successfully exported it. Thanks for the starter idea.

  2. In fact, I emilinated every single asset out of the project leave one blank layer. It’s got nothing. No code, no images, no nothing. And I STILL get the error. Help!

  3. im getting error 1026, im new to actionscript so i dont know what im doing wrong

    yellow.addEventListener(TimerEvent.TIMER, helloYellow);

    function helloYellow(event:TimerEvent):void
    {
    yellowTgt = new target();
    addChild(yellowTgt);
    yellowTgt.x = random;
    yellowTgt.y = random;
    this.addEventListener(MouseEvent.CLICK, dead);

    function dead(event:MouseEvent):void
    {
    if(cursor.hitTestObject(yellowTgt))
    {
    yellowTgt.removeChild;
    points ++;
    yellowTgt.stop();
    }
    }
    }

  4. I’ve reproduce the same problem with a component who have the same name (filname) as a variable inside.

  5. Hi, good explanation. But I’m getting this error even though my constructor function actually is assigned as “public”. It looks like this:

    package valueObjects
    {
    import flash.utils.*
    import mx.collections.ArrayCollection;
    import mx.rpc.events.FaultEvent;
    import mx.rpc.events.ResultEvent;
    public class Venue
    {
    public function Venue()
    {
    super();
    }

    and so on.

    I’m just hoping you have another idea. Judging from the several other postings of this on the web, this error does seem to pop up for a few reasons other than the stated one.

    Thanks,

    Wayne

Comments are closed.