flash - Creating a .swc - why don't interfaces work, when classes do? -
i'm making game loads map .swfs @ runtime. maps contain graphics , code, can both vary map map. i've decided make maps implement interface, can used in same way game. i'm using .swc contain interface, in this page.
i can classes work in .swc, not interfaces!
i'm using flash cs5, , flashdevelop editing, in as3. here's how i've been doing it:
1- create map.fla symbol called map, , map.as:
public class map extends movieclip { public function test():void { trace("woohoo"); } }
2- in flash, right click map symbol , choose "export swc..." , "export swf...".
3- create new .fla , flashdevelop project called loader in new folder, , copy in .swf , .swc created in 2
4- in flashdevelop, right click swc , choose "add library"
5- in flash, actionscript settings -> lirbary path, add swc , set link type: external
now in loader.as can access map class after loading in map.swf:
public class loaderoo extends movieclip { public function loaderoo() { var loader:loader = new loader() loader.load(new urlrequest("map.swf"), new loadercontext(false, applicationdomain.currentdomain)); loader.contentloaderinfo.addeventlistener(event.complete, loaded); // var map:map = new map(); // throw verifyerror 1014 } private function loaded(e:event):void { var map:map = new map(); addchild(map); map.test(); // has loaded class - traces "woohoo" } }
so far good. if try
public class map extends movieclip implements imap { ...
and
private function loaded(e:event) { var map:imap = new map(); ...
it doesn't work! "verifyerror: error #1014: class imap not found." why oh why? if can i'd grateful.
you need have interface imap stored in swc. try exporting whole fla swc , not map symbol.
in flash: flash > publish settings >flash> check export swc box.
now publish swf , use resulting swc in flashdevelop.
also, maybe if include library in flashdevelop
for see issue no 2 here: http://flashontherocks.com/2010/12/13/flashdevelop-resolved-issues/
good luck!
Comments
Post a Comment