Error Parameter Initializer Unknown Or Is Not A Compile-time Constant
Contents |
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 initializer element is not a compile time constant Errors. Compiler Error #1047 1047: Parameter initializer unknown or is not a
Initializer Element Is Not A Compile Time Constant Nsnumber
compile-time constant. This compiler error revolves around ASC's (ActionScript Compiler) inability to resolve variable references for default parameter values initializer element is not a compile time constant c 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 are
Initializer Element Is Not A Compile Time Constant Objective C
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 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 are required
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 Using constants as default http://www.senocular.com/flash/tutorials/compilererrors/ parameter values in interfaces: IDE okay but mxmlc fails? up vote 6 down vote favorite This code seems to compile fine in the IDE, but the command-line compiler (SDK 4.5 mxmlc.exe) reports "Parameter initializer unknown or is not a compile-time constant." senocular gives a good explanation and a maybe-workaround, but I'm hoping for something more elegent (like a command-line instruction). package { public class Constants http://stackoverflow.com/questions/6335890/using-constants-as-default-parameter-values-in-interfaces-ide-okay-but-mxmlc-fa { public static const CONSTANT : int = 0; } } package { public interface IInterface { function foo( param : int = Constants.CONSTANT ) : void; } } package { public class Concrete implements IInterface { public function foo(param:int=Constants.CONSTANT):void { } } } actionscript-3 interface constants share|improve this question asked Jun 13 '11 at 20:25 Richard Haven 7681129 1 Maybe you could try configuration constants? livedocs.adobe.com/flex/3/html/… –cmann Aug 19 '11 at 15:21 Only thing I can think of is to create your own batch type script to pre-process the source before the compiler gets it, but that's probably not the best idea. It would work, though, assuming you got all the bugs out :) –Scott Oct 1 '11 at 6:55 add a comment| 1 Answer 1 active oldest votes up vote 2 down vote According to Senocular, it's all about the compilation order. There's no explicit way to set this order. You could define inline constants using the define compiler option to avoid this problem. Another way would be to create a library containing the constants. Libraries are included before user classes. To create a library use the component compiler:
error has occurred. Right-click for moreinformation. 30 Jul This is another chapter to the amazing errors, which does not leave behind any signals https://shashankkulkarni.wordpress.com/tag/parameter-initializer-unknown-or-is-not-a-compile-time-constant/ how to solve it, and more interestingly what is the exact reason for it. When we have a pretty large code base where many developers check in and check out the code regularly, it is very hard to find the exact cause of the error which comes while compiling the code. Same is not thing happened with me and to find the exact cause and the solution for it took a lot of time and interestingly and amazed feeling why it is happening so, For Demo let’s compile the following code, Case 1: Error :An internal build error has occurred. Right-click for more information is not a