Worker don't receive MessageChannel object in getSharedProperty() - actionscript-3

I'm creating a AIR application, with the AIR 23 SDK, and need use the Worker object. With this adobe documentation I made a simple example to understand it. The code is below:
if(Worker.current.isPrimordial) {
var worker:Worker = WorkerDomain.current.createWorker(this.loaderInfo.bytes);
var mainToWorker:MessageChannel = Worker.current.createMessageChannel(worker);
var workerToMain:MessageChannel = worker.createMessageChannel(Worker.current);
worker.setSharedProperty("mtw", mainToWorker);
worker.setSharedProperty("wtm", workerToMain);
worker.start();
trace("[MAIN] Start worker.");
trace("[MAIN] Property one: "+worker.getSharedProperty("mtw"));
trace("[MAIN] Property two: "+worker.getSharedProperty("wtm"));
}
else {
trace("[WORKER] Status: "+Worker.current.state);
var mtw = Worker.current.getSharedProperty("mtw");
var wtm = Worker.current.getSharedProperty("wtm");
trace("[WORKER] Property one: "+mtw);
trace("[WORKER] Property two: "+wtm);
}
But the output traces are:
[MAIN] Start worker.
[MAIN] Property one: [object MessageChannel]
[MAIN] Property two: [object MessageChannel]
[WORKER] Status: running
[WORKER] Property one: undefined
[WORKER] Property two: undefined
When I change the AIR SDK to the 3.4, it works! The traces changes to: [WORKER] Property one: [object MessageChannel] and [WORKER] Property two: [object MessageChannel].
Is it a bug? Can someone help me?

Related

Cannot read property 'environment' of null - ionic native google maps

When running my ionic project with ionic serve -c
Everytime, I get an this error :
ERROR TypeError: Cannot read property 'environment' of null
at Function.Environment.setEnv (index.js:1980)
at HomePage.webpackJsonp.194.HomePage.loadMap (home.ts:98)
at HomePage.webpackJsonp.194.HomePage.ionViewDidLoad (home.ts:45)
at ViewController._lifecycle (view-controller.js:486)
at ViewController._didLoad (view-controller.js:369)
at NavControllerBase._didLoad (nav-controller-base.js:768)
at t.invoke (polyfills.js:3)
at Object.onInvoke (core.js:4760)
at t.invoke (polyfills.js:3)
at r.run (polyfills.js:3)
There is the loadMap method :
loadMap() {
Environment.setEnv({
'API_KEY_FOR_BROWSER_DEBUG' : '',
'API_KEY_FOR_BROWSER_RELEASE' : ''
})
this.geoLocation.getCurrentPosition().then((resp) => {
this.latitude = resp.coords.latitude;
this.longitude = resp.coords.longitude;
console.log(this.latitude);
console.log(this.longitude);
let CurrentPosition : LatLng = new LatLng(this.latitude,this.longitude);
let CameraPosition : CameraPosition<ILatLng> = {
target : CurrentPosition,
zoom : 18
};
this.addMarker();
this.map.moveCamera(CameraPosition);
}).catch((error) => {
console.log('Error getting location', error);
});
this.map = GoogleMaps.create('map_canvas');
}
I don't understand. I only launch my component after the device.isReady() is fired, so it should not be a lifecycle problem.
Do you have any idea as to where does this come from?
Thank you!
EDIT : When using the ionic cordova run browser -l command, the map is loaded without error the first time then on some refresh of the webpage, the error appears again, without me changing anything to the code...
I had the same problem I found the solution on this thread https://stackoverflow.com/a/52681481/6560704
You need to build your platforms to create that 'environment' variable, by using CLI for example :
ionic cordova build browser -l
Hope this will help
Problem solved !
It was in fact a lifecycle problem. I was attributing the HomePage to the rootPage in app.components.ts before the device was ready.

Uncaught TypeError: this.EventDispatcher_initialize is not a function createjs error

