flash actionscript:
I'm using AS 3 in Adobe Flash 9 Public Alpha. I have a MovieClip named "RandImg" in my Library with an associated "RandImg.as" class file. I'm placing this MC on the stage during design time. This MC contains an instance of another MC with with the instance name of "mcDefault". In the constructor of my RandImg.as class file, if I attempt to reference mcDefault, I get the following error when I try to compile: ReferenceError: Error #1056: Cannot create property mcDefault on RandImg. How do I reference this movie clip in AS 3? Also, if I want to remove mcDefault from memory, but keep the RandImg MC in memory, in the "RandImg.as" class file would I just call: removeChild( mcDefault ); ? Thanks! ~JC
Hi, can you give us a bit of code ... that will help. And did you declare your movieClip before (and outside of) the constructor? Like this i mean: class RandImg{ private var mcDefault:MovieClip; // --> here it is .. mcDefault public function RandImg(){ // --> cunstructor trace("mcDefault path = " + mcDefault); } } If mcDefault is not declare before and outside your constructor, its impossible for your class to access it. Of course you are probably aware of that .. but im trying to figure out what can be the problem .. just guessing. So please give us some code and we will try to help!
Hi, can you give us a bit of code ... that will help. And did you declare your movieClip before (and outside of) the constructor? Like this i mean: class RandImg{ private var mcDefault:MovieClip; // --> here it is .. mcDefault public function RandImg(){ // --> cunstructor trace("mcDefault path = " + mcDefault); } } If mcDefault is not declare before and outside your constructor, its impossible for your class to access it. Of course you are probably aware of that .. but im trying to figure out what can be the problem .. just guessing. So please give us some code and we will try to help!
Hi, can you give us a bit of code ... that will help. And did you declare your movieClip before (and outside of) the constructor? Like this i mean: class RandImg{ private var mcDefault:MovieClip; // --> here it is .. mcDefault public function RandImg(){ // --> cunstructor trace("mcDefault path = " + mcDefault); } } If mcDefault is not declare before and outside your constructor, its impossible for your class to access it. Of course you are probably aware of that .. but im trying to figure out what can be the problem .. just guessing. So please give us some code and we will try to help!
Hi, can you give us a bit of code ... that will help. And did you declare your movieClip before (and outside of) the constructor? Like this i mean: class RandImg{ private var mcDefault:MovieClip; // --> here it is .. mcDefault public function RandImg(){ // --> cunstructor trace("mcDefault path = " + mcDefault); } } If mcDefault is not declare before and outside your constructor, its impossible for your class to access it. Of course you are probably aware of that .. but im trying to figure out what can be the problem .. just guessing. So please give us some code and we will try to help!
Thanks for responding butcho. I did, of course, declare protected var mcDefault:MovieClip; before my constructor with the rest of my variables. I did some more messing around, it appears that in Flash 9 and AS3, the problem is that I can't actually have a named MC inside of a parent movie clip that has an associated class..? If I place mcDefault on the stage inside of RandImg during design time, the swf compiles properly. However, if I give the mcDefault an instance name, and do nothing else different, then I get my compile error: ReferenceError: Error #1056: Cannot create property mcDefault on RandImg. I don't get it; this used to work great in AS2...
Don't see what you're looking for? Try a search.
|