I’m trying to load an external swf into another swf and acces some variables and functions. This actually works quite well, however I’m dealing with some variables from the external loaded swf that are read-only.
I’m wondering if I could somehow change the variable to be writeable as well by extending a function from the loaded swf.
Maybe there’s also another way to change the read-only variable, but I have no clue.
I know all the variables, functions and class names from the loaded swf, I just can’t change them myself, I have to do it by loading the swf externally.
The class from the external swf is called “Application” where I want to change the “public const DEV_SERVER_URL:String” to another string, or extend the function: “private function get serverUrl()” returning a string.
Code I made so far to acces the variable.
When I do swf.DEV_SERVER_URL = “test”; it says “can’t change read-only variable”.
package {
// Module
import flash.display.Loader;
import flash.display.LoaderInfo;
import flash.display.Sprite;
import flash.events.ProgressEvent;
import flash.net.URLRequest;
import flash.events.Event;
// Class
public class Main extends Sprite {
// Variable
private var loadContent:String = "Application.swf";
// Functions
public function Main():void {
StartLoad();
}
private function StartLoad():void {
trace("loading");
var urlLoader:Loader = new Loader();
var urlRequest:URLRequest = new URLRequest(loadContent);
urlLoader.contentLoaderInfo.addEventListener(Event.COMPLETE, LoadComplete);
urlLoader.contentLoaderInfo.addEventListener(ProgressEvent.PROGRESS, LoadProgress);
urlLoader.load(urlRequest);
}
private function LoadComplete(evt:Event):void {
trace("loaded complete");
appC.addChild(evt.currentTarget.content);
var loaderInfo:LoaderInfo = evt.target as LoaderInfo;
var swf:Object = loaderInfo.content;
trace(swf.DEV_SERVER_URL);
}
private function LoadProgress(evt:ProgressEvent):void {
trace(evt.bytesLoaded);
}
}
}
Hopefully someone is more knowledged about this topic.