Results 1 to 6 of 6
Thread: Package Errors
-
May 8th, 2012, 08:13 PM #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.
-
May 9th, 2012, 05:08 AM #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.
ECMAscript
-
May 9th, 2012, 07:47 AM #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).
-
May 9th, 2012, 09:02 AM #4
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?
ECMAscript
-
May 9th, 2012, 04:57 PM #5
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
-
May 10th, 2012, 12:55 AM #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; } } } }
ECMAscript

Reply With Quote


Bookmarks