Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Unable to do copy/paste on textfields in loaded SWFs in AIR

My AIR app is loading an SWF file which contains a text field for input. I can type into the text field but copying and pasting is broken. When I try to paste something using the keyboard shortcut, the text field becomes like this:

enter image description here

(this is not a "T").

And after a series of copy/pasting it looks like this:

enter image description here

When I do a right-click on the text field, nothing happens, no context menu with copy/paste options appears.

The SWF that is being loaded is in AS2 (it's practically impossible to port it to AS3 because the code in it is very vast and sophisticated). I can't replace that SWF, it has extremely high value for my project. Apart from this trouble, the SWF works fine. Maybe I could change some config constants in the AS3 settings of the loader?

For testing purposes, I created two .flas, one is in AS2 and contains a text field and the other is in AS3 and loads the text field. You can download the .flas in an archive from here.

like image 245
Pleo Avatar asked Apr 02 '13 13:04

Pleo


1 Answers

It's dirty hack, but it works. :) Convert your SWF from AVM1 to AVM2 "on fly". Use ForcibleLoader https://code.google.com/p/as3-classes/source/browse/trunk/org/lzyy/util/ForcibleLoader.as

In loader.fla:

var loader:Loader = Loader(addChild(new Loader()));
var fLoader:ForcibleLoader = new ForcibleLoader(loader);
fLoader.load(new URLRequest('tf.swf'));

In ForcibleLoader.as add import flash.system.LoaderContext;

and

var lc:LoaderContext = new LoaderContext();
lc.allowCodeImport = true;
loader.loadBytes(inputBytes, lc);

instead

loader.loadBytes(inputBytes);

in line ~75

like image 187
Smolniy Avatar answered Sep 21 '22 02:09

Smolniy