Flash AS3: ReferenceError: Error #1056: Cannot create property
Asked Answered
A

1

17

I am writing something in Flash/ AS3, and I came across this problem:

ReferenceError: Error #1056: Cannot create property txtInput on package.name.DocumentClasss

Basically I have a document class, and I can create instances of movieclips clips and compile without issues. But when I put a input text field ("T" icon in the palette) on the stage, and it refuses to compile, with the above error.

I am not sure if this makes a difference, but I am writing my ActionScript in FlashDevelop, with compilation done in the Flash IDE. I also have both Strict Mode and Warnings Mode selected under Publish Settings -> Flash -> Script -> Settings... -> Errors.

I have searched for solutions to this online, and the only suggestions out there seem to be to not insert the text field on the stag in Flash IDE, and instead dynamically create them in the document class.

Is there a better solution?

Thanks

Alber answered 14/11, 2009 at 12:59 Comment(1)
Post the stacktrace and the line (along with some context) where the error is thrown.Stodge
R
28

It sounds like you have "Automatically declare stage instances" unchecked and thus if you want to add a named instances, you need to declare it in your class

import flash.text.TextField;
...
public var txtInput:TextField;
...

You can find the declare stage instances setting in the flash tab in your movie properties and clicking on "settings" next to Script: Actionscript 3 selectbox.

Personally I always have this unchecked so it forces you to declare the instances in your class and you can better keep track on what's going on.

Rubber answered 14/11, 2009 at 16:53 Comment(3)
Thank you! You were right about having declare stage instances unchecked, that is the behaviour that I wanted. My mistake was that I was declaring the text fields as flash.text.TextField but as TextInput instead. I was stumped because it was giving me a Reference Error instead of a Type Error.Alber
Where is the option: "Automatically declare stage instances" found?Kizzie
if you go to publish settings, select the "flash" tab you should have a "Settings" button next to the selectbox showing "actionscript 3" In this window you can uncheck "automatically declare stage instances"Rubber

© 2022 - 2024 — McMap. All rights reserved.