ReferenceError: Error #1056: Cannot create property
Quite often, I do projects where I do the code and somebody else do the graphics. I usually set this up so that the designer can work in Flash CS3, whereas I do my code in Flex Builder. I set my class to be the Document Class and then set the FLA to not "Automatically declare stage instances" so I can reference the animators MovieClips inside my code.
Today I got an error that I've also gotten on a couple other occasions and I thought I'd blog the solution here for future reference.
This is the error:
ReferenceError: Error #1056: Cannot create property anim1 on Bynett. at flash.display::Sprite/constructChildren() at flash.display::Sprite() at Bynett()
By default, I usually set all properties in a class to "private". This error will occur if you set a MovieClip to "private" when it should have been "public". What happens is that since the MovieClip is set to private, the Flash CS3 environment won't have the required access to this clip. Just make sure that all objects that the designer will control is set to "public" and all is fine.
(Thanks to Kadazuro for reminding me of the solution!)
Comments
I think this issue is bad design from Adobe:it forces you to expose members, while they, as makers of the whole Flash thing should have been able to write some backdoor compile thing to set the private member.
Posted by: Macaca | September 7, 2008 11:38 AM
Another reason this error can show up is if you have "Automatically declare stage instances" turned off in your AS settings.
Posted by: Jim | September 10, 2008 10:58 PM
Weird, I'm getting this error but the instance is public and "Automatically detect stage instances" is turned on.
It seems to be caused by a dynamic textfield inside it which was created in the Flash IDE. I figured maybe I needed to declare it as a property of the class, but then Flash tells me it can't be declared twice. I'm stumped.
Posted by: Anonymous | September 12, 2008 07:06 AM
This post helped me. I got the 1056 error and your post made me understand the problem was that for some reason I didn`t have the "Automatically declare stage instances" checkbox in the publish settings enabled (as it should be by default).
Thank you !!!!
Posted by: 1is0 | September 14, 2008 03:41 AM
Anonymous: then you probably should turn it off? :)
1is0: I love those animations of yours and the button sounds is a instant classic!
J
Posted by: Jensa | September 14, 2008 02:29 PM
I was almost crazy with this 1056 error, I turned on the "Automatically declare stage instances" from publish settings and it finally works! Thanks guys!
Posted by: Erika | October 19, 2008 03:32 AM