package { import flash.display.Sprite; import flash.display.Loader; import flash.net.URLRequest; import flash.events.Event; import flash.events.MouseEvent; public class Fun extends Sprite { private var loader = new Loader(); private var loaderA = new Loader(); private var loader1 = new Loader(); private var loaderA1 = new Loader(); private var loader2 = new Loader(); private var loaderA2 = new Loader(); private var loader3 = new Loader(); private var loaderA3 = new Loader(); public function Fun () { loader.load(new URLRequest("家乡1.jpg")); loaderA.load(new URLRequest("家乡1.jpg")); loader1.load(new URLRequest("家乡2.jpg")); loaderA1.load(new URLRequest("家乡2.jpg")); loader2.load(new URLRequest("家乡3.jpg")); loaderA2.load(new URLRequest("家乡3.jpg")); loader3.load(new URLRequest("家乡4.jpg")); loaderA3.load(new URLRequest("家乡4.jpg")); loader.contentLoaderInfo.addEventListener(Event.COMPLETE,onLoaderCompleteHandler); loaderA.contentLoaderInfo.addEventListener(Event.COMPLETE,onLoaderACompleteHandler); loader1.contentLoaderInfo.addEventListener(Event.COMPLETE,onLoader1CompleteHandler); loaderA1.contentLoaderInfo.addEventListener(Event.COMPLETE,onLoaderA1CompleteHandler); loader2.contentLoaderInfo.addEventListener(Event.COMPLETE,onLoader2CompleteHandler); loaderA2.contentLoaderInfo.addEventListener(Event.COMPLETE,onLoaderA2CompleteHandler); loader3.contentLoaderInfo.addEventListener(Event.COMPLETE,onLoader3CompleteHandler); loaderA3.contentLoaderInfo.addEventListener(Event.COMPLETE,onLoaderA3CompleteHandler); loader.addEventListener(MouseEvent.CLICK,bianda); loader1.addEventListener(MouseEvent.CLICK,bianda1); loader2.addEventListener(MouseEvent.CLICK,bianda2); loader3.addEventListener(MouseEvent.CLICK,bianda3); } private function onLoaderCompleteHandler (e:Event):void { loader.x = 0; loader.y = 320; loader.width = 137.5; loader.height = 80; stage.addChild(loader); } private function onLoaderACompleteHandler (e:Event):void { loaderA.x = 75; loaderA.y = 0; loaderA.width = 400; loaderA.height = 300; stage.addChild(loaderA); } private function bianda (e:MouseEvent):void { loaderA.visible = true; loaderA1.visible = false; loaderA2.visible = false; loaderA3.visible = false; } private function onLoader1CompleteHandler (e:Event):void { loader1.x = 137.5; loader1.y = 320; loader1.width = 137.5; loader1.height = 80; stage.addChild(loader1); } private function onLoaderA1CompleteHandler (e:Event):void { loaderA1.x = 75; loaderA1.y = 0; loaderA1.width = 400; loaderA1.height = 300; stage.addChild(loaderA1); } private function bianda1 (e:MouseEvent):void { loaderA.visible = false; loaderA1.visible = true; loaderA2.visible = false; loaderA3.visible = false; } private function onLoader2CompleteHandler (e:Event):void { loader2.x = 275; loader2.y = 320; loader2.width = 137.5; loader2.height = 80; stage.addChild(loader2); } private function onLoaderA2CompleteHandler (e:Event):void { loaderA2.x = 75; loaderA2.y = 0; loaderA2.width = 400; loaderA2.height = 300; stage.addChild(loaderA2); } private function bianda2 (e:MouseEvent):void { loaderA.visible = false; loaderA1.visible = false; loaderA2.visible = true; loaderA3.visible = false; } private function onLoader3CompleteHandler (e:Event):void { loader3.x = 412.5; loader3.y = 320; loader3.width = 137.5; loader3.height = 80; stage.addChild(loader3); } private function onLoaderA3CompleteHandler (e:Event):void { loaderA3.x = 75; loaderA3.y = 0; loaderA3.width = 400; loaderA3.height = 300; stage.addChild(loaderA3); } private function bianda3 (e:MouseEvent):void { loaderA.visible = false; loaderA1.visible = false; loaderA2.visible = false; loaderA3.visible = true; } } }