I have also seen this in the past, where a bead did not implement IBead.
A check was added to verify that in the addBead method but the error alone
is not particularly helpful because of stringification. It could be that
you are encountering a bead that was not updated to explicitly implement
IBead in the as3 source code, but which probably does comply with the
interface in terms of its method signatures.
If the bead that is causing the issue is from the royale framework, then it
needs fixing in the framework.
I just pushed a change that will log the instance to the console before the
error is thrown.
If you want to check this in your local build now without updating your
royale sdk, you can do the following:
1. go into js-debug output folder and navigate to
org/apache/royale/core/ElementWrapper.js
2. open that file in a text editor.
3. Find the block of code that begins with:
org.apache.royale.core.ElementWrapper.prototype.addBead = function(bead) {
4. and replace it with:
org.apache.royale.core.ElementWrapper.prototype.addBead = function(bead) {
if (!this._beads) {
this._beads = [];
}
if (goog.DEBUG && !org.apache.royale.utils.Language.is(bead,
org.apache.royale.core.IBead)) {
console.log('Cannot convert ', bead, ' to IBead');
throw new TypeError('Cannot convert ' + bead + ' to IBead');
}
this._beads.push(bead);
bead.strand = this;
};
When you re-run the app, you should see a more helpful log in the browser
console before the error.
The other way to do this is to do what Yishay said and put a breakpoint at
the code just before the error is thrown and inspect the bead instance
there.
Please let us know what that bead is, if it is one that is from the royale
sdk.
Thanks,
Greg
On Fri, Aug 13, 2021 at 3:12 AM Yishay Weiss <[email protected]> wrote:
> Oh, I see you have resolved it, thanks for sharing.
>
>
>
> *From: *Yishay Weiss <[email protected]>
> *Sent: *Thursday, August 12, 2021 6:11 PM
> *To: *[email protected]
> *Subject: *RE: Uncaught TypeError: Cannot convert [object Object] to IBead
>
>
>
> I have encountered similar issues in the past. I think the runtime
> requirement that all beads actually implement IBead was added a bit late so
> there may be code that fails in runtime. I would put a breakpoint in your
> browser and inspect beads to see if one of them is not an IBead.
>
>
>
> *From: *[email protected]
> *Sent: *Tuesday, August 10, 2021 6:23 PM
> *To: *[email protected]
> *Subject: *Uncaught TypeError: Cannot convert [object Object] to IBead
>
>
>
>
>
> Hi Everyone,
>
>
>
> I am developing my first crux based royale app.
>
>
>
> I am getting the following error
>
> when running the application
>
>
>
> Uncaught TypeError: Cannot convert [object Object] to IBead
>
> at FrontEnd.org.apache.royale.core.ElementWrapper.addBead
> (ElementWrapper.as:268)
>
> at FrontEnd.org.apache.royale.core.HTMLElementWrapper.addBead
> (HTMLElementWrapper.js:50)
>
> at FrontEnd.org.apache.royale.jewel.Application.start
> (Application.as:674)
>
> at index.html:345
>
>
>
>
>
> When tracing to the generated javascript source it is failing at this point
>
>
>
> if (model is IBead) addBead(model as IBead);
>
> if (controller is IBead) addBead(controller as IBead);
>
> for (var index:int in beads) {
>
> *addBead(beads[index]); *// it fails at this line.
>
> }
>
>
>
>
>
>
>
> My guess is that there is one more configuration that needs to be done. I
> have tried to follow the example on the apache royale site.
>
>
>
> Has anyone encountered this issue before ?
>
>
>
>
>