I have this quickBox2d code to add a cricle to the stage:
var ball:QuickObject = sim.addCircle( {skin:skinMc, x:10, y:10, radius:3, density:0 } );
The skinMc contains animations so I want to be able to refer to it like this: skinMc.gotoAndPlay(5); but it says
Type Coercion failed: cannot convert skinMc$ to flash.display.MovieClip.
ball.gotoAndPlay(5); doesn't work either since it's a QuickObject, not an mc...
Any help will be appreciated
Thanks
ball.userData.gotoAndPlay(5);
userData will be a DisplayObject populated by QuickBox2D.
var sim:QuickBox2D = new QuickBox2D
var ball:QuickObject = sim.addCircle( {skin:skinMc, x:10, y:10, radius:3, density:0 } );
//something along these lines
So to reference the object you can use:
sim.gotoAndPlay("5");
im not 100% on what your doin but i installed both packages and created a quick document and it works fine on my machine.
if need be try this link http://www.emanueleferonato.com/2009/08/25/simplify-your-box2d-projects-with-quickbox2d/
if this fails,send me your file or else let me know how you go.
Related
I cannot access any value in typescript inside the function triggered by the onAdd event of the dxo-item-dragging element. All come undefined
HTML Code :
<dxo-item-dragging group="'server'" [data]="tasks"
[allowReordering]="true" [onDragStart]="onDragStart" [onAdd]="onAdd" [onRemove]="onRemove">
</dxo-item-dragging>
TS Code:
onAdd(e) {
e.toData.splice(e.toIndex, 0, e.itemData);
let a = this.tasks;
}
When I do let a = this.tasks, this.tasks comes as undefined. Actually I defined it.
When I type [onAdd]="onAdd.bind(this)" instead of [onAdd]="onAdd", I can access all properties, but this time the ui slows down a lot and freezes.
Thanks in advance for your help
I tried binding the event event to a function.
I was expecting to access all properties in that function, but I can't.
in the example in this link https://js.devexpress.com/Demos/WidgetsGallery/Demo/DataGrid/DnDBetweenGrids/Angular/Light/ there is a solution to my problem. For those who have the same problem as me, the solution to my problem is to put
this.onAdd = this.onAdd.bind(this);
It was enough for me to write. Have a nice day
I'm writing an extension for the Forge Viewer and I ran into this problem when trying to use the setThemingColor() method in the "load" part of the extension:
function extensaoteste(viewer, options) {
Autodesk.Viewing.Extension.call(this, viewer, options);
}
extensaoteste.prototype = Object.create(Autodesk.Viewing.Extension.prototype);
extensaoteste.prototype.constructor = extensaoteste;
extensaoteste.prototype.load = function() {
this.onSelectionBinded = this.onSelectionEvent.bind(this);
this.viewer.addEventListener(Autodesk.Viewing.SELECTION_CHANGED_EVENT, this.onSelectionBinded);
this.viewer.setThemingColor(3554,new THREE.Vector4(255/255, 255/255, 102/255, 1));
The code goes on, but the rest works fine. As you can see, there is another part of the extension, with an event listener.
If I use the exact same line with the setThemingColor method in the extensaoteste.prototype.onSelectionEvent, it works perfectly. I understand it is the this.viewer part that isn't returning anything, however it works in the line above.
I have used the code from https://forge.autodesk.com/en/docs/viewer/v6/tutorials/events/#step-2-listen-and-react-to-an-event as a template.
I know this is probably a silly question, but I really can't understand it. Thanks for your help!
This is happening because the model geometry was not fully loaded when the call was made to set color and the null reference was not called out on this.viewer but on the model object:
Viewer3D.prototype.setThemingColor = function(dbId, color, model, recursive) {
// use default RenderModel by default
model = model || this.model;
model.setThemingColor(dbId, color, recursive); // null reference here
// we changed the scene to apply theming => trigger re-render
this.impl.invalidate(true);
};
Try set color (and other fragment level operations) after the GEOMETRY_LOADED_EVENT is fired:
var viewer = this.viewer;
viewer.addEventListener(Autodesk.Viewing.GEOMETRY_LOADED_EVENT,()=>viewer.setThemingColor(3554,new THREE.Vector4(255/255, 255/255, 102/255, 1));
I have some simple code:
var timer = Observable.Timer(TimeSpan.FromSeconds(0), TimeSpan.FromSeconds(1)).Timestamp();
//timer.Subscribe(x => timerTb.Text = x.Value.ToString());
timer.Subscribe(x => Debug.WriteLine(x.Value));
And a textbox on the view called timerTb. I am trying to get the commented out line to work without it shouting about marshalling issues.
From what i can find out i should be using timer.ObserveOnDispatcher().Subscribe(...
But i do not have access to this method, nor do i have access to the CoreDispatcherScheduler dispite referencing "System.Reactive.Linq;"
I am running RX 2.0.20304.0
Any ideas?
I managed to get it working.
Silly rookie mistake CoreDispatcherScheduler was in : System.Reactive.Windows.Threading
Once i referenced that i got ObserveOnDispatcher() and this worked:
var timer = Observable.Timer(TimeSpan.FromSeconds(0), TimeSpan.FromSeconds(1)).Timestamp();
timer.ObserveOnDispatcher().Subscribe(x => timerTb.Text = x.Value.ToString());
Put your timer on the UI thread:
Observable.Timer(TimeSpan.FromSeconds(0), TimeSpan.FromSeconds(1), CoreDispatcherScheduler.Instance)
.Timestamp();
var abc:int=123
trace(abc)
//actual output:
123
//my expected output:
abc:123
Although I can type trace("abc:"+abc) by hands,but I still want to have a more simple way to trace
I have tried something like
function tracee(word){
trace("word:"+word)
}
function traceee(word){
var wordd:Srting=word
trace(wordd+word)
}
but these functions are not working.
is it possible to have the expected output?
import flash.utils.describeType;
var num:Number = 47;
function customTrace(word:*){
trace(describeType(this).variable.#name + " : "+word)
}
customTrace(num);
SOURCE
No. Variables are passed to functions by link (memory offset) or by value, so you don't have any data about names.
The one thing I can propose - is to use automatic code generation in IDEs. For example, in IntelliJ Idea it is in Settings -> Live Templates, that you can use via ctrl+J in editor.
i have the following switch case:
switch (appModel.currentPage){
case "Programma":
case "Winkelwagen":
case "Films":
case "Contact":
if (page){
removeChild(page);
}
//here i would like to create a new object page that has the type of the switch.
i mean this: var page: getDefinitionByName(appModel.currentPage+"Page");
this doesnt work thou but it should be something like: "FilmsPage or ContactPage or ...".
addChild(page);
break;
Does anyone know how to do this?
var pageClass:Object = getDefinitionByName(appModel.currentPage+"Page");
var page:DisplayObject = new pageClass();
addChild( page );
PatrickS's answer should work, but you will need to make sure all the classes that you will use are referenced somewhere, or the compiler will skip over them, and not add them to your SWF.