Over 10 years of community discussion and knowledge are maintained here as a read-only archive.
public class GetPhotosCommand extends BaseCommand { private var gallery:GalleryProxy; override public function execute(note:INotification):void { var delegate:GalleryDelegate = new GalleryDelegate(this); delegate.getAllImages(); } override public function result(data:Object):void { var rs:Array = data.result as Array; var images:Array = new Array(); for (var i:int = 0; i < rs.length; i++) { var image:ImageVO = GalleryUtils.getImageVO(rs[i]) as ImageVO; images.push(image); } gallery = facade.retrieveProxy(GalleryProxy.NAME) as GalleryProxy; gallery.addImages(images); } override public function fault(data:Object):void { } }
public class GalleryDelegate { public static const GATEWAY:String = "http://localhost/thaihuynh/amf/gateway/index.php"; private var service:ServiceProxy; private var responder:IResponder; public function GalleryDelegate(responder:IResponder) { this.responder = responder; service = new ServiceProxy(GATEWAY, "gallery"); service.addEventListener(ResultEvent.RESULT, resultHandler); service.addEventListener(FaultEvent.FAULT, faultHandler); service.addEventListener(FaultEvent.CONNECTION_ERROR, faultHandler); } public function getAllImages():void { service.call("getImages", []); } private function resultHandler(event:ResultEvent):void { responder.result(event); } private function faultHandler(event:FaultEvent):void { responder.fault(event); } }
public class GalleryProxy extends Proxy implements IProxy { public static const NAME:String = "RemoteProxy"; private var images:Array = []; public function GalleryProxy(data:Object=null) { super(NAME, data); } public function addImages(images:Array):void { this.images = images; sendNotification(ApplicationFacade.GALLERY_LOADED, images); } public function getImages():Array { return images; } }
public class GetPhotosCommand extends SimpleCommand implements ICommand { override public function execute(note:INotification):void { var service:GalleryProxy = facade.retrieveProxy(GalleryProxy.NAME) as GalleryProxy; service.getGalleryImages(); } }
public class GalleryProxy extends Proxy implements IProxy { public static const GATEWAY:String = "http://localhost/thaihuynh/amf/gateway/index.php"; public static const NAME:String = "RemoteProxy"; private var service:ServiceProxy; private var images:Array = []; public function GalleryProxy(data:Object=null) { super(NAME, data); service = new ServiceProxy(GATEWAY, "gallery"); service.addEventListener(ResultEvent.RESULT, resultHandler); service.addEventListener(FaultEvent.FAULT, faultHandler); service.addEventListener(FaultEvent.CONNECTION_ERROR, faultHandler); } private function resultHandler(event:ResultEvent):void { var results:Array = event.result as Array; for (var i:int = 0; i < results.length; i++) { var image:ImageVO = GalleryUtils.getImageVO(results[i]) as ImageVO; images.push(image); } sendNotification(ApplicationFacade.GALLERY_LOADED, images); } private function faultHandler(event:FaultEvent):void { trace(event.fault); } public function getGalleryImages():void { service.call("getImages", []); } public function getImages():Array { return images; }
private function resultHandler(event:ResultEvent):void { var results:Array = event.result as Array; for (var i:int = 0; i < results.length; i++) { var image:IValueObject = factoryClass.createValueObject(results[i], commandRef); images.push(image); } sendNotification(ApplicationFacade.GALLERY_LOADED, images); }
public class GalleryProxy extends Proxy implements IProxy, IResponder { public static const GATEWAY:String = "http://localhost/thaihuynh/amf/gateway/index.php"; public static const NAME:String = "RemoteProxy"; private var delegate:GalleryDelegate; private var service:ServiceProxy; private var images:Array = []; public function GalleryProxy(data:Object=null) { super(NAME, data); delegate = new GalleryDelegate(this); } public function result(data:Object):void { var results:Array = data.result as Array; for (var i:int = 0; i < results.length; i++) { var image:ImageVO = GalleryUtils.getImageVO(results[i]) as ImageVO; images.push(image); } sendNotification(ApplicationFacade.GALLERY_LOADED, images); } public function fault(data:Object):void { trace(data.fault); } public function getGalleryImages():void { delegate.getGalleryImages(); } public function getImages():Array { return images; } }
public class GalleryDelegate { //public static const GATEWAY:String = "http://thaihuynh.com/amf/gateway/index.php"; public static const GATEWAY:String = "http://localhost/thaihuynh/amf/gateway/index.php"; private var responder:IResponder; private var service:ServiceProxy; public function GalleryDelegate(responder:IResponder) { this.responder = responder; service = new ServiceProxy(GATEWAY, "gallery"); service.addEventListener(ResultEvent.RESULT, resultHandler); service.addEventListener(FaultEvent.FAULT, faultHandler); service.addEventListener(FaultEvent.CONNECTION_ERROR, faultHandler); } public function getGalleryImages():void { service.call("getImages", []); } public function getAlbums():void { service.call("getAlbums", []); } private function resultHandler(event:ResultEvent):void { responder.result(event); } private function faultHandler(event:FaultEvent):void { responder.fault(event); } }
public class GetPhotosCommand extends SimpleCommand implements ICommand{ override public function execute(note:INotification):void { var galleryProxy:GalleryProxy = facade.retrieveProxy(GalleryProxy.NAME) as GalleryProxy; galleryProxy.getGalleryImages(); }}