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.

About Judah

Please note in the comments if this has helped you or not.
This entry was posted in Compiler. Bookmark the permalink.

One Response to 1026 Constructor functions must be instance methods.

  1. Wayne Freeman says:

    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

Leave a Reply

Your email address will not be published. Required fields are marked *

Highlight your code before posting code:

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong> <pre class="">