08.30.07
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
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
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.