ActionScript ReferenceError: Error #1056

ReferenceError: Error #1056: Cannot create property _x on flash.display.Sprite

or

ReferenceError: Error #1056: Cannot create property someVar on flash.text.TextField.

ActionScript 3 Error #1056 Description:
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.  See Bad Code 3.

Flash / Flex Error 1056 Fix:
Simply spell the property correctly or make sure that you are using AS3 Syntax instead of AS2.


Bad Code 1:

var s = new Sprite();
s._x = 100;

Good Code 1:

var s = new Sprite();
s.x = 100;

Bad Code 2:

var t = new Timer(1000, 4);
t.dela = 500;

Good Code 2:

var t = new Timer(1000, 4);
t.delay = 500;

Bad Code 3:

myTextField.someVar = “something”;

This should help you resolve Flex / Flash Error #1056

Thanks and as always Happy Flashing

Curtis J. Morley

Related ActionScript Error(s):
Flash / Flex Error 1119
– You will get AS3 Error 1056 instead of 1119 if you don’t properly type your object before referencing a property on it. For example var s:Sprite = new Sprite(); s._x = 10; will give error 1119 but var s = new Sprite(); s._x = 10; will give Error 1056.
Flash / Flex Error 1151
Flash / Flex Error 1069
– This is the error you will get if you try and call a method with a misspelled name in the same way as calling a property with a misspelled name.

8 thoughts on “ActionScript ReferenceError: Error #1056

  1. Here is another case where this error appears:

    When working with external libraries and using 2 (or more) external libraries that use the same component assets that are themselves imported from external libraries.

    When the code runs through the bad clip first, it tells:
    ReferenceError: Error #1056: Impossible to create the property __id0_ on (…)

    But if it runs through the good clip first, it all works…

  2. I ran into the “ReferenceError: Error #1056: Cannot create property” error when trying to assign a Main class for use in my app.

    I named the “Document Class” as Main
    (this is found on the properties tab)

    In the as file I had the declarations correct:

    package {
    public class Main extends MovieClip {
    public function Main() {
    }
    }
    }

    But this silly thing continued to not work.

    Problem was the capitalization of the file.
    I changed file from main.as to Main.as and it worked just fine — error gone.

    As a windows programmer I typically don’t worry about upper or lower case. In fact, I usually make files as lowercase. Well Flash wants to see the same capitalization.

    Duh, I should have known. But is easy to miss.

    So just mentioning here in case that is your problem too. 🙂

  3. Pingback: curtismorley.com » Update to AS3 Reference Error #1056

  4. Here’s a variation: name a movieclip instance the same as the document class. Don’t declare that same instance in the document class.

    1056 cannot create property [instanceName] on [instanceName].

    Let the hair pulling begin : )

  5. Pingback: Flash/ Flex Error « RIAdobe

  6. Pingback: curtismorley.com

  7. Pingback: curtismorley.com » Flash CS3 / Flex 2 AS3 Error #1119

Comments are closed.