aurelia error (0, _bootstrap2.default) is not a function - ecmascript-6

I have an aurelia app for a filmfestival and recently I stumbled upon an error that I don't understand.
I have a line of code:
const timetableElement = $('<div>').attr('id', timetableID).addClass('timetable anim-fade-in');
That after compiling it changes to
var timetableElement = (0, _bootstrap2.default)('<div>').attr('id', timetableID).addClass('timetable anim-fade-in');
Which result in the error:
(0, _bootstrap2.default) is not a function.
I hope I made myself a bit clear.
(www.suikerzoetfilmfestival.nl/programma)

Solved it by adding
declare var $

Related

TypeError: Cannot find default value for object

I have a google ads script which is failing with the following error.
TypeError: Cannot find default value for object.
It seems fairly cryptic so im not sure what its referring to.
This is the line that its failing on:
var adOperation = adGroup.newAd().expandedTextAdBuilder()
.newAd()
.expandedTextAdBuilder()
.withHeadline1(expandedTextAd.getHeadline1())
.withHeadline2(expandedTextAd.getHeadline2())
.withDescription1(expandedTextAd.getDescription1())
.withPath1(expandedTextAd.getPath1())
.withPath2(expandedTextAd.getPath2())
.withTrackingTemplate(expandedTextAd.getTrackingTemplate())
.withFinalUrl(expandedTextAd.getFinalUrl())
.build(adGroup);
I've checked adGroup is set and it is, not sure where to go from here.
Update:
I split the line in to each method call and the line which is failing is line 1
> var adOperation = adGroup
.newAd()
.expandedTextAdBuilder()
After a few hours head scratching, I fixed this by removing adGroup from the .build() method. build() doesn't take any parameters and I'm not sure why I was passing it. Still a very strange error.
var adOperation = adGroup
.newAd()
.expandedTextAdBuilder()
.withHeadline1(expandedTextAd.getHeadline1())
.withHeadline2(expandedTextAd.getHeadline2())
.withDescription1(expandedTextAd.getDescription1())
.withPath1(expandedTextAd.getPath1())
.withPath2(expandedTextAd.getPath2())
.withTrackingTemplate(expandedTextAd.getTrackingTemplate())
.withFinalUrl(expandedTextAd.getFinalUrl())
.build();
I would recommend anyone trying to solve anything similar to unchain the method calls and debug each call line by line.

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.

How can I clone an object?

I'll need to clone some objects that have several types of instances. I've searched using a search engine and found some examples however I got error after I tested them.
Example: AS3 - Clone an object
import Line;
import OtherClass;
// Set lines
var obj1:Object={
environmentLine:new EnvironmentLine(),
lineX:100,
lineY:100
};
addChild(obj1.environmentLine);
var line:Line = new Line();
line.clone(obj1);
This gives me error: Line.as, Line 12, Column 3 1170: Function does not return a value.
Example: https://gist.github.com/PrimaryFeather/6914861
import com.gamua.flox.*;
import com.gamua.flox.utils.*;
import com.gamua.flox.events.*;
// Set lines
var obj1:Object={
environmentLine:new EnvironmentLine(),
lineX:100,
lineY:100
};
addChild(obj1.environmentLine);
var clone:Object = new cloneObject(obj1);
This code is giving me warning: TypeError: Error #1064: Cannot call method global/com.gamua.flox.utils::cloneObject() as constructor.
at Untitled_07_fla::MainTimeline/frame1()
Example: https://code.google.com/p/as3-commons/source/browse/trunk/as3-commons-lang/src/main/actionscript/org/as3commons/lang/ObjectUtils.as?r=1784
import org.as3commons.lang.ObjectUtils;
var num:int = 0;
// Set lines
var obj1:Object={
environmentLine:new EnvironmentLine(),
lineX:100,
lineY:100
};
var objectUtils:ObjectUtils = new ObjectUtils();
objectUtils.clone(obj1);
This gives me error: org\as3commons\lang\ObjectUtils.as, Line 211, Column 69 1046: Type was not found or was not a compile-time constant: IIterator.
Which one is the best for cloning an object and how can I fix the errors? Or is there a good library?
Boddy you should search more on Google. This is well discussed topic on many places:
https://gist.github.com/PrimaryFeather/6914861
http://www.tomauger.com/2009/flash-actionscript/actionscript-3-gotchas-copy-by-reference-deep-copy-and-read-only-objects
AS3 - Clone an object

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.

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.