00:00
00:00
Newgrounds Background Image Theme

ozziel94 just joined the crew!

We need you on the team, too.

Support Newgrounds and get tons of perks for just $2.99!

Create a Free Account and then..

Become a Supporter!

Mutual Interfaces [AS3]

200 Views | 1 Reply
New Topic Respond to this Topic

Mutual Interfaces [AS3] 2017-11-01 11:07:26


In the project I'm working on, users can compile their own SWFs that can then be loaded into the application, and the application will be able to call methods on instances of a class definition grabbed from the SWF. The class must implement an interface (say A), which is available in the source code of the application as well.

Loading the SWF is fine, and so is the instantiation of the remote class, but when I try and cast it to interface A then it fails (type conversion error), even though all the methods of A are defined. How do I make sure that it is casted to the interface? I don't want to have to deal with Objects all the time, and using the "as" cast fails.


Slint approves of me! | "This is Newgrounds.com, not Disney.com" - WadeFulp

"Sit look rub panda" - Alan Davies

BBS Signature

Response to Mutual Interfaces [AS3] 2017-11-03 02:18:38


Never mind, found out how to do it. Turns out the class definition wasn't exactly the same (they were in a different package) and so it didn't recognize it. To make sure, though, I exported the interfaces as an SWC, and imported it in the remote SWF as an external SWC; in my main SWF, I set it as a fully included SWC, and so far, it seems to be working.


Slint approves of me! | "This is Newgrounds.com, not Disney.com" - WadeFulp

"Sit look rub panda" - Alan Davies

BBS Signature