+ sprintf(framename, "[packageinternal]rfx::frame%d", frame);
+
+ if(!f && (tag->id == ST_DEFINEBUTTON || tag->id == ST_DEFINEBUTTON2 || stop_each_frame)) {
+ /* make the contructor add a frame script */
+ abc_findpropstrict(c,"[package]::addFrameScript");
+ abc_pushbyte(c,frame);
+ abc_getlex(c,framename);
+ abc_callpropvoid(c,"[package]::addFrameScript",2);
+
+ f = abc_class_method(cls, 0, framename, 0);
+ f->max_stack = 3;
+ f->local_count = 1;
+ f->init_scope_depth = 10;
+ f->max_scope_depth = 11;
+ abc_debugfile(f, "framescript.as");
+ abc_debugline(f, 1);
+ abc_getlocal_0(f);
+ abc_pushscope(f);
+ }
+
+ if(tag->id == ST_DEFINEBUTTON || tag->id == ST_DEFINEBUTTON2) {
+ U16 id = swf_GetDefineID(tag);
+ sprintf(buttonname, "::button%d", swf_GetDefineID(tag));
+ abc_getlex(f,buttonname);
+ abc_getlex(f,"flash.events::MouseEvent");
+ abc_getproperty(f, "::CLICK");
+ sprintf(functionname, "::clickbutton%d", swf_GetDefineID(tag));
+ abc_getlex(f,functionname);
+ abc_callpropvoid(f, "::addEventListener" ,2);
+
+ if(stop_each_frame) {
+ abc_findpropstrict(f, "[package]::stop");
+ abc_callpropvoid(f, "[package]::stop", 0);
+ }
+ needs_framescript = 1;
+
+ abc_method_body_t*h =
+ abc_class_method(cls, "::void", functionname, 1, "flash.events::MouseEvent");
+ h->max_stack = 6;
+ h->local_count = 2;
+ h->init_scope_depth = 10;
+ h->max_scope_depth = 11;
+ abc_getlocal_0(h);
+ abc_pushscope(h);
+
+ ActionTAG*oldaction = swf_ButtonGetAction(tag);
+ if(oldaction && oldaction->op == ACTION__GOTOFRAME) {
+ int framenr = GET16(oldaction->data);
+ if(framenr>254) {
+ fprintf(stderr, "Warning: Couldn't translate jump to frame %d to flash 9 actionscript\n", framenr);
+ }
+ if(!events) {
+ abc_findpropstrict(h,"[package]::gotoAndStop");
+ abc_pushbyte(h,framenr+1);
+ abc_callpropvoid(h,"[package]::gotoAndStop", 1);
+ } else {
+ char framename[80];
+ sprintf(framename, "frame%d", framenr);
+ abc_getlocal_0(h); //this
+ abc_findpropstrict(h, "[package]flash.events::TextEvent");
+ abc_pushstring(h, "link");
+ abc_pushtrue(h);
+ abc_pushtrue(h);
+ abc_pushstring(h, framename);
+ abc_constructprop(h,"[package]flash.events::TextEvent", 4);
+ abc_callpropvoid(h,"[package]::dispatchEvent", 1);
+ }
+ } else if(oldaction && oldaction->op == ACTION__GETURL) {
+ if(!events) {
+ abc_findpropstrict(h,"flash.net::navigateToURL");
+ abc_findpropstrict(h,"flash.net::URLRequest");
+ abc_pushstring(h,oldaction->data); //url
+ abc_constructprop(h,"flash.net::URLRequest", 1);
+ abc_callpropvoid(h,"flash.net::navigateToURL", 1);
+ } else {
+ abc_getlocal_0(h); //this
+ abc_findpropstrict(h, "[package]flash.events::TextEvent");
+ abc_pushstring(h, "link");
+ abc_pushtrue(h);
+ abc_pushtrue(h);
+ abc_pushstring(h,oldaction->data); //url
+ abc_constructprop(h,"[package]flash.events::TextEvent", 4);
+ abc_callpropvoid(h,"[package]::dispatchEvent", 1);
+ }
+ } else if(oldaction) {
+ fprintf(stderr, "Warning: Couldn't translate button code of button %d to flash 9 abc action\n", id);
+ }
+ abc_returnvoid(h);
+ swf_ActionFree(oldaction);
+ }
+ if(tag->id == ST_SHOWFRAME) {
+ if(f) {
+ abc_returnvoid(f);
+ f = 0;
+ }
+ frame++;
+ }
+ tag = tag->next;
+ }
+ if(f) {
+ abc_returnvoid(f);