Skip to content

Commit

Permalink
created views
Browse files Browse the repository at this point in the history
  • Loading branch information
seanhess committed Aug 20, 2009
1 parent 1783784 commit 6a59fb8
Show file tree
Hide file tree
Showing 17 changed files with 437 additions and 0 deletions.
4 changes: 4 additions & 0 deletions flex/src/Flight.mxml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="vertical" minWidth="1024" minHeight="768">

</mx:Application>
22 changes: 22 additions & 0 deletions flex/src/Glue.mxml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute" xmlns:view="common.view.*">

<view:Register display="true"/>
<view:Login id="login" display="true" login="login.display = false"/>

<view:MainPanel>

<mx:ViewStack id="stack" width="100%" height="100%">
<view:ShowAll/>
<view:Show/>
<view:Edit/>
</mx:ViewStack>

<mx:ControlBar>
<mx:Button label="Create"/>
<mx:Spacer width="100%"/>
<view:Welcome/>
</mx:ControlBar>
</view:MainPanel>

</mx:Application>
4 changes: 4 additions & 0 deletions flex/src/Mate.mxml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="vertical" minWidth="1024" minHeight="768">

</mx:Application>
4 changes: 4 additions & 0 deletions flex/src/Swiz.mxml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="vertical" minWidth="1024" minHeight="768">

</mx:Application>
4 changes: 4 additions & 0 deletions flex/src/Zero.mxml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="vertical" minWidth="1024" minHeight="768">

</mx:Application>
15 changes: 15 additions & 0 deletions flex/src/common/mock/Dictionary.mxml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
<?xml version="1.0" encoding="utf-8"?>
<mx:Object xmlns:mx="http://www.adobe.com/2006/mxml" xmlns:model="common.model.*">

<mx:ArrayCollection id="definitions">
<model:Definition word="Flex" definition="A sweet component framework for flash"/>
<model:Definition word="ActionScript" definition="An ECMA-based language for flash"/>
<model:Definition word="Deathmatch" definition="A competition in which only one framework can survive"/>
<model:Definition word="Flash" definition="A runtime that's even better than silverlight"/>
</mx:ArrayCollection>

<mx:ArrayCollection>
<model:User id="fakeUser" username="fake" password="fake"/>
</mx:ArrayCollection>

</mx:Object>
9 changes: 9 additions & 0 deletions flex/src/common/model/Definition.as
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
package common.model
{
[Bindable]
public class Definition
{
public var word:String;
public var definition:String;
}
}
10 changes: 10 additions & 0 deletions flex/src/common/model/Page.as
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
package common.model
{
public class Page
{
public static const LIST:String = "list";
public static const CREATE:String = "create";
public static const EDIT:String = "edit";
public static const SHOW:String = "show";
}
}
9 changes: 9 additions & 0 deletions flex/src/common/model/User.as
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
package common.model
{
[Bindable]
public class User
{
public var username:String;
public var password:String;
}
}
42 changes: 42 additions & 0 deletions flex/src/common/view/Create.mxml
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
<?xml version="1.0" encoding="utf-8"?>
<mx:VBox xmlns:mx="http://www.adobe.com/2006/mxml" width="100%" height="100%">

<mx:Metadata>
[Event(name="create", type="flash.events.Event")]
[Event(name="cancel", type="flash.events.Event")]
</mx:Metadata>

<mx:Script>
<![CDATA[
import common.model.Definition;
[Bindable] public var definition:Definition;
private function submit():void
{
dispatchEvent(new Event("create"));
}
private function cancel():void
{
dispatchEvent(new Event("cancel"));
}
]]>
</mx:Script>

<mx:Form>
<mx:FormItem label="Word">
<mx:TextInput text="{definition.word}"/>
</mx:FormItem>

<mx:FormItem label="Definition">
<mx:TextArea text="{definition.definition}"/>
</mx:FormItem>

<mx:FormItem direction="horizontal">
<mx:Button label="Create" click="submit()"/>
<mx:Button label="Cancel" click="cancel()"/>
</mx:FormItem>
</mx:Form>

</mx:VBox>
49 changes: 49 additions & 0 deletions flex/src/common/view/Edit.mxml
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
<?xml version="1.0" encoding="utf-8"?>
<mx:VBox xmlns:mx="http://www.adobe.com/2006/mxml" width="100%" height="100%">

<mx:Metadata>
[Event(name="update", type="flash.events.Event")]
[Event(name="cancel", type="flash.events.Event")]
[Event(name="remove", type="flash.events.Event")]
</mx:Metadata>

<mx:Script>
<![CDATA[
import common.model.Definition;
[Bindable] public var definition:Definition;
private function submit():void
{
dispatchEvent(new Event("update"));
}
private function cancel():void
{
dispatchEvent(new Event("cancel"));
}
private function remove():void
{
dispatchEvent(new Event("remove"));
}
]]>
</mx:Script>

<mx:Form>
<mx:FormItem label="Word">
<mx:TextInput text="{definition.word}"/>
</mx:FormItem>

<mx:FormItem label="Definition">
<mx:TextArea text="{definition.definition}"/>
</mx:FormItem>

