Main Class unable to identify Clips in the Flash IDE
A Flash Developer Resource Site

Results 1 to 5 of 5

Thread: Main Class unable to identify Clips in the Flash IDE

  1. #1
    Senior Member
    Join Date
    Oct 2005
    Posts
    198

    Thumbs down Main Class unable to identify Clips in the Flash IDE

    Hi,

    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:
    Code:
    myContent.mycontainer.z = 100;
    That's how I've been doing it until now.

    Can someone help?

    I can bypass the first trace error if I explicitly declare the var by using this:
    Code:
    public var myContent :MovieClip;
    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...

    Here is some of the code and the code that throws the first error--
    Code:
    public function CarouselNew()
    		{
    			addEventListener(Event.ADDED_TO_STAGE, onAddedToStage);
    
    			function onAddedToStage(evt:Event):void
    			{
    				trace(myContent);
    				removeEventListener(Event.ADDED_TO_STAGE, onAddedToStage);
    			}
    
    			if (stage)
    			{
    				contextMenu = new ContextMenu();
    				contextMenu.hideBuiltInItems();
    				init();
    				loadXML();
    				//addChild(myContent);
    
    			}
    			else
    			{
    				addEventListener(Event.ADDED_TO_STAGE,init);
    			}
    
    		private function init():void
    		{
    			container = new Sprite();
    			container.x = 450;
    			container.y = 450;
    			container.z = 400;
    			addChild(container);
    			cloudBut.visible = false;
    			cloudBut.buttonMode = true;
    			cloudBut.mouseChildren = false;
    
    			//cover.addEventListener(MouseEvent.CLICK, stageClick);
    			removeEventListener(Event.ADDED_TO_STAGE, init);
    			this.addEventListener(Event.ENTER_FRAME, loop);
    		}
    The trace statement throws that error...

    Thanks,
    ---Yvette
    Last edited by yvillicana; 11-28-2012 at 08:38 PM.

  2. #2
    Mod cancerinform's Avatar
    Join Date
    Mar 2002
    Location
    press the picture...
    Posts
    13,440
    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.
    In fla:
    PHP Code:
    var a:A1 = new A1();
    a.getInfo(mc); 
    class file
    PHP Code:
    package 
    {
        
    import flash.display.MovieClip;
        public class 
    A1 extends MovieClip
        
    {
            public var 
    mc:MovieClip;
            public function 
    A1 ():void
            
    {
                
    trace("A1:"+stage);//null
                
    trace(mc);//null
            
    }
            public function 
    getInfo(mc:MovieClip):void
            
    {
                
    trace("A1"+mc);//Object MovieClip
            
    }
        }

    Last edited by cancerinform; 11-29-2012 at 10:59 AM.
    - The right of the People to create Flash movies shall not be infringed. -
    | www.Flashscript.biz | Flashscript Biz Classes/Components |

  3. #3
    Senior Member
    Join Date
    Oct 2005
    Posts
    198
    Thanks cancerinform,

    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.

    ---Yvette

  4. #4
    Mod cancerinform's Avatar
    Join Date
    Mar 2002
    Location
    press the picture...
    Posts
    13,440
    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.
    - The right of the People to create Flash movies shall not be infringed. -
    | www.Flashscript.biz | Flashscript Biz Classes/Components |

  5. #5
    Senior Member
    Join Date
    Oct 2005
    Posts
    198
    Hi cancerinform,

    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.

    Thanks,
    ----Yvette

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  




Click Here to Expand Forum to Full Width


HTML5 Development Center

Poll by Flashkit.com