Chapter 27 Example 4
♥0 |
Line 43 |
Modified 2010-02-03 04:37:40 |
MIT License
archived:2017-03-09 14:00:41
ActionScript3 source code
/**
* Copyright actionscriptbible ( http://wonderfl.net/user/actionscriptbible )
* MIT License ( http://www.opensource.org/licenses/mit-license.php )
* Downloaded from: http://wonderfl.net/c/8Ffx
*/
package {
import flash.display.*;
import flash.events.Event;
import flash.net.URLRequest;
import flash.system.*;
import flash.text.*;
import flash.utils.describeType;
public class ch27ex4 extends Sprite {
public function ch27ex4() {
var l:Loader;
l = new Loader();
l.load(new URLRequest("http://actionscriptbible.com/files/icon-fl.swf"),
new LoaderContext(true, null, SecurityDomain.currentDomain));
l.contentLoaderInfo.addEventListener(Event.COMPLETE, onComplete);
l = new Loader();
l.load(new URLRequest("http://actionscriptbible.com/files/icon-fx.swf"),
new LoaderContext(true, null, SecurityDomain.currentDomain));
l.contentLoaderInfo.addEventListener(Event.COMPLETE, onComplete);
}
protected function onComplete(event:Event):void {
var loaderInfo:LoaderInfo = LoaderInfo(event.target);
var iconClass:Class =
Class(loaderInfo.applicationDomain.getDefinition("assets.Icon"));
var icon:DisplayObject = DisplayObject(new iconClass());
addChild(icon);
var tf:TextField = new TextField();
tf.defaultTextFormat = new TextFormat("_sans", 11, 0);
tf.width = 150; tf.height = 400; tf.y = 130;
tf.multiline = tf.wordWrap = true;
addChild(tf);
tf.text = loaderInfo.url + "\n\n" + typeInfo(icon);
if (numChildren > 2) tf.x = icon.x = 160;
}
protected function typeInfo(obj:Object):String {
var info:XML = describeType(obj);
var ret:String = info.@name;
for each (var extendsNode:XML in info.extendsClass) {
ret += " \u2192 " + extendsNode.@type.toString().replace(/^.*::/, "");
}
return ret;
}
}
}