Adobe Flash Error 1119
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 4.7 million programmers, just like you, helping each other. Join them; it only takes a minute: Sign up AS3 - Error 1119: Access of possibly undefined property enemyList through a reference with static type Class. up vote 3 down vote favorite I need to get access to a variable from another class and I keep getting error '1119: Access of possibly undefined property enemyList through a reference with static type Class.' I can't see what I do wrong since my variable is made 'public' and 'static'. class where the variable is made. package classes.enemy { imports ... public class Enemy extends MovieClip { public static var enemyList:Array = new Array(); ** var speed:Number; public function initialize() { var stageReff:Stage = this.stage as Stage; addEventListener("enterFrame", enterFrame); } public function Enemy() { enemyList.push(this); ** this.x = 700; this.y = Math.random()*200 + 50; speed = Math.random()*5 + 5; } //code } } class that needs access to the variable package classes.ship { imports ... public class Bullet extends MovieClip { var speed:Number; public function initialize() { var stageReff:Stage = this.stage as Stage; stage.addEventListener("enterFrame", enterFrame); } //code function enterFrame(e:Event):void { this.x += speed; trace(enemy.enemyList); ** } } } Putted '**' behind the lines where the problem occurs and where the variable is made, just to make it clear. Classes are in different folders (classes > enemy & classes > ship), don't know if that has anything to do with it. Thanks in advance. actionscript-3 share|improve this question asked Jan 2 '12 at 1:17 Robbe Van Winckel 1602514 add a comment| 4 Answers 4 active oldest votes up vote 1 down vote accepted If you want to access a static property, you need to use the class it is defined in: Enemy.enemyList Also make sure the class is imported properly in your ship's class: import classes.enemy.Enemy; share|improve this answer edited Dec 3 '12 at 10:47 answered Jan 2 '12 at 1:30 Kapep 15.8k34974 I assume the lower case enemy is just a typo. If not, I will gladly expand my answer with more information. –Kapep Jan 2 '12 at 1:31 If I do that I get: 1120: Ac
other Adobe products. Flash Player Compiler Errors and How to Fix Them The following lists common compiler errors found with Flash Player and what you can do to fix them. Also available, Runtime Errors. Compiler Error #1047 1047: Parameter initializer unknown or is not a compile-time constant. This compiler error revolves around ASC's (ActionScript Compiler) inability to resolve variable references for default parameter values in parameter lists for functions. Example: public function foo(bar:int = SomeClass.CONSTANT_VALUE):void { ... } In the above example, SomeClass.CONSTANT_VALUE is the parameter initializer (default parameter value). In general, variables http://stackoverflow.com/questions/8696709/as3-error-1119-access-of-possibly-undefined-property-enemylist-through-a-refe are not allowed in parameter lists. Instead, only primitive literals including numbers, strings, booleans, and null/undefined should be used. But exceptions are made as long as they satisfy the following conditions (valid as of Flash 10 version timeframe): The variables are constants, defined with the const keyword ASC has previous knowledge of the constant The second point is the more important http://www.senocular.com/flash/tutorials/compilererrors/ of the two. This can lead to situations where the above example may work sometimes and may not work, producing a 1047 error, others. Situations where it will consistently work include: Use of constants defined in the same class Use of constants native to Flash Player's ActionScript API (e.g. flash.events::Event.COMPLETE) These values are known to exist by the time ASC is comiling the parameter list. Inconsistently working situaitons include: Use of constants defined in classes other than the one specifying the parameter list When a constant is coming from another class, depending on the order in which ASC compiles the classes, the parameter value may not yet be known. If that is the case, a 1047 error will occur. Compiling with ASC directly gives you control over the order of the classes being compiled. When compiling a SWF with something like Adobe Flash Professional, that tool controls the order, sending it to ASC in the background. Logic dictates this order - logic heavily dependant on a dependency analysis of the classes that are to be compiled. This analysis determines what classes
am working on a Flash project where a MovieClip that is contained within another clip needs to get a property from the main timeline of the container clip. http://thedesignspace.net/MT2archives/000542.html
trace(this.parent.someProperty) But this generated an error: 1119: Access of possibly undefined https://www.kirupa.com/forum/showthread.php?348890-Error-1119-Access-of-possibly-undefined-property-etc property someProperty through a reference with static type flash.display:DisplayObjectContainer. I finally found the reason for this in this excellent article by Josh Tynjala. The problem is with "casting". The parent clip must be cast as type "MovieClip" or the compiler will throw that error in strict mode. adobe flash Either of the following two methods will work:MovieClip(this.parent.someProperty);
or (this.parent as MovieClip).someProperty; For the complete explanation of why this is so, see: WHY DOESN'T THE "PARENT" PROPERTY WORK THE SAME IN ACTIONSCRIPT 3? Ads by Google Posted by ellen at October 31, 2008 02:55 PM 8 Comments <
using your existing account on the new forums, check out this thread. Register Help Remember Me? Forum Today's Posts FAQ Calendar Forum Actions Mark Forums Read Quick Links View Forum Leaders What's New? Advanced Search Forum Flash ActionScript 3 Error #1119 Access of possibly undefined property...etc Results 1 to 7 of 7 Thread: Error #1119 Access of possibly undefined property...etc Thread Tools Show Printable Version Subscribe to this Thread… Search Thread Advanced Search Display Linear Mode Switch to Hybrid Mode Switch to Threaded Mode May 13th, 2010,01:44 PM #1 vigordesign View Profile View Forum Posts 42 posts Registered User Error #1119 Access of possibly undefined property...etc Hi there! I'm working in an external .as file which is working with my main .fla. Code is below. I'm getting 7 compiler errors, one each time "Stage" is referenced. I had this problem yesterday(http://www.kirupa.com/forum/showthread.php?t=348842) and the answer for that was to import and change "root" to "Stage"(as you can see in that link. That doesn't work for this file that I'm working with today. Same sort of setup in the .fla, just different content. Here is one of the errors -"1119: Access of possibly undefined property get_error through a reference with static type Class." The others are just the same thing but replace "get_error" with the other functions next to "stage" in the .as. I tried changing "Stage" to "MovieClip(parent)", which I found online, but that threw different errors. I seem to be working in circles and would love to learn the real cause of this. It's hard to wrap my head around at the moment. Here is the external .as you can download the files here http://www.vigormusic.com/rootHelp.zip Code: package{ import flash.system.fscommand; import flash.display.Stage; public class LMS{ public var m_bInit:Boolean; public var m_bValues:Boolean; public var m_strStudentName:String; public var m_strStudentId:String; public var m_strCredit:String; public var m_strComments:String; public var m_nScore:Number; public var m_nSession:Number; public var m_nLastError:Number; public function LMS(){ m_bInit = false; m_bValues = false; m_strStudentName = "