我只是尝试从 HTML URL 变量加载外部图像。示例:src="http://mysite.com/flash/load.swf?imageURL=http://mysite.com/img/image.jpg"
var imageURL:String = this.loaderInfo.parameters.imageURL;
var murl:URLRequest = new URLRequest(imageURL);
var loader:Loader = new Loader();
loader.load(murl);
loader.contentLoaderInfo.addEventListener(ProgressEvent.PROGRESS, loadProgress);
loader.contentLoaderInfo.addEventListener(Event.COMPLETE, loadComplete);
function loadProgress(event:ProgressEvent):void
{
var percentLoaded:Number = Math.round((event.bytesLoaded/event.bytesTotal) * 100);
trace("Loading: "+percentLoaded+"%");
}
function loadComplete(event:Event):void
{
trace("Complete");
mc.addChild(loader);
}
是的,这是有效的。但我想知道图像宽度和高度信息。因为我尝试为图像信息执行此操作
function loadComplete(event:Event):void
{
trace("Complete");
var bm:Bitmap = Bitmap(loader.content);
var CXL = bm.width;
var CYL = bm.height;
但它不起作用。任何建议请谢谢