Results 1 to 6 of 6

Thread: Package Errors

  1. #1

    Package Errors

    Im new to flash as3 and all. So my problem is I cant get this package business to work. I get error 1120 for some instance names that are on my stage, and I dont know how to tie the .fla and the .as together. I know there has to be a main.as or a main class for the .fla which ive made ,but dont know what to put in it. This is my code so far:

    http://www.sendspace.com/file/eq6hq7

    Please help me.

  2. #2
    Throw the ship.as file or comment out the shipo references in the class file.

    You can start by accessing the ship in the main class like this:

    Code:
    package {
        import flash.display.MovieClip;
        import flash.events.KeyboardEvent;
        import flash.events.Event;
    
    
        public class Main extends MovieClip
        {
            
            public function Main()
            {
                stage.addEventListener(Event.ENTER_FRAME, setShipToMousePos);
            }
            
            private function setShipToMousePos(e:Event)
            {
                //trace("hello");
                var ship = this.getChildByName("shipo");
                ship.x = mouseX;
                ship.y = mouseY;
            }
        }
    }
    Last edited by lnsiu; May 9th, 2012 at 05:10 AM.

  3. #3
    Im going to try that thank you. And by referencing do you mean add something in the Main like:
    this is that or this=stage.(name).

  4. #4
    Quote Originally Posted by UnstableP View Post
    Im going to try that thank you. And by referencing do you mean add something in the Main like:
    this is that or this=stage.(name).
    I'm not sure what you mean? You already put the Main.as class as the document class in the file I downloaded from you. So "this" in your Main.as would reference to the main timeline in you .fla file.

    The errors you got came from errors in the ship.as file. And from what I could see you didn't use that class at all?

  5. #5
    Quote Originally Posted by lnsiu View Post
    I'm not sure what you mean? You already put the Main.as class as the document class in the file I downloaded from you. So "this" in your Main.as would reference to the main timeline in you .fla file.

    The errors you got came from errors in the ship.as file. And from what I could see you didn't use that class at all?

    I wanted to add controls for the ship in the ship.as and controls for the laser in the laser.as. So I was asking if there could be a way(because only the main can see the stage) if I could tie the fla to the main and tie the other classes to the stage too but they also comply with the main too

  6. #6
    You can access the ref to stage from within the ship.as class.
    Not so pretty, but this works.

    Code:
    package {
    
    
        import flash.display.MovieClip;
        import flash.events.Event;
    
    
    
    
        public class ship extends MovieClip
        {
    
    
    
    
            public function ship() {
                
                stage.addEventListener(Event.ENTER_FRAME,gogo);
                function gogo(e:Event):void
                {
                    parent.getChildByName("shipo").x=parent.mouseX;
                    parent.getChildByName("shipo").y=parent.mouseY;
                }
            }
            
        }
    
    
    }

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

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

Home About kirupa.com Meet the Moderators Advertise

 Link to Us

 Credits

Copyright 1999 - 2012