Haxe 4 rc3 problems

Hi, I have just installed Haxe 4 rc3 over Haxe 3.4.7.
I fixed a lot of deprecated class names, but I don’t know how to fix a few errors:

D:/HaxeToolkit/haxe/lib/lime/7,5,0/src/lime/media/AudioSource.hx:14: characters 26-49 : Unknown<0> cannot be constructed

that refers to line

public var onComplete = new Event<Void->Void>();

Then there are a lot of errors referring to thx libs

referring to code

I suspect that I need to specify some type, because it is unable to infer the correct ones.
Any hint about how to fix them?

in the called function buildFromAnonymous I have modified a line

var e = haxe.macro.Expr.ExprDef.EObjectDecl(fields.map(function(field)#if ((haxe_ver >= 4.0) && !macro ) :haxe.macro.Expr.ObjectField #end {
var e = haxe.macro.Expr.ExprDef.EObjectDecl(fields.map(function(field)#if (haxe_ver >= 4.0) :haxe.macro.Expr.ObjectField #end {
as explained here
and now it works, even if I had to change a lot of other things.

One thing that remains unchanged is the use of Utf8 even if it is deprectated in favour of UnicodeString: the new class is not compatible, it is not sufficient to change the class…

The latest dev is stable, perhaps compare there?

How do I install it? And Lime dev?

Uh oh, the links to lime builds in the page are wrong

the correct URL is http://builds.openfl.org/

Thanks, I just updated the README

How do you replace Utf8 with UnicodeString? I’d like to get rid of those annoying warnings.

I have upgraded everything (Haxe, Lime and Openfl) to the dev versions, but now I get

Error: Could not process asset libraries (swflite)

and if I rebuild the tools as explained in this topic I get all the UnicodeString warnings, plus

HaxeToolkit\haxe\lib\format/3,4,2/format/amf3/Tools.hx:73: characters 14-20 : Cannot use abstract as value


Could you check haxelib path and make sure they are all dev?

I have been using Haxe 4 RC 3 since release using dev OpenFL and Lime

I have literally replaced the official versions, so there shouldn’t be any doubt that it was using the dev ones.
I had to go back to the previous ones to continue the development.

Ok, I got rid of the Utf8 warnings, to replace the calls to the static methods of Utf8 you just need to cast the target variable to UnicodeString and call the corresponding (non static) functions:
cast(str, UnicodeString).length

Note that the UnicodeString function corresponding to Utf8.sub is .substr, so

Utf8.sub(s, p, l)
cast(s, UnicodeString).substr(p, l)

This fixes all warning, please tell me if it is the correct approach.
I think that when Haxe 4 will be released officially all libraries will be fixed, but in the meanwhile I prefer to fix them myself, if possible.

Safe casting to an abstract type like that is considered bad practice, it has unnecessary runtime overhead. It would be nicer to use a type check:

(str : UnicodeString).length

Ok, I’ll swap to that method, thank you!

EDIT: I noticed that Away3D uses safe casting massively, could this be a problem for performance?

EDIT 2: which are the situations where safe casting is the best/unique choice?