Thanks for help. I didn’t see any call Lambda before. I think Haxe dpesn’t support with forEach();
Now you have to say Lambda - I am very longer searching to google. But it finds hard If I use “forEach for Haxe” than they are nothing current to find. just only for loop of Haxe or AS3.
Please add Lambda to Actionscript developer guide! I will know about same conversion of AS3 and Haxe. I feel stupid because I search longer before. I thought because Haxe has not more features. Now I am surprised you have same features. I am shocking now.
PS: Thanks for great support to @player_03!!!
// EDIT:
And I do not understand why I got errors.
> private var events(get, set) : Array;
> private var _events : Array;
> public function new()
> {
> super();
>
> //default: events you would expect when using an URLLoader (load external files)
> _events = [Event.COMPLETE, ProgressEvent.PROGRESS, IOErrorEvent.IO_ERROR];
> }
> /** ADD_LISTENERS
> * add all events to an object with a loop
> * @param target: the object in which to add the listeners to
> /
> private function addListeners(target : Dynamic, evts : Array = null) : Void
> {
> _events = ((evts == null)) ? _events : evts;
> var n:Int;
> Lambda.foreach(_events, function(value:String):String
> {
> if (!target.hasEventListener(value))
> target.addEventListener(value, event_handler);
> return _events[n] = value;
> });
> }
> /* DROP_LISTENERS
> * remove all events from an object with a loop
> * @param target: the object in which to remove the listeners from
> */
> private function dropListeners(target : Dynamic, evts : Array = null) : Void
> {
> _events = ((evts == null)) ? _events : evts;
> var n:Int;
> Lambda.foreach(_events, function(value:String):String
> {
> if (target.hasEventListener(value))
> target.removeEventListener(value, event_handler);
> return _events[n] = value;
> });
> }
And output: Lambda.foreach(function());
Error:
> src/io/events/EventManager.hx:52: lines 52-57 : value : String -> String should be String -> Bool
> src/io/events/EventManager.hx:52: lines 52-57 : Cannot unify return types
> src/io/events/EventManager.hx:52: lines 52-57 : String should be Bool
> src/io/events/EventManager.hx:52: lines 52-57 : For function argument 'f'
> src/io/events/EventManager.hx:68: lines 68-73 : value : String -> String should be String -> Bool
> src/io/events/EventManager.hx:68: lines 68-73 : Cannot unify return types
> src/io/events/EventManager.hx:68: lines 68-73 : String should be Bool
> src/io/events/EventManager.hx:68: lines 68-73 : For function argument 'f'
How do I fix foreach?
// EDIT: I have fixed but array won’t work
src/wad/WAD3.hx:134: lines 134-145 : pal : Array<Int> -> Bool should be Int -> Bool
src/wad/WAD3.hx:134: lines 134-145 : Cannot unify argument 1
src/wad/WAD3.hx:134: lines 134-145 : Int should be Array<Int>
src/wad/WAD3.hx:134: lines 134-145 : For function argument 'f'
Build halted with errors.
My code is from WAD3.hx
Lambda.foreach(palette, function(pal:Array<Int>):Bool
{
var val:Int, i:Int;
alpha = (((i == (MAX_PALETTE_COLORS - 1)) && (dir[n].name.charAt(0) == "{"))) ? 0x00 : 0xFF;
if (dir[n].type == 0x40)
pal[i] = (alpha << 24 | i << 16 | i << 8 | i)
else
pal[i] = (alpha << 24 | bytes.readUnsignedByte() << 16 | bytes.readUnsignedByte() << 8 | bytes.readUnsignedByte());
return true;
});
I already tried - it always give errors? I don’t understand I already fixed _events and directories both foreachs are work fine but why not with Array.
How do I fix? Possible I use Vector?
I fixed Lambda.mapi();
Than it always crash Because ( I already checked:
Called from hxcpp::__hxcpp_main
Called from ApplicationMain::main ApplicationMain.hx line 79
Called from ApplicationMain::create ApplicationMain.hx line 111
Called from lime.app.Application::exec lime/app/Application.hx line 225
Called from lime._backend.native.NativeApplication::exec lime/_backend/native/NativeApplication.hx line 154
Called from lime._backend.native.NativeApplication::handleApplicationEvent lime/_backend/native/NativeApplication.hx line 195
Called from lime.app._Event_Int_Void::dispatch lime/_macros/EventMacro.hx line 101
Called from lime.system.ThreadPool::__update lime/system/ThreadPool.hx line 206
Called from lime.app._Event_Dynamic_Void::dispatch lime/_macros/EventMacro.hx line 101
Called from lime._backend.native.NativeHTTPRequest::threadPool_onComplete lime/_backend/native/NativeHTTPRequest.hx line 414
Called from lime.app.Promise_haxe_io_Bytes::complete lime/app/Promise.hx line 39
Called from lime.net._HTTPRequest_Bytes::load lime/net/HTTPRequest.hx line 124
Called from lime.app.Promise::complete lime/app/Promise.hx line 39
Called from openfl.net.URLLoader::load openfl/net/URLLoader.hx line 74
Called from openfl.events.EventDispatcher::dispatchEvent openfl/events/EventDispatcher.hx line 97
Called from openfl.events.EventDispatcher::__dispatchEvent openfl/events/EventDispatcher.hx line 218
Called from io.events.EventManager::event_handler io/events/EventManager.hx line 83
Called from openfl.events.EventDispatcher::dispatchEvent openfl/events/EventDispatcher.hx line 97
Called from openfl.events.EventDispatcher::__dispatchEvent openfl/events/EventDispatcher.hx line 218
Called from io.Importer::event_handler io/Importer.hx line 113
Called from Main::handle Main.hx line 41
Called from wad.WAD3::parse wad/WAD3.hx line 49
AL lib: (EE) alc_cleanup: 1 device not closed
Wow it crashes So sad how do I fix if I want openfl let to works Quake and Half-Life…