Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
576 views
in Technique[技术] by (71.8m points)

actionscript 3 - Flash AS3: ReferenceError: Error #1056: Cannot create property

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

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

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.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

1.4m articles

1.4m replys

5 comments

57.0k users

...