08.30.07

Flash CS3 / Flex 2 AS3 Error #1026

Posted in Computers, Error, errors, Flash, Flex at 10:33 pm by Curtis J. Morley

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 Comments »

  1. Wayne Freeman said,

    December 23, 2007 at 9:02 pm

    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

  2. lecochien said,

    September 4, 2008 at 9:42 am

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

  3. mel said,

    May 6, 2009 at 10:03 am

    So did I. I had a variable name that is exactly the same as document class.

  4. jellybean said,

    January 5, 2010 at 5:20 pm

    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();
    }
    }
    }

  5. Jjjet42 said,

    March 2, 2010 at 12:18 pm

    I have a problem with this and this movieclip has no code on it!

  6. RD said,

    July 20, 2010 at 1:59 pm

    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!

  7. Longway said,

    December 3, 2010 at 4:04 pm

    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.

Leave a Comment