Search code examples
actionscript-3objectflash-cs4

(Flash CS4/AS3) Error #1007: Instantiation attempted on a non-constructor


Having a bit of a problem creating an instance of an object. Bear in mind that this is timeline based and NOT an external class…

var foo:Object {
    var a:String;
    var b:String;
}

var new_foo:Object;

function makeFoo():void
{
    new_foo = new foo();
}

function doStuff(e:MouseEvent):void
{
    makeFoo();
}

Everything runs fine until the 'new_foo = new foo();' bit, at which point I get the #1007 error.

Any ideas?


Solution

  • the problem is your object. missing some sintax, here is how to declare a object with two empty strings:

    var foo:Object = {
        a:"",
        b:""
    }