Main Class unable to identify Clips in the Flash IDE
I'm using the Flash IDE with a Main Class(CarouselNew) and for some reason, the objects that are on stage(given instance names) in the the Flash IDE are throwing errors when I try to run the swf. On the most basic level, I have a mc on the stage with an instance name of myContent and just tracing it throws an 1120 error--I added some ADDED_TO_STAGE event code in the initial declaration of the class to make sure that the mcs, like the myContent mc, are on the display list and yet it doesnt work---Also, if I have a mc within the myContent mc with an instance name of mycontainer would I access its properties like this:
That's how I've been doing it until now.
myContent.mycontainer.z = 100;
Can someone help?
I can bypass the first trace error if I explicitly declare the var by using this:
but I don't understand why I would need to do that being its on the stage in the Flash IDE...and I still can't access the mc within that clip with an instance name of mycontainer...get a 1010 error--term is undefined...
public var myContent :MovieClip;
Here is some of the code and the code that throws the first error--
The trace statement throws that error...
public function CarouselNew()
contextMenu = new ContextMenu();
private function init():void
container = new Sprite();
container.x = 450;
container.y = 450;
container.z = 400;
cloudBut.visible = false;
cloudBut.buttonMode = true;
cloudBut.mouseChildren = false;
Last edited by yvillicana; 11-28-2012 at 08:38 PM.
Your class is obviously not a Document class. If that is the case you need to create separate functions or one function where you have those objects from the main timeline as parameters. If you don't use parameters you need to use getters and setters. You need to always declare variables also for objects already on the timeline except when you use a Document class. However, even there if you don't get an error it is good practice to do so.
var a:A1 = new A1();
public class A1 extends MovieClip
public var mc:MovieClip;
public function A1 ():void
public function getInfo(mc:MovieClip):void
Last edited by cancerinform; 11-29-2012 at 10:59 AM.
It's absolutely the Document class and I've never had to declare such variables before...
Here's what I've done: I just removed the graphics from the Flash IDE and created them dynamically and then used MovieClip(root).somemc to deal with any nested clips...
I'm a visual person and prefer using the Flash drawing tools to create/layout my graphical elements...Why the Document class isn't recognizing them I don't know, but frankly I think its ****e.
If you have a MovieClip named mc1 on the main timeline and a MovieClip named mc2 inside mc1 all you need is to write mc1.mc2. Also are you using frames or you have only one frame. Frames can cause all kinds of problems.
just one frame for mc1 (myContent) and a blank container mc, mc2(mycontainer)inside. Yeah, I had been using that dot syntax and it used to work fine...just used that code as it seemed more foolproof.
Another, odd thing has happened..I just had a graphic(not a symbol) on the maintime...main timeline is one frame in length...which I was just using as a guide...well, when I turned it to a guide layer, the whole swf started messing it..parts of the carousel disappeared and all Mouse events were non-functional....
Anyhow, I fixed that by turning the graphic into a mc and setting its visibility to false
and the I changed its publish settings to 0 in the jpeg option, so hopefully it's not increasing the size of the swf....
I never encountered any of these strange things before and the carousel had been working fine..was able to access stage instances...actually, I still am apart from those two aforementioned clips I subsequently added...I actually directly copied and pasted the mc2(mycontainer) from another carousel, which I had completed b4(it was papervision and had strange movement on the z-axis, which I couldn't fix...but I also pasted a lot of its code as I wanted this carousel to function likewise....
Any ideas as to what happened? Anyhow, its working now with those weird modifications.
Click Here to Expand Forum to Full Width