Tagged: adobe

Decrypting XML File with Actionscript 2.0, memory problem?

- by admin


I have an encrypted XML file that needs to be decrypted and displayed in Flash. The Encrypted XML file contains over 33000 characters, Flash crashes when I try to decrypt it. Is there a limit to amount of data that Flash can decrypt? I'm using rijndael to decrypt and Actionscript 2.0.

Just that the script is causing the flash player to run slowly and if it continues to run, my computer may become unresponsive. It then asks me do I want to abort. If I don't, it just keeps reappearing. the only code in the file is to decrypt, so it isn't caused by anything else.


Your problem is caused by the non-existing multithreading capabilities in Flash: All calculations are supposed to happen "in-between frames", i.e. user algorithms should not take longer to execute than the interval at which the screen is refreshed. If your calculation takes too long to finish, the Flash player will first start to drop frames, and (unless you changed settings) after 15 seconds show the warning you described.

You can get around this by "spreading" your algorithm across multiple frames, making sure only part of the calculation is executed until the screen is refreshed. You can do so by simply splitting up your encrypted string into small enough parts and executing an enterFrame loop to decrypt one at a time, or by implementing something like Alex Harui's PseudoThread class (which essentially does the same, but comes with encapsulation and all that Jazz).

« All tags