i am following a famous book "beginning html5 game development with createjs.pdf " Apress Publication .
Anyhow when i run the codes i get error in my browser console : i updated my createjs hosted lib to latest version
gs skinner github i found p.initialize =function is deprecated .
i am not a good programmer. is there any way so that i can fix the error and run the codes of this book. thanks
Uncaught TypeError: this.EventDispatcher_initialize is not a function
AssetManager.js:34 Uncaught TypeError:
here i pasted few lines for 34 to last of function
p.initialize = function () {
this.EventDispatcher_initialize();
this.loadManifest = [
{id:this.EXPLOSION, src:this.assetsPath + 'explosion.mp3'},
{id:this.SOUNDTRACK, src:this.assetsPath + 'dreamRaid1.mp3'},
{id:this.GAME_SPRITES_DATA, src:this.assetsPath + 'all.json'},
{id:this.GAME_SPRITES, src:this.assetsPath + 'all.png'}
];
}
Can you show more of your code? The this.EventDispatcher_initialize is used with early inheritance approaches, as well as with the newer extend/promote approach.
If you are using the old approach, there should be a line above this one that says:
p.EventDispatcher_initialize = p.initialize;
This stores the superclass (EventDispatcher) method on the current class prototype first, so you can call it to apply the default functionality. You should also see something like this at the top, which sets up the inheritance:
function MyClass() {
this.initialize();
}
var p = MyClass.prototype = new createjs.EventDispatcher();
If you are missing any of these steps, your code will not work.

cocos2d-js: Error: Invalid Native Object using setPhysicsBody

I'm trying to implement chipmunk physics engine for a cocos2d-js game. I'm getting the following error when i run it.
jsb: ERROR: File Y:\Documents\cocos\PrebuiltRuntimeJs\frameworks\js-bindings\bindings\auto\jsb_cocos2dx_auto.cpp: Line: 2143, Function: js_cocos2dx_Node_setPhysicsBody
Invalid Native Object
JS: D:/PROJECTS/cocos/Sliderule/runtime/win32/../../src/app.js:32:Error: Invalid Native Object
Here is the code i'm working with
`init:function () {
this._super();
var size = cc.winSize;
this.rect1 = new cc.Sprite(res.null_png,cc.rect(0,0, 200, 25));
this.rect1.setColor(cc.color(255,50,50,1));
this.rect1.setPosition(size.width/2, size.height-12.5);
this.rect1._setAnchorX(0.5);
this.rect1._setAnchorY(0.5);
this.rectbody1 = new cp.Body(1,cp.momentForBox(1,this.rect1.getContentSize().width, this.rect1.getContentSize().height));
this.rectbody1.p = cc.p(size.width/2, size.height-12.5);
this.space.addBody(this.rectbody1);
this.rectshape1 = new cp.BoxShape(this.rectbody1, this.rect1.getContentSize().width - 14, this.rect1.getContentSize().height);
this.space.addShape(this.rectshape1);
this.rect1.setPhysicsBody(this.rectbody1);
this.addChild(this.rect1,1);
`
I get the problem when setting the body to the sprite. Thanks in Advance.
This error message usually appears because of a missing retain(). You have to explicitly set sprites to be kept by the native system (Android, iOS) otherwise it's not valid after some time. And then, if you don't need it anymore: release it.
Try:
this.rect1.retain()
after you created the sprite. And then
this.rect1.release()
when you don't need it anymore.

sendToURL not working in flashplayer 14