<mx:FormItem direction="horizontal">
<mx:Button label="Update" click="submit()"/>
<mx:Button label="Delete" click="remove()"/>
<mx:Button label="Cancel" click="cancel()"/>
</mx:FormItem>
</mx:Form>

</mx:VBox>
90 changes: 90 additions & 0 deletions flex/src/common/view/Login.mxml
Original file line number Diff line number Diff line change
@@ -0,0 +1,90 @@
<?xml version="1.0" encoding="utf-8"?>
<mx:Canvas xmlns:mx="http://www.adobe.com/2006/mxml" xmlns:model="common.model.*">

<mx:Metadata>
[Event(name="login", type="flash.events.Event")]
[Event(name="register", type="flash.events.Event")]
</mx:Metadata>

<mx:Script>
<![CDATA[
import mx.managers.PopUpManager;
[Bindable] public var error:String;
public function login():void
{
dispatchEvent(new Event("login"));
}
public function register():void
{
dispatchEvent(new Event("register"));
}
/**
* Make this popup data-driven
*/
public function set display(value:Boolean):void
{
_display = value;
_displayChange = true;
invalidateProperties();
}
protected var _display:Boolean = false;
protected var _displayChange:Boolean = false;
override protected function commitProperties() : void
{
super.commitProperties();
if (_displayChange)
{
_displayChange = false;
if (_display)
{
PopUpManager.addPopUp(popup, this, true);
PopUpManager.centerPopUp(popup);
}
else
{
PopUpManager.removePopUp(popup);
}
}
}
]]>
</mx:Script>

<model:User id="user">
<model:username>{username.text}</model:username>
<model:password>{password.text}</model:password>
</model:User>

<!-- Putting it in an array prevents it from displaying -->
<mx:Array>
<mx:Panel id="popup" title="Login">
<mx:Form>
<mx:FormItem label="Error" visible="{error != null}" includeInLayout="{error != null}">
<mx:Label text="{error}" color="#FF0000" fontWeight="bold"/>
</mx:FormItem>
<mx:FormItem label="Username">
<mx:TextInput id="username" enter="login()"/>
</mx:FormItem>
<mx:FormItem label="Password">
<mx:TextInput id="password" enter="login()"/>
</mx:FormItem>
</mx:Form>

<mx:ControlBar>
<mx:Button label="Login" click="login()"/>
<mx:Button label="Create an Account" click="register()"/>
</mx:ControlBar>
</mx:Panel>
</mx:Array>


</mx:Canvas>
4 changes: 4 additions & 0 deletions flex/src/common/view/MainPanel.mxml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
<?xml version="1.0" encoding="utf-8"?>
<mx:Panel xmlns:mx="http://www.adobe.com/2006/mxml" layout="horizontal" verticalCenter="0" horizontalCenter="0" width="600" height="400" title="Dictionary">

</mx:Panel>
89 changes: 89 additions & 0 deletions flex/src/common/view/Register.mxml
Original file line number Diff line number Diff line change
@@ -0,0 +1,89 @@
<?xml version="1.0" encoding="utf-8"?>
<mx:Canvas xmlns:mx="http://www.adobe.com/2006/mxml" xmlns:model="common.model.*">

<mx:Metadata>
[Event(name="register", type="flash.events.Event")]
[Event(name="cancel", type="flash.events.Event")]
</mx:Metadata>

<mx:Script>
<![CDATA[
import mx.managers.PopUpManager;
[Bindable] public var error:String;
public function register():void
{
dispatchEvent(new Event("register"));
}
public function cancel():void
{
dispatchEvent(new Event("cancel"));
}
/**
* Make this popup data-driven
*/
public function set display(value:Boolean):void
{
_display = value;
_displayChange = true;
invalidateProperties();
}
protected var _display:Boolean = false;
protected var _displayChange:Boolean = false;
override protected function commitProperties() : void
{
super.commitProperties();
if (_displayChange)
{
_displayChange = false;
if (_display)
{
PopUpManager.addPopUp(popup, this, true);
PopUpManager.centerPopUp(popup);
}
else
{
PopUpManager.removePopUp(popup);
}
}
}
]]>
</mx:Script>

<model:User id="user">
<model:username>{username.text}</model:username>
<model:password>{password.text}</model:password>
</model:User>

<!-- Putting it in an array prevents it from displaying -->
<mx:Array>
<mx:Panel id="popup" title="Register">
<mx:Text text="Please choose a username and password" width="300" paddingLeft="10" paddingTop="10" paddingRight="10"/>
<mx:Form>
<mx:FormItem label="Error" visible="{error != null}" includeInLayout="{error != null}">
<mx:Label text="{error}" color="#FF0000" fontWeight="bold"/>
</mx:FormItem>
<mx:FormItem label="Username">
<mx:TextInput id="username"/>
</mx:FormItem>
<mx:FormItem label="Password">
<mx:TextInput id="password"/>
</mx:FormItem>
</mx:Form>

<mx:ControlBar>
<mx:Button label="Sign Me Up!" click="register()"/>
<mx:LinkButton label="Cancel" click="cancel()"/>
</mx:ControlBar>
</mx:Panel>
</mx:Array>

</mx:Canvas>
Loading

0 comments on commit 6a59fb8

Please sign in to comment.