View Full Version : getDefinitionByName() gives error 1065
nate403
November 7th, 2008, 11:25 AM
In my FLA I have a movieclip in the Library named "ContentPanel1". I have it's Linkage properties to export on first frame - class "ContentPanel1" and base class flash.display.MovieClip.
In my code I'm trying to attach an instance of this movieclip:
var instanceClass:Class = getDefinitionByName("ContentPanel1") as Class;
Now, here's the error I get:
ReferenceError: Error #1065: Variable ContentPanel1 is not defined.
at global/flash.utils::getDefinitionByName()
The weird thing is that this DID work, but when I went into Publish Settings > Actionscript Settings and then unchecked the "Automatically Declare Stage Instances" checkbox, now it doesn't work.
Do stage instances need to be automatically declared now in order for this to work?
Nate
senocular
November 7th, 2008, 11:37 AM
they don't have to be automatically be declared, but they do have to be declared. If you don't let the tool do it for you, you'll have to declare them yourself in your code.
Krilnon
November 7th, 2008, 11:43 AM
Is it the case that you don't have any instances of this particular symbol on the stage? If so, then I think that your class is not being compiled into the final SWF because you never use it.
Did you also uncheck "Export in first frame"? I was trying to recreate your situation and I had a symbol that was only in the library whose associated class would not be compiled into the SWF when I unchecked that box. That behavior is expected, though, as a form of optimization. If you don't export the class in the first frame, then you need to have an instance of that class elsewhere in your document.
Edit: …and it looks like I took too long to write this post. :sure:
nate403
November 7th, 2008, 11:44 AM
Thanks senocular! I tried to just test the declaration though like so:
public var test:ContentPanel1;
and got this error:
1046: Type was not found or was not a compile-time constant: ContentPanel1.
nate403
November 7th, 2008, 11:54 AM
Hi Krilnon: well, I did just now put an instance of this onto the stage and I'm still getting the error.
Krilnon
November 7th, 2008, 12:07 PM
Can you compare your document to the one I've attached?
I don't get a similar error.
senocular
November 7th, 2008, 12:10 PM
the type not found error could be a result of you not importing your class if it's in a package?
nate403
November 7th, 2008, 12:29 PM
good point senocular - but how can i import a class that's not really there? it's just applied to the symbol in the Library...
dene22
June 5th, 2009, 09:38 AM
In the symbol properties, check 'Export in frame 1'
that solved it for me.
Powered by vBulletin® Version 4.1.10 Copyright © 2012 vBulletin Solutions, Inc. All rights reserved.