This piece of code is working in flashplayer 11 but it's not working in flashplayer 14.
AS3 code :
private function savePDF(pdfBinary:ByteArray, urlString:String):void{
try{
//result comes back as binary, create a new URL request and pass it back to the server
var header:URLRequestHeader = new URLRequestHeader("Content-type", "application/octet-stream");
var sendRequest:URLRequest = new URLRequest(urlString);
sendRequest.requestHeaders.push(header);
sendRequest.method = URLRequestMethod.POST;
sendRequest.data = pdfBinary;
sendToURL(sendRequest);
} catch (e:Error) {
// handle error here
trace("Error in savePDF "+e.message);
trace("StackTrace : "+e.getStackTrace());
}
}
and these are the errors I got :
Error in savePDF Error #3769: Security sandbox violation: Only simple headers can be used with navigateToUrl() or sendToUrl().
StackTrace : SecurityError: Error #3769: Security sandbox violation: Only simple headers can be used with navigateToUrl() or sendToUrl().
at global/flash.net::sendToURL()
at Export2Publish/savePDF()[my_project_dir\src\Export2Publish.mxml:158]
at Export2Publish/GeneratePDF()[my_project_dir\src\Export2Publish.mxml:386]
at Export2Publish/getUrl()[my_project_dir\src\Export2Publish.mxml:138]
at Export2Publish/___Export2Publish_Application1_creationComplete()[my_project_dir\src\Export2Publish.mxml:3]
at flash.events::EventDispatcher/dispatchEventFunction()
at flash.events::EventDispatcher/dispatchEvent()
at mx.core::UIComponent/dispatchEvent()[my_framework_dir\src\mx\core\UIComponent.as:9051]
at mx.core::UIComponent/set initialized()[my_framework_dir\src\mx\core\UIComponent.as:1167]
at mx.managers::LayoutManager/doPhasedInstantiation()[my_framework_dir\src\mx\managers\LayoutManager.as:698]
at Function/http://adobe.com/AS3/2006/builtin::apply()
at mx.core::UIComponent/callLaterDispatcher2()[my_framework_dir\src\mx\core\UIComponent.as:8460]
at mx.core::UIComponent/callLaterDispatcher()[my_framework_dir\src\mx\core\UIComponent.as:8403]
Any fix for this issue ?
You can start by using a try and catch like this :
try {
sendToURL(request);
}
catch (e:Error) {
// handle error here
}
If the problem is not visible on dev environment, I recommand you to install a flash debug player which you can download here : Flash Player Downloads to see what kind of error your code will fire.
If your code is fine, in dev and prod environment, you should debug your server side script.

Ace editor - Uncaught TypeError: Cannot read property 'clientX' of undefined

Im using ace editor and mootools.
I have just updated my mootools to version 1.4.5 and when i click/drag on the editor i get js exception:
Uncaught TypeError: Cannot read property 'clientX' of undefined
Please help... Thanks
Instead of removing the bind method always I think I found a workaround. It seems that only a couple of Mootools builds have this issue. So I use this code to fix them:
if (this.MooTools.build=='ab8ea8824dc3b24b6666867a2c4ed58ebb762cf0') {
delete Function.prototype.bind;
Function.implement({
/*<!ES5-bind>*/
bind: function(that){
var self = this,
args = arguments.length > 1 ? Array.slice(arguments, 1) : null,
F = function(){};
var bound = function(){
var context = that, length = arguments.length;
if (this instanceof bound){
F.prototype = self.prototype;
context = new F;
}
var result = (!args && !length)
? self.call(context)
: self.apply(context, args && length ? args.concat(Array.slice(arguments)) : args || arguments);
return context == that ? result : context;
};
return bound;
},
/*</!ES5-bind>*/
});
}
The benefit is that I can fix it for each build separately. The drawback is clearly to have mootools code shipped with my own code. But currently I see no other option and since I code for Joomla I'm pretty sure that there is a limited number of mootools versions in use.
i solve it for my situation!
i've delete some lines from mootools.js:
1) bind:function(e){var a=this,b=arguments.length>1?Array.slice(arguments,1):null,d=function(){};var c=function(){var g=e,h=arguments.length;if(this instanceof c){d.prototype=a.prototype;
g=new d;}var f=(!b&&!h)?a.call(g):a.apply(g,b&&h?b.concat(Array.slice(arguments)):b||arguments);return g==e?f:g;};return c;}
2) delete Function.prototype.bind;
(i don't need mouse binding in mootools so it's revelation for me!)
This is a very strange error. During debugging I didn't get the error. But as soon as I removed the breakpoint it appeared again. I finally solved the issue by adding the latest version of mootools 1.4.5 to joomla. The error was immediately gone.