Packages Cannot Be Nested Error
Contents |
here for a quick overview of the site Help Center Detailed answers to any questions you might have Meta Discuss the workings and policies of this site About Us Learn more package cannot be nested in actionscript 3 about Stack Overflow the company Business Learn more about hiring developers or posting
As3 Packages
ads with us Stack Overflow Questions Jobs Documentation Tags Users Badges Ask Question x Dismiss Join the Stack Overflow Community Stack Overflow is a community of 6.2 million programmers, just like you, helping each other. Join them; it only takes a minute: Sign up ActionScript 3 Error 1037: Packages cannot be nested up vote 0 down vote favorite I am new to AS3. When learning AS3, I get the below code from an Adobe example and trying to run it gives an error like "1037: Packages cannot be nested." What does this mean? Please tell me how to execute? or any problem in this code? package { import flash.display.Sprite; import flash.text.TextField; import flash.text.TextFieldType; public class TextField_alwaysShowSelection extends Sprite { public function TextField_alwaysShowSelection() { var label1:TextField = createTextField(0, 20, 200, 20); label1.text = "This text is selected."; label1.setSelection(0, 9); label1.alwaysShowSelection = true; var label2:TextField = createTextField(0, 50, 200, 20); label2.text = "Drag to select some of this text."; } private function createTextField(x:Number, y:Number, width:Number, height:Number):TextField { var result:TextField = new TextField(); result.x = x; result.y = y; result.width = width; result.height = height; addChild(result); return result; } } } actionscript-3 share|improve this question edited Jul 11 '11 at 2:40 phwd 17.8k43664 asked Feb 13 '09 at 8:04 naveen 53151224 add a comment| 5 Answers 5 active oldest votes up vote 1 down vote accepted Your code should compile, provided that it is in the root source folder ("src" in flex builder). Are you sure that's the entire file? The error means that you have nested a package {} statement inside another package {} statement. share|improve this answer answered Feb 13 '09 at 8:17 Richard Szalay 54.8k14126180 add a comment| up vote 2 down vote You need to create an action script file and then add that class to document class in your fla file property then it would not give you an error share|improve this answer answered Nov 18 '11 at 19:28 Sraven Kumar Kande 212 add a comme
here for a quick overview of the site Help Center Detailed answers to any questions you might have Meta Discuss the workings and policies of this site About Us Learn more about Stack Overflow the company Business Learn more about hiring developers or posting ads with us Stack Overflow Questions Jobs Documentation Tags Users Badges Ask Question x Dismiss Join the Stack Overflow Community Stack Overflow is a community of 6.2 million programmers, just like you, helping each other. Join them; it only takes a minute: Sign up What does “Packages cannot be nested” in AS3 mean? up vote 0 down vote favorite I got the complie error "Packages cannot be nested". What does it mean, and how do I http://stackoverflow.com/questions/545124/actionscript-3-error-1037-packages-cannot-be-nested fix it? actionscript-3 flash nested package share|improve this question asked Dec 19 '13 at 20:18 user3040958 125 add a comment| 1 Answer 1 active oldest votes up vote 0 down vote While you can have more than one Class, you should only have a single Package in each of your .as files. Check your .as files to see if you have more than one instance of Package. Update based on OP's comments: You cannot use Packages or Classes on the http://stackoverflow.com/questions/20690888/what-does-packages-cannot-be-nested-in-as3-mean timeline. You need to place that code in an external file and link to it either by making it your Document Class or by assigning it to a symbol in your library via the Class property in the properties panel. share|improve this answer edited Dec 21 '13 at 20:11 answered Dec 19 '13 at 21:11 Marcela 3,5231819 There was only one. I added the script directly to the file instead of importing/including. –user3040958 Dec 20 '13 at 17:06 What do you mean when you say you "added the script directly to the file"? Do you mean that you copied/pasted code? If so, it's possible that the file you created (depending on the IDE you're using) automatically created a package for you and when you pasted the code you added a second package. –Marcela Dec 21 '13 at 0:19 Yes, I copy pasted the code into the fla file. So now the code is in frame 1 of the mainscreen. –user3040958 Dec 21 '13 at 12:48 add a comment| Your Answer draft saved draft discarded Sign up or log in Sign up using Google Sign up using Facebook Sign up using Email and Password Post as a guest Name Email Post as a guest Name Email discard By posting your answer, you agree to the privacy policy and terms of service. Not the answer you're looking for? Browse other questio
Art Jam & Audio News | #Inktober "1037: Packages cannot be nested" 5,268 Views 7 Replies New Topic Respond to this Topic « Return http://www.newgrounds.com/bbs/topic/1119830 to Game Development Forum Forum Index Havegum Havegum Member since: Oct. 20, 2008 Offline. Send Private Message Browse All Posts (3,659) Block Forum Stats Member Level 24 Melancholy "1037: Packages cannot be nested" 2009-11-06 17:23:51 Reply OMFG!!!!!! im finaly taking everybodys advice and converting to AS3, but I always get the error:1037: Packages cannot be nested At the cannot be end I copied the code directly into my flash and i got the same error -.- AS3, on main timeline: package { import flash.display.Sprite; import flash.text.TextField; public class Starter_1 extends Sprite { private var tField:TextField; public function Starter_1 () { myTest(); } private function myTest():void { tField = new TextField(); tField.autoSize = "left"; tField.background = true; tField.border = true; cannot be nested tField.x = 20; tField.y = 75; tField.text = "Hello, world"; addChild(tField); } } } TheBoob TheBoob Member since: Apr. 12, 2002 Offline. Send Private Message Browse All Posts (502) Block Forum Stats Member Level 13 Blank Slate Response to "1037: Packages cannot be nested" 2009-11-06 17:30:16 Reply Packages must be in their own AS file. Each class should have its own file named the same as its class name. zrb zrb Member since: Aug. 8, 2006 Offline. Send Private Message Browse All Posts (5,310) Block Forum Stats Member Level 11 Blank Slate Response to "1037: Packages cannot be nested" 2009-11-06 17:31:52 Reply At 11/6/09 05:23 PM, havegum wrote: AS3, on main timeline: You don't write class codes on your main timeline though :\ As for your problem, not too sure. Looks right to me but I have limited knowledge of AS3. Maybe you have to name your package ? School Sux ! || As :Main || As3: Main || Animation: Main || Flash Tutorials || Havegum Havegum Member since: Oct. 20, 2008 Offline. Send