ReferenceError: Error #1056 – instance name Error

actionscript-3

I got a Problem with a Movie Clip I add to the Stage in Flash CS4/AS3.

The Flash File consist of two MovieClips, "Inside" and "Outside". The "Inside" Clip is contained by the Outside and has the Instance Name "insideClip". The Clips are attached to Actionscript Class-Files of the same names (Outside and Inside) which are "empty" – they don't do anything, like the ones flash automatically creates.

Adding "Outside" to stage I get the following Error:

ReferenceError: Error #1056: property insideClip in Outside can not be created.
at flash.display::Sprite/constructChildren()
at flash.display::Sprite()
at flash.display::MovieClip()
at gui::Outside()
at MyDocumentClass()

I always have trouble to get to know what Flash and Actionscript actually does behind the scenes – is there any good general ressource which is recommended?

PS.: The code was translated from a version in german — in case I missed a variable name in the translation.

Code:

DOCUMENT CLASS:

package
{        
import flash.display.Sprite;
import flash.display.MovieClip;
import gui.Outside;


public class MyDocumentClass extends MovieClip
{   
    public var aussen:MovieClip;
    public function SelfDeclaredClips()
    {   outside = new Outside();
        outside.y = 100;
        outside.x = 100;
        addChild(outside);}}}

OUTSIDE CLASS:

package gui
{

import flash.display.MovieClip;

public class Outside extends MovieClip
{public function Outside(){}}
}

INSIDE CLASS:

package gui
{

import flash.display.MovieClip;

public class Inside extends MovieClip
{public function Inside(){}}
}

Best Answer

This error occurs when you uncheck the "Declare Stage Instances Automatically" checkbox in the "ActionScript 3.0 Settings" dialogbox and proceed to declare stage instances as private variables in the class associated with the containing MovieClip.

You cannot choose to simply always declare stage instances automatically without forging the use of inheritance in classes linked to MovieClip Symbols. If you have a class APrime which is derived from class A and APrime is linked to a MovieClip Symbol, all stage instances used in the base class A must be manually declared in class A.

OR

AS3 error 1056 appears when you have improperly referenced a property of an object. This will happen when you misspell something or when you reference variables in the AS2 fashion with a leading underscore ( _ ). AS3 error 1056 is actually pretty nice to work with because it tells you exactly what variable didn't work and it tells you which object it didn't work on.

You can also get this error if you try to dynamically assign a variable to an object that doesn't naturally accept one like a textField.

Related Topic