Parameter default value should be constant

I'm porting the Flint particle engine for AS3 to haxe and I'm getting the "Parameter default value should be constant" error in the following code: public function new( minAlpha:Float= 1, maxAlpha:Float = Math.NaN ) { ... the problem is that haxe w…

Viewing 1 to 5 (5 Total)
Parameter default value should be constant

JohnSword

JohnSword
Total Posts: 27
Joined: April 12, 2012

I'm porting the Flint particle engine for AS3 to haxe and I'm getting the "Parameter default value should be constant" error in the following code:

public function new( minAlpha:Float= 1, maxAlpha:Float = Math.NaN )
{ ...

the problem is that haxe wont use the consant variable if it's accessed as a static variable from a class, not even if its defined in the same class.
anyone knows how to do this in haxe?

ps: im using haXe Compiler 2.08

Tags:
Posted on April 12, 2012 at 4:35 PM

singmajesty

singmajesty
Total Posts: 2140
Joined: August 25, 2011

Re: Parameter default value should be constant

I can think of at least two ways this could be solved.

Either you could use Null<Float> instead of Float to allow a null value. That way, the default would be null, and you check for it when applying either the user's setting or the default. Another method would be to use something like -1 as the value, which doesn't make sense in terms of a user value for alpha, so you could check for an alpha of -1 to apply the default, or not.

Lastly, if it doesn't affect anything, you could also use a default like 1, so whether they set it or not, its a good value.

Posted on April 12, 2012 at 5:47 PM

JohnSword

JohnSword
Total Posts: 27
Joined: April 12, 2012

Re: Parameter default value should be constant

thanks, I guess using a default value will be ok.
but another question... in flash one can do something like the following to insert a value into a vector at the given index number:

var _initializers:Vector<Initializer> = new Vector<Initializer>();
_initializers.splice( idx, 0, initializer );

how can this be achieved with haxe? is there a way to insert values into an array or vector using a given index number in the list?

Posted on April 13, 2012 at 7:14 PM

JohnSword

JohnSword
Total Posts: 27
Joined: April 12, 2012

Re: Parameter default value should be constant

another thing I noticed when compiling to the cpp target is that most of the times i've tested if an event listener is set like this where weak reference is set to true:

emitter.addEventListener( EmitterEvent.EMITTER_UPDATED, emitterUpdated, false, 0, true );

then the listener will delete itself and return false all by itself.

Posted on April 15, 2012 at 12:01 PM

JohnSword

JohnSword
Total Posts: 27
Joined: April 12, 2012

Re: Parameter default value should be constant

there is also an issue with the BitmapData class in cpp target, when calling the paletteMap function on a BitmapData object I got this error:

nme.display.BitmapData has no field paletteMap

even though the nme BitmapData has the function available (at least in FlashDevelop's code completion).

Posted on April 15, 2012 at 12:08 PM