Fixed Saving SWFs opened by "Open loaded while playing" feature

Added sample data for loader
This commit is contained in:
Jindra Petřík
2023-12-30 12:44:22 +01:00
parent 8e817f6421
commit 8ee83b49f5
10 changed files with 488 additions and 13 deletions

View File

@@ -0,0 +1,10 @@
package
{
import flash.utils.ByteArray;
[Embed(source="/../bin/inside_xored.swf", mimeType="application/octet-stream")]
public class EncryptedByteArray extends ByteArray
{
}
}

View File

@@ -0,0 +1,59 @@
package
{
import flash.events.Event;
import flash.utils.ByteArray;
import flash.display.Loader;
import flash.display.Sprite;
import flash.display.StageAlign;
import flash.display.StageScaleMode;
public class Main extends Sprite
{
private var swfLoader: Loader;
public function Main():void
{
if (stage) {
init();
} else {
addEventListener(Event.ADDED_TO_STAGE, init);
}
}
private function init(e:Event = null):void
{
removeEventListener(Event.ADDED_TO_STAGE, init);
var encrypted:ByteArray = new EncryptedByteArray();
var decrypted:ByteArray = decrypt(encrypted);
this.swfLoader = new Loader();
this.swfLoader.contentLoaderInfo.addEventListener(Event.COMPLETE, onSWFLoaded);
this.swfLoader.loadBytes(decrypted);
}
private function decrypt(encrypted: ByteArray): ByteArray
{
var decrypted:ByteArray = new ByteArray();
for (var i:int = 0; i < encrypted.length; i++) {
decrypted[i] = encrypted[i] ^ 65;
}
return decrypted;
}
private function onSWFLoaded(event:Event):void {
var loadedSWF:Sprite = this.swfLoader.content as Sprite;
addChild(loadedSWF);
stage.scaleMode = StageScaleMode.NO_SCALE;
stage.align = StageAlign.TOP_LEFT;
// loadedSWF.x = ...
// loadedSWF.y = ...
// loadedSWF.width = ...
// loadedSWF.height = ...
}
}
}