1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 | package { import flash.display.Sprite; import flash.events.Event; import flash.display.Loader; import flash.net.URLRequest; public class Main extends Sprite{ private var photoUrl:URLRequest = new URLRequest("1.jpg"); private var photoLoad:Loader = new Loader(); private var contain:Sprite = new Sprite(); public function Main() { init(); } private function init():void { addChild(contain); photoLoad.load(photoUrl); photoLoad.contentLoaderInfo.addEventListener(Event.COMPLETE, photo_fun); } private function photo_fun(e:Event):void { photoLoad.content.width = photoLoad.content.width / 2; photoLoad.content.height = photoLoad.content.height / 2; contain.x = this.stage.stageWidth / 2 - photoLoad.content.width / 2; contain.y = this.stage.stageHeight / 2 - photoLoad.content.height / 2; contain.addChild(photoLoad); } } } |
content 这个属性。
转帖自:http://www.cnblogs.com/faily201/articles/2167480.html