Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

commands

  • Loading branch information...
commit fb355a7e9e6da1057242d01cd8db4f24d1142562 1 parent 32383e9
@seanhess authored
View
61 examples/FlickrBook/src/flickr/glue/MainGlue.mxml
@@ -1,42 +1,57 @@
<?xml version="1.0" encoding="utf-8"?>
-<Controller xmlns:mx="http://www.adobe.com/2006/mxml" xmlns="http://glue.seanhess.net/2009" xmlns:views="flickr.ui.views.*" xmlns:business="flickr.business.*" xmlns:service="flickr.service.*" xmlns:model="flickr.model.*" xmlns:control="flickr.control.*">
+<GlueMap xmlns:mx="http://www.adobe.com/2006/mxml" xmlns="http://glue.seanhess.net/2009" xmlns:views="flickr.ui.views.*" xmlns:business="flickr.business.*" xmlns:service="flickr.service.*" xmlns:model="flickr.model.*" xmlns:control="flickr.control.*" xmlns:store="flickr.store.*">
<mx:Script>
<![CDATA[
+ import flickr.ui.views.MainUI;
import mx.events.FlexEvent;
]]>
</mx:Script>
-
-
-
+ <!-- COMMAND -->
+ <Command id="initialize">
+ <Action watch="{appService}" call="appService.loadConfig()">
+ <config>
+ <Action call="config.setValues(appService.config.url, appService.config.key)"/>
+ <Action call="loadInterestingness.execute()"/>
+ </config>
+ </Action>
+ </Command>
+
+ <Command id="loadInterestingness">
+ <Action watch="{flickrService}" call="flickrService.getInterestingness()">
+ <result>
+ <Action call="photos.storePhotos(scope.event.result)"/>
+ </result>
+ </Action>
+ </Command>
+
+ <Command id="runSearch" search="Set search to be an object with tags and user">
+ <Action watch="{flickrService}" call="flickrService.search(scope.search)">
+ <result>
+ <Action call="photos.storePhotos(scope.event.result)"/>
+ </result>
+ </Action>
+ </Command>
<!-- MODELS :: These are the main models -->
- <model:Photos id="photos"/>
- <model:Config id="config"/>
-
+ <store:Photos id="photos"/>
+ <store:Config id="config"/>
<!-- SERVICES :: Controllers can manipulate models and call other services -->
- <service:ApplicationService id="appService" config="{config}"/>
- <service:MockPhotoService id="mockPhotoService" photos="{photos}" />
-
- <Glue>
- <service:PhotoService id="photoService" photos="{photos}" config="{config}"/>
- <Observe model="{config}" event="{Config.LOADED}" call="photoService.getInterestingness()"/>
- </Glue>
+ <service:ApplicationService id="appService"/>
+ <service:MockFlickrService id="mockFlickr"/>
+ <service:FlickrService id="flickrService" config="{config}"/>
<!-- VIEWS -->
-
- <Glue match=".mainInterface>
- <views:MainUI id="main"/>
- <Route event="{FlexEvent.CREATION_COMPLETE}" call="appService.loadConfig()"/>
- <Route event="{MainUI.INTERESTINGNESS}" call="photoService.getInterestingness()"/>
- <Route event="{MainUI.SEARCH}" call="photoService.search(main.search)"/>
+ <Glue match="MainUI">
+ <Route event="{FlexEvent.CREATION_COMPLETE}" call="initialize.execute()"/>
+ <Route event="{MainUI.INTERESTINGNESS}" call="loadInterestingness.execute()"/>
+ <Route event="{MainUI.SEARCH}" call="runSearch.execute({search:view.search})"/>
</Glue>
- <Glue>
- <views:PhotoViewer id="photoViewer"/>
+ <Glue match="PhotoViewer">
<Inject currentSet="{photos.currentSet}"/>
</Glue>
-</Controller>
+</GlueMap>
View
9 examples/FlickrBook/src/flickr/manager/ApplicationManager.as
@@ -1,9 +0,0 @@
-package flickr.manager
-{
- public class ApplicationManager
- {
- public function ApplicationManager()
- {
- }
- }
-}
View
26 examples/FlickrBook/src/flickr/manager/ApplicationManager.mxml
@@ -1,26 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<events:EventDispatcher xmlns:mx="http://www.adobe.com/2006/mxml" xmlns:business="flickr.business.*" xmlns:model="flickr.model.*" xmlns:events="flash.events.*">
-
- <mx:HTTPService id="configService" resultFormat="e4x" url="assets/config/configuration.xml" result="onConfigLoaded(event)"/>
-
- <mx:Script>
- <![CDATA[
- import flickr.model.Config;
-
- import mx.rpc.events.ResultEvent;
-
- [Bindable] public var config:Config;
-
- public function loadConfig():void
- {
- configService.send();
- }
-
- private function onConfigLoaded(event:ResultEvent):void
- {
- var info:XML = event.result as XML;
- config.setValues(info..url, info..api_key);
- }
- ]]>
- </mx:Script>
-</events:EventDispatcher>
View
35 examples/FlickrBook/src/flickr/manager/MockPhotoManager.mxml
@@ -1,35 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<mx:Object xmlns:mx="http://www.adobe.com/2006/mxml" xmlns:business="flickr.business.*" xmlns:model="flickr.model.*" xmlns:service="flickr.service.*">
-
- <mx:Array id="list">
- <model:Photo farmId="1" photoId="3263147997" isPublic="true" secret="ba252ca104" serverId="241" title="RIA-Survey"/>
- <model:Photo farmId="4" photoId="3102433937" isPublic="true" secret="fdb85613e4" serverId="3237" title="bW.Calc-iT"/>
- <model:Photo farmId="4" photoId="3052457714" isPublic="true" secret="ab49c8e883" serverId="3182" title="Trixie and Flex"/>
- <model:Photo farmId="4" photoId="2948015888" isPublic="true" secret="3178196411" serverId="3207" title="Eboy"/>
- <model:Photo farmId="4" photoId="2936186907" isPublic="true" secret="27aa5f4888" serverId="3157" title="MiamiPHP Pool Party"/>
- <model:Photo farmId="4" photoId="2937041802" isPublic="true" secret="ece54ba500" serverId="3198" title="MiamiPHP Pool Party"/>
- <model:Photo farmId="4" photoId="2936187195" isPublic="true" secret="9445a9551e" serverId="3249" title="MiamiPHP Pool Party - Paul"/>
- <model:Photo farmId="4" photoId="2936187647" isPublic="true" secret="92438b093f" serverId="3207" title="MiamiPHP Pool Party"/>
- <model:Photo farmId="4" photoId="2936187059" isPublic="true" secret="22d484729c" serverId="3009" title="MiamiPHP Pool Party"/>
- </mx:Array>
-
- <mx:Script>
- <![CDATA[
- import flickr.model.Photos;
- import flickr.model.Search;
-
- [Bindable] public var photos:Photos;
-
- public function getInterestingness():void
- {
- photos.storePhotos(list);
- }
-
- public function search(value:Search):void
- {
- getInterestingness();
- }
- ]]>
- </mx:Script>
-
-</mx:Object>
View
31 examples/FlickrBook/src/flickr/manager/PhotoManager.as
@@ -1,31 +0,0 @@
-package flickr.manager
-{
- import mx.rpc.events.ResultEvent;
- import flickr.model.Photos;
- import flickr.model.Search;
-
- public class PhotoManager
- {
- public var photos:Photos;
- private var currentSearch:Search;
-
- public function getInterestingness():void
- {
- interestingness.send();
- }
-
- public function search(value:Search):void
- {
- currentSearch = value;
- searching.send();
- }
-
- private function onResult(event:ResultEvent):void
- {
- var list:Array = parser.parseXML(event.result as XML);
- this.photos.storePhotos(list);
- }
-
-
- }
-}
View
55 examples/FlickrBook/src/flickr/manager/PhotoManager.mxml
@@ -1,55 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<mx:Object xmlns:mx="http://www.adobe.com/2006/mxml" xmlns:business="flickr.business.*" xmlns:model="flickr.model.*" xmlns:service="flickr.service.*">
-
- <model:Config id="config"/>
-
- <!-- Other Services -->
- <mx:HTTPService id="interestingness" url="{config.url}" resultFormat="e4x" result="onResult(event)">
- <mx:request>
- <api_key>{config.key}</api_key>
- <method>flickr.interestingness.getList</method>
- </mx:request>
- </mx:HTTPService>
-
- <mx:HTTPService id="searching" url="{config.url}" resultFormat="e4x" result="onResult(event)">
- <mx:request>
- <api_key>{config.key}</api_key>
- <method>flickr.photos.search</method>
- <user_id>{currentSearch.user}</user_id>
- <page>{currentSearch.page}</page>
- <tags>{currentSearch.tags}</tags>
- </mx:request>
- </mx:HTTPService>
-
- <service:FlickrParser id="parser"/>
-
- <mx:Script>
- <![CDATA[
- import mx.rpc.events.ResultEvent;
- import flickr.model.Photos;
- import flickr.model.Search;
-
- [Bindable] public var photos:Photos;
- [Bindable] private var currentSearch:Search;
-
- public function getInterestingness():void
- {
- interestingness.send();
- }
-
- public function search(value:Search):void
- {
- currentSearch = value;
- searching.send();
- }
-
- private function onResult(event:ResultEvent):void
- {
- var list:Array = parser.parseXML(event.result as XML);
- this.photos.storePhotos(list);
- }
-
- ]]>
- </mx:Script>
-
-</mx:Object>
View
7 examples/FlickrBook/src/flickr/store/Config.as → examples/FlickrBook/src/flickr/model/Config.as
@@ -1,12 +1,10 @@
-package flickr.store
+package flickr.models
{
import flash.events.EventDispatcher;
[Bindable]
- public class Config extends EventDispatcher
+ public class Config
{
- public static const LOADED:String = "loaded";
-
public var url:String = 'http://api.flickr.com/services/rest/';
public var key:String = '';
@@ -14,7 +12,6 @@ package flickr.store
{
this.url = url;
this.key = key;
- dispatchEvent(new Event(LOADED));
}
}
}
View
15 examples/FlickrBook/src/flickr/model/Photos.as
@@ -0,0 +1,15 @@
+package flickr.model
+{
+ import mx.collections.ArrayCollection;
+
+ [Bindable]
+ public class Photos
+ {
+ public var currentSet:ArrayCollection;
+
+ public function storePhotos(value:Array):void
+ {
+ currentSet = new ArrayCollection(value);
+ }
+ }
+}
View
33 examples/FlickrBook/src/flickr/service/ApplicationService.mxml
@@ -1,4 +1,31 @@
<?xml version="1.0" encoding="utf-8"?>
-<mx:Object xmlns:mx="http://www.adobe.com/2006/mxml">
- <mx:HTTPService id="configService" resultFormat="e4x" url="assets/config/configuration.xml"/>
-</mx:Object>
+<events:EventDispatcher xmlns:mx="http://www.adobe.com/2006/mxml" xmlns:events="flash.events.*">
+ <mx:HTTPService id="configService" resultFormat="e4x" url="assets/config/configuration.xml" result="onConfigLoaded(event)"/>
+
+
+
+ <mx:Script>
+ <![CDATA[
+ import flickr.store.Config;
+ import mx.rpc.events.ResultEvent;
+
+ public var config:Config;
+
+ public function loadConfig():void
+ {
+ configService.send();
+ }
+
+ private function onConfigLoaded(event:ResultEvent):void
+ {
+ var xml:XML = event.result as XML;
+
+ config = new Config();
+ config.key = xml..api_key;
+ config.url = xml..url;
+
+ dispatchEvent(new Event("config"));
+ }
+ ]]>
+ </mx:Script>
+</events:EventDispatcher>
View
53 examples/FlickrBook/src/flickr/service/FlickrService.mxml
@@ -1,16 +1,10 @@
<?xml version="1.0" encoding="utf-8"?>
-<mx:Object xmlns:mx="http://www.adobe.com/2006/mxml" xmlns:business="flickr.business.*" xmlns:model="flickr.model.*" xmlns:service="flickr.service.*">
-
- <mx:Script>
- <![CDATA[
- import flickr.store.Config;
-
- [Bindable] public var config:Config;
- ]]>
- </mx:Script>
+<events:EventDispatcher xmlns:mx="http://www.adobe.com/2006/mxml" xmlns:business="flickr.business.*" xmlns:model="flickr.model.*" xmlns:service="flickr.service.*" xmlns:events="flash.events.*" xmlns:store="flickr.store.*">
+
+ <store:Config id="config"/>
<!-- Other Services -->
- <mx:HTTPService id="interestingness" url="{config.url}" resultFormat="e4x" result="onResult(event)">
+ <mx:HTTPService id="interestingness" url="{config.url}" resultFormat="e4x" result="onResult(event)" fault="onFault(event)">
<mx:request>
<api_key>{config.key}</api_key>
<method>flickr.interestingness.getList</method>
@@ -21,12 +15,43 @@
<mx:request>
<api_key>{config.key}</api_key>
<method>flickr.photos.search</method>
- <user_id>{currentSearch.user}</user_id>
+ <!--<user_id>{currentSearch.user}</user_id>
<page>{currentSearch.page}</page>
- <tags>{currentSearch.tags}</tags>
+ <tags>{currentSearch.tags}</tags>-->
</mx:request>
</mx:HTTPService>
<service:FlickrParser id="parser"/>
-
-</mx:Object>
+
+ <mx:Script>
+ <![CDATA[
+ import mx.rpc.events.FaultEvent;
+ import mx.collections.ArrayCollection;
+ import mx.rpc.events.ResultEvent;
+
+ public function getInterestingness():void
+ {
+ interestingness.send();
+ }
+
+ public function search(value:Object):void
+ {
+ searching.request.user_id = value.user;
+ searching.request.tags = value.tags;
+ searching.send();
+ }
+
+ private function onResult(event:ResultEvent):void
+ {
+ var list:Array = parser.parseXML(event.result as XML);
+ dispatchEvent(ResultEvent.createEvent(list));
+ }
+
+ private function onFault(event:FaultEvent):void
+ {
+ trace("FAULT " + event.fault);
+ }
+ ]]>
+ </mx:Script>
+
+</events:EventDispatcher>
View
24 examples/FlickrBook/src/flickr/service/MockFlickrService.mxml
@@ -15,20 +15,20 @@
<mx:Script>
<![CDATA[
- import flickr.model.Photos;
- import flickr.model.Search;
+// import flickr.model.Photos;
+// import flickr.model.Search;
- [Bindable] public var photos:Photos;
+// [Bindable] public var photos:Photos;
- public function getInterestingness():void
- {
- photos.storePhotos(list);
- }
-
- public function search(value:Search):void
- {
- getInterestingness();
- }
+// public function getInterestingness():void
+// {
+// photos.storePhotos(list);
+// }
+////
+// public function search(value:Search):void
+// {
+// getInterestingness();
+// }
]]>
</mx:Script>
View
13 examples/FlickrBook/src/flickr/store/Photos.as
@@ -1,13 +0,0 @@
-package flickr.store
-{
- import flash.events.Event;
- import flash.events.EventDispatcher;
-
- import mx.collections.ArrayCollection;
-
- [Bindable]
- public class Photos extends EventDispatcher
- {
- public var currentSet:ArrayCollection;
- }
-}
View
10 examples/FlickrBook/src/flickr/store/Search.as
@@ -1,10 +0,0 @@
-package flickr.model
-{
- [Bindable]
- public class Search
- {
- public var tags:String;
- public var user:String;
- public var page:int = 0;
- }
-}
View
10 examples/FlickrBook/src/flickr/ui/views/MainUI.mxml
@@ -1,7 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<mx:Canvas xmlns:mx="http://www.adobe.com/2006/mxml"
xmlns:controls="flexlib.controls.*"
- xmlns:qs="qs.controls.*" xmlns:views="flickr.ui.views.*" xmlns:model="flickr.model.*">
+ xmlns:qs="qs.controls.*" xmlns:views="flickr.ui.views.*">
<mx:Script>
<![CDATA[
@@ -20,10 +20,10 @@
]]>
</mx:Script>
- <model:Search id="search">
- <model:tags>{tagsInput.text}</model:tags>
- <model:user>{userInput.text}</model:user>
- </model:Search>
+ <mx:Object id="search">
+ <mx:tags>{tagsInput.text}</mx:tags>
+ <mx:user>{userInput.text}</mx:user>
+ </mx:Object>
<mx:HBox styleName="topBar" width="100%" height="55" >
View
BIN  source/bin/Glue.swc
Binary file not shown
View
3  source/src/net/seanhess/glue/tags/Action.as
@@ -40,6 +40,9 @@ package net.seanhess.glue.tags
{
if (value is Action)
value = [value];
+
+ if (value is String)
+ return;
if (!(value is Array))
throw new Error("Use <eventName> to specify a list of actions to perform");
Please sign in to comment.
Something went wrong with that request. Please try again.