Merge remote-tracking branch 'PracticingFlex/master'
5
PracticingFlex/.gitignore
vendored
Normal file
@ -0,0 +1,5 @@
|
||||
*.pyc
|
||||
*.swf
|
||||
*.swc
|
||||
*.swf.cache
|
||||
*generated
|
46
PracticingFlex/01-flickr/FlickrRIA.mxml
Normal file
@ -0,0 +1,46 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml"
|
||||
backgroundGradientColors="[0xFFFFFF, 0xAAAAAA]"
|
||||
horizontalAlign="left"
|
||||
verticalGap="15"
|
||||
horizontalGap="15">
|
||||
|
||||
<mx:Script>
|
||||
<![CDATA[
|
||||
import mx.collections.ArrayCollection;
|
||||
import mx.rpc.events.ResultEvent;
|
||||
|
||||
[Bindable]
|
||||
private var photoFeed:ArrayCollection;
|
||||
|
||||
private function requestPhotos():void {
|
||||
photoService.cancel();
|
||||
var params:Object = new Object();
|
||||
params.format = 'rss_200_enc';
|
||||
params.tags = searchTerms.text;
|
||||
photoService.send(params);
|
||||
}
|
||||
|
||||
private function photoHandler(event:ResultEvent):void {
|
||||
photoFeed = event.result.rss.channel.item as ArrayCollection;
|
||||
}
|
||||
]]>
|
||||
</mx:Script>
|
||||
|
||||
<mx:HTTPService id="photoService"
|
||||
url="http://api.flickr.com/services/feeds/photos_public.gne"
|
||||
result="photoHandler(event)" />
|
||||
|
||||
<mx:HBox>
|
||||
<mx:Label text="Flickr tags or search terms:" />
|
||||
<mx:TextInput id="searchTerms" />
|
||||
<mx:Button label="Search"
|
||||
click="requestPhotos()" />
|
||||
</mx:HBox>
|
||||
|
||||
<mx:TileList width="100%" height="100%"
|
||||
dataProvider="{photoFeed}"
|
||||
itemRenderer="FlickrThumbnail">
|
||||
</mx:TileList>
|
||||
|
||||
</mx:Application>
|
13
PracticingFlex/01-flickr/FlickrThumbnail.mxml
Normal file
@ -0,0 +1,13 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<mx:VBox xmlns:mx="http://www.adobe.com/2006/mxml"
|
||||
width="125" height="125"
|
||||
horizontalAlign="center"
|
||||
paddingBottom="5" paddingLeft="5" paddingRight="5" paddingTop="5">
|
||||
|
||||
<mx:Image
|
||||
width="75" height="75"
|
||||
source="{data.thumbnail.url}" />
|
||||
|
||||
<mx:Text width="100" text="{data.credit}" />
|
||||
|
||||
</mx:VBox>
|
47
PracticingFlex/02-shipping/PlainText.mxml
Normal file
@ -0,0 +1,47 @@
|
||||
<mx:Application name=""
|
||||
xmlns:mx="http://www.adobe.com/2006/mxml"
|
||||
layout="absolute"
|
||||
backgroundColor="#FFFFFF"
|
||||
backgroundImage="">
|
||||
|
||||
<mx:Script>
|
||||
<![CDATA[
|
||||
|
||||
import mx.rpc.events.ResultEvent;
|
||||
import mx.rpc.events.FaultEvent;
|
||||
import mx.controls.Alert;
|
||||
|
||||
|
||||
private function handlePlain(event:ResultEvent):void
|
||||
{
|
||||
shippingOptions.htmlText = event.result.toString();
|
||||
}
|
||||
|
||||
|
||||
private function handleFault(event:FaultEvent):void
|
||||
{
|
||||
Alert.show(event.fault.faultString, "Error");
|
||||
}
|
||||
|
||||
]]>
|
||||
</mx:Script>
|
||||
|
||||
<mx:HTTPService id="plainRPC" url="http://10.10.231.98:18080/text"
|
||||
result="handlePlain(event)"
|
||||
fault="handleFault(event)"
|
||||
resultFormat="text">
|
||||
<mx:request xmlns="">
|
||||
<zipcode>{zipcode.text}</zipcode>
|
||||
<pounds>{weight_lb.text}</pounds>
|
||||
</mx:request>
|
||||
</mx:HTTPService>
|
||||
|
||||
<mx:Label x="54" y="25" text="Zip Code"/>
|
||||
<mx:Label x="65" y="51" text="Weight"/>
|
||||
<mx:TextInput x="128" y="23" id="zipcode"/>
|
||||
<mx:TextInput x="128" y="49" id="weight_lb"/>
|
||||
<mx:Button x="128" y="79" label="Get Shipping Options"
|
||||
click="plainRPC.send();" />
|
||||
<mx:TextArea x="339" y="24" width="198" height="77" id="shippingOptions"/>
|
||||
|
||||
</mx:Application>
|
175
PracticingFlex/02-shipping/shipping.py
Normal file
@ -0,0 +1,175 @@
|
||||
"""
|
||||
standalone WSGI application for serving plaintext and xml suitable
|
||||
for the Adobe Flex "Getting Started" tutorial, "Part II. Exchanging Data"
|
||||
|
||||
For the plaintext data flex app, set the HTTPService url to:
|
||||
|
||||
http://<hostname>:<port>/text
|
||||
|
||||
For the xml data flex app, set the HTTPService url to:
|
||||
|
||||
http://<hostname>:<port>/xml
|
||||
|
||||
"""
|
||||
from __future__ import print_function
|
||||
|
||||
import sys
|
||||
import cgi
|
||||
import optparse
|
||||
from wsgiref.simple_server import make_server
|
||||
|
||||
__author__ = 'Dan Buch dbuch@ag.com'
|
||||
__license__ = 'AGI'
|
||||
|
||||
USAGE = """\
|
||||
%prog [options]
|
||||
Run a standalone WSGI app for the Adobe Flex Tutorial
|
||||
"Getting Started", "Part II. Exchanging Data"
|
||||
"""
|
||||
|
||||
|
||||
def main(sysargs=sys.argv[:]):
|
||||
parser = optparse.OptionParser(usage=USAGE)
|
||||
parser.add_option('-p', '--port', dest='port', type='int',
|
||||
help='port number on which to serve app, default=%default',
|
||||
default=18080)
|
||||
parser.add_option('-i', '--interface', dest='interface',
|
||||
help='interface on which to serve app, default=%default',
|
||||
default='0.0.0.0')
|
||||
|
||||
opts = parser.parse_args(sysargs[1:])[0]
|
||||
|
||||
server = make_server(opts.interface, opts.port, ShippingCostApp())
|
||||
print('serving {0.__name__} on '
|
||||
'port {1}'.format(ShippingCostApp, opts.port))
|
||||
server.serve_forever()
|
||||
return 0
|
||||
|
||||
|
||||
class NotFoundError(ValueError):
|
||||
pass
|
||||
|
||||
|
||||
class ShippingCostApp(object):
|
||||
|
||||
def __call__(self, environ, start_response):
|
||||
try:
|
||||
return ShippingCostHandler(environ, start_response).handle()
|
||||
except NotFoundError:
|
||||
return self._handle_404(environ, start_response)
|
||||
|
||||
@classmethod
|
||||
def _handle_404(cls, environ, start_response):
|
||||
ret = 'nothin at {0!r}'.format(environ.get('PATH_INFO', '/'))
|
||||
start_response('404 Not Found', [
|
||||
('content-type', 'text/plain'),
|
||||
('content-length', str(len(ret)))
|
||||
])
|
||||
return [ret]
|
||||
|
||||
|
||||
class ShippingCostHandler(object):
|
||||
_shipping_options = None
|
||||
_zipcode = 0
|
||||
_pounds = 0
|
||||
_handler_method = ''
|
||||
|
||||
def __init__(self, environ, start_response):
|
||||
self.environ = environ
|
||||
self.start_response = start_response
|
||||
self._path_info = self.environ.get('PATH_INFO', '').strip('/')
|
||||
self._handler_method = \
|
||||
'_handle_{0}'.format(self._path_info.replace('.', '_'))
|
||||
|
||||
def _get_params(self):
|
||||
"""some dumb param fetching, ignores multiple values for
|
||||
same var name, e.g. query of "zipcode=12345&zipcode=90210"
|
||||
would effectively discard the 90210 value
|
||||
"""
|
||||
params = cgi.parse_qs(self.environ.get('QUERY_STRING', ''))
|
||||
|
||||
for intvar in ('zipcode', 'pounds'):
|
||||
if params.get(intvar):
|
||||
value = int(float(params.get(intvar)[0]))
|
||||
setattr(self, '_{0}'.format(intvar), value)
|
||||
|
||||
def _get_shipping_options(self):
|
||||
base_cost = (float(self._zipcode) / 10000.0) + (self._pounds * 5.0)
|
||||
self._shipping_options = {
|
||||
"Next Day": int(base_cost * 4),
|
||||
"Two Day Air": int(base_cost * 2),
|
||||
"Saver Ground": int(base_cost)
|
||||
}
|
||||
|
||||
def handle(self):
|
||||
if hasattr(self, self._handler_method):
|
||||
self._get_params()
|
||||
self._get_shipping_options()
|
||||
return getattr(self, self._handler_method)()
|
||||
else:
|
||||
raise NotFoundError
|
||||
|
||||
def _handle_xml(self):
|
||||
response = XMLShippingOptionsResponse(self._shipping_options)
|
||||
return response(self.environ, self.start_response)
|
||||
|
||||
def _handle_text(self):
|
||||
response = PlaintextShippingOptionsResponse(self._shipping_options)
|
||||
return response(self.environ, self.start_response)
|
||||
|
||||
def _handle_crossdomain_xml(self):
|
||||
response = CrossdomainXMLResponse()
|
||||
return response(self.environ, self.start_response)
|
||||
|
||||
|
||||
class PlaintextShippingOptionsResponse(object):
|
||||
_head = ''
|
||||
_record = '{service}: {price} USD'
|
||||
_tail = ''
|
||||
_content_type = 'text/plain'
|
||||
|
||||
def __init__(self, shipping_options):
|
||||
self._shipping_options = shipping_options
|
||||
|
||||
def __call__(self, environ, start_response):
|
||||
body = str(self)
|
||||
start_response('200 OK', [
|
||||
('content-type', self._content_type),
|
||||
('content-length', str(len(body))),
|
||||
])
|
||||
return [body]
|
||||
|
||||
def __str__(self):
|
||||
ret = [self._head]
|
||||
for service, price in self._shipping_options.iteritems():
|
||||
ret.append(self._record.format(service=service, price=price))
|
||||
ret.append(self._tail)
|
||||
return '\n'.join(ret)
|
||||
|
||||
|
||||
class XMLShippingOptionsResponse(PlaintextShippingOptionsResponse):
|
||||
_head = '<options>'
|
||||
_record = ('<option><service>{service}</service>'
|
||||
'<price>{price}</price></option>')
|
||||
_tail = '</options>'
|
||||
_content_type = 'text/xml'
|
||||
|
||||
|
||||
class CrossdomainXMLResponse(PlaintextShippingOptionsResponse):
|
||||
_content_type = 'text/xml'
|
||||
|
||||
def __init__(self):
|
||||
pass
|
||||
|
||||
def __str__(self):
|
||||
return (
|
||||
'<cross-domain-policy>'
|
||||
'<allow-access-from domain="*"/>'
|
||||
'</cross-domain-policy>'
|
||||
)
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
sys.exit(main())
|
||||
|
||||
# vim:filetype=python
|
51
PracticingFlex/03a1-binding-and-modeling/YahooWeather.mxml
Normal file
@ -0,0 +1,51 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml"
|
||||
layout="vertical"
|
||||
backgroundAlpha="0" backgroundColor="#FFFFFF">
|
||||
|
||||
<mx:HTTPService
|
||||
id="weatherService"
|
||||
url="http://weather.yahooapis.com/forecastrss"
|
||||
resultFormat="e4x"
|
||||
result="resultHandler(event);"/>
|
||||
|
||||
<mx:Script>
|
||||
<![CDATA[
|
||||
import mx.rpc.events.ResultEvent;
|
||||
|
||||
private namespace yweather = "http://xml.weather.yahoo.com/ns/rss/1.0";
|
||||
use namespace yweather;
|
||||
|
||||
[Bindable]
|
||||
private var myResult:XML;
|
||||
|
||||
public function requestWeather():void {
|
||||
weatherService.cancel();
|
||||
var params:Object = new Object();
|
||||
params.p = zip.text;
|
||||
weatherService.send(params);
|
||||
}
|
||||
|
||||
public function resultHandler(event:ResultEvent):void {
|
||||
myResult = XML( event.result );
|
||||
}
|
||||
]]>
|
||||
</mx:Script>
|
||||
|
||||
<mx:Form width="400">
|
||||
<mx:FormItem label="Zip Code">
|
||||
<mx:TextInput id="zip" />
|
||||
<mx:Button label="Get Weather" click="requestWeather();"/>
|
||||
</mx:FormItem>
|
||||
<mx:FormItem label="City">
|
||||
<mx:Text text="{myResult.channel.yweather::location.@city}"/>
|
||||
</mx:FormItem>
|
||||
<mx:FormItem label="Temperature">
|
||||
<mx:Text text="{myResult.channel.item.yweather::condition.@temp}"/>
|
||||
</mx:FormItem>
|
||||
<mx:FormItem label="Condition">
|
||||
<mx:Text text="{myResult.channel.item.yweather::condition.@text}" width="100%"/>
|
||||
</mx:FormItem>
|
||||
</mx:Form>
|
||||
<mx:TextArea id="resultFld" text="{myResult}" width="400" height="152"/>
|
||||
</mx:Application>
|
58
PracticingFlex/03a2-crud-dynamic/CRUDDynamic.mxml
Normal file
@ -0,0 +1,58 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml"
|
||||
layout="absolute">
|
||||
<mx:Script>
|
||||
<![CDATA[
|
||||
include "dyn-employees.as";
|
||||
]]>
|
||||
</mx:Script>
|
||||
|
||||
<mx:HTTPService
|
||||
id="employeesService"
|
||||
url="http://examples.adobe.com/flex3/workingwithdata/employees.php"
|
||||
resultFormat="e4x"
|
||||
useProxy="false" />
|
||||
|
||||
<mx:ViewStack id="viewstack1" width="100%" height="100%" >
|
||||
<mx:Canvas label="Form View" width="100%" height="100%">
|
||||
<mx:Form horizontalCenter="0" verticalCenter="0"
|
||||
backgroundColor="#FFFFFF">
|
||||
<mx:FormItem label="Query Employees ">
|
||||
<mx:Button label="Submit" click="fill()" width="100"/>
|
||||
</mx:FormItem>
|
||||
</mx:Form>
|
||||
</mx:Canvas>
|
||||
<mx:Panel label="DataGrid View" width="100%" height="100%">
|
||||
<mx:DataGrid width="100%" height="100%" dataProvider="{listData}">
|
||||
<mx:columns>
|
||||
<mx:DataGridColumn dataField="firstName" headerText="First Name"/>
|
||||
<mx:DataGridColumn dataField="lastName" headerText="Last Name"/>
|
||||
<mx:DataGridColumn dataField="officePhone" headerText="Phone"/>
|
||||
</mx:columns>
|
||||
</mx:DataGrid>
|
||||
<mx:Form backgroundColor="#FFFFFF">
|
||||
<mx:FormItem label="Add New Employee">
|
||||
<mx:Button label="Add..." click="{viewstack1.selectedIndex = 2}"
|
||||
width="100"/>
|
||||
</mx:FormItem>
|
||||
</mx:Form>
|
||||
</mx:Panel>
|
||||
<mx:Canvas label="Add New Employee View" width="100%" height="100%">
|
||||
<mx:Form horizontalCenter="0" verticalCenter="0"
|
||||
backgroundColor="#FFFFFF">
|
||||
<mx:FormItem label="First Name">
|
||||
<mx:TextInput id="inputFirst"/>
|
||||
</mx:FormItem>
|
||||
<mx:FormItem label="Last Name">
|
||||
<mx:TextInput id="inputLast"/>
|
||||
</mx:FormItem>
|
||||
<mx:FormItem label="Phone">
|
||||
<mx:TextInput id="inputPhone"/>
|
||||
</mx:FormItem>
|
||||
<mx:FormItem label="Add Employee ">
|
||||
<mx:Button label="Add" click="insertEmployee()" />
|
||||
</mx:FormItem>
|
||||
</mx:Form>
|
||||
</mx:Canvas>
|
||||
</mx:ViewStack>
|
||||
</mx:Application>
|
43
PracticingFlex/03a2-crud-dynamic/dyn-employees.as
Normal file
@ -0,0 +1,43 @@
|
||||
import mx.rpc.events.ResultEvent;
|
||||
import mx.collections.XMLListCollection;
|
||||
|
||||
private var params:Object = new Object();
|
||||
[Bindable]
|
||||
private var listData:XMLListCollection;
|
||||
|
||||
public function resultHandler(event:ResultEvent):void {
|
||||
var result:XML = XML(event.result);
|
||||
var xmlList:XMLList = result.data.children();
|
||||
listData = new XMLListCollection(xmlList);
|
||||
}
|
||||
|
||||
public function insertItemHandler(event:ResultEvent):void {
|
||||
fill();
|
||||
}
|
||||
|
||||
public function fill():void{
|
||||
employeesService.removeEventListener(ResultEvent.RESULT,insertItemHandler);
|
||||
employeesService.addEventListener(ResultEvent.RESULT,resultHandler);
|
||||
employeesService.method = "GET";
|
||||
params['method'] = "FindAllEmployees";
|
||||
employeesService.cancel();
|
||||
employeesService.send(params);
|
||||
viewstack1.selectedIndex=1;
|
||||
}
|
||||
|
||||
public function insertEmployee():void{
|
||||
employeesService.removeEventListener(ResultEvent.RESULT,resultHandler);
|
||||
employeesService.addEventListener(ResultEvent.RESULT,insertItemHandler);
|
||||
employeesService.method = "POST";
|
||||
params = {"method": "InsertEmployee", "id": NaN, "firstName": inputFirst.text,
|
||||
"lastName": inputLast.text, "officePhone": inputPhone.text};
|
||||
employeesService.cancel();
|
||||
employeesService.send(params);
|
||||
clearInputFields();
|
||||
}
|
||||
|
||||
private function clearInputFields():void{
|
||||
inputFirst.text = "";
|
||||
inputLast.text = "";
|
||||
inputPhone.text = "";
|
||||
}
|
34
PracticingFlex/03a3-crud-static/CRUDStatic.mxml
Normal file
@ -0,0 +1,34 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute" creationComplete="initApp()">
|
||||
<mx:Script>
|
||||
<![CDATA[
|
||||
include "static-employees.as";
|
||||
]]>
|
||||
</mx:Script>
|
||||
|
||||
<mx:HTTPService
|
||||
id="employeesService"
|
||||
url="http://www.flexmonkeys.com/F3GSE/PartIII/CRUD/employees.xml"
|
||||
resultFormat="e4x"
|
||||
result="resultHandler(event)" />
|
||||
|
||||
<mx:ViewStack id="viewstack1" width="100%" height="100%" >
|
||||
<mx:Canvas label="Form View" width="100%" height="100%">
|
||||
<mx:Form horizontalCenter="0" verticalCenter="0" backgroundColor="#FFFFFF">
|
||||
<mx:FormItem label="Query Employees ">
|
||||
<mx:Button label="Submit" click="fill()" width="100"/>
|
||||
</mx:FormItem>
|
||||
</mx:Form>
|
||||
</mx:Canvas>
|
||||
<mx:Panel label="DataGrid View" width="100%" height="100%">
|
||||
<mx:DataGrid width="100%" height="100%" dataProvider="{result.employee}">
|
||||
<mx:columns>
|
||||
<mx:DataGridColumn dataField="firstName" headerText="First Name"/>
|
||||
<mx:DataGridColumn dataField="lastName" headerText="Last Name"/>
|
||||
<mx:DataGridColumn dataField="officePhone" headerText="Phone"/>
|
||||
</mx:columns>
|
||||
</mx:DataGrid>
|
||||
</mx:Panel>
|
||||
</mx:ViewStack>
|
||||
|
||||
</mx:Application>
|
20
PracticingFlex/03a3-crud-static/static-employees.as
Normal file
@ -0,0 +1,20 @@
|
||||
import mx.rpc.events.ResultEvent;
|
||||
|
||||
private var params:Object;
|
||||
|
||||
[Bindable]
|
||||
private var result:XML;
|
||||
|
||||
private function initApp():void{
|
||||
employeesService.cancel();
|
||||
params= new Object();
|
||||
}
|
||||
|
||||
public function resultHandler(event:ResultEvent):void {
|
||||
result = XML( event.result);
|
||||
}
|
||||
|
||||
public function fill():void{
|
||||
viewstack1.selectedIndex=1;
|
||||
employeesService.send(params);
|
||||
}
|
48
PracticingFlex/03a4-external-interface/Main.mxml
Normal file
@ -0,0 +1,48 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml"
|
||||
layout="absolute"
|
||||
creationComplete="initConn()"
|
||||
backgroundAlpha="0" backgroundColor="#FFFFFF">
|
||||
<mx:Script>
|
||||
<![CDATA[
|
||||
import flash.net.LocalConnection;
|
||||
|
||||
private var conn:LocalConnection;
|
||||
|
||||
private function initConn():void{
|
||||
btnSend.addEventListener(MouseEvent.CLICK, sendMessage);
|
||||
conn = new LocalConnection();
|
||||
conn.addEventListener(StatusEvent.STATUS, onStatus);
|
||||
}
|
||||
|
||||
private function sendMessage(event:MouseEvent):void {
|
||||
conn.send("taskConnection", "localconnectionHandler", inputTask.text);
|
||||
}
|
||||
|
||||
private function onStatus(event:StatusEvent):void {
|
||||
switch (event.level) {
|
||||
case "status":
|
||||
ExternalInterface.call("showStatus", "Task successfully sent");
|
||||
break;
|
||||
case "error":
|
||||
ExternalInterface.call("showStatus", "Task failed to send");
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
]]>
|
||||
</mx:Script>
|
||||
<mx:Panel horizontalCenter="0" verticalCenter="0">
|
||||
<mx:Form width="100%" height="100%" horizontalCenter="0" verticalCenter="0">
|
||||
<mx:FormItem label="Enter Task">
|
||||
<mx:TextInput id="inputTask"/>
|
||||
</mx:FormItem>
|
||||
<mx:FormItem label="Send Task ">
|
||||
<mx:Button id="btnSend" label="Send"/>
|
||||
</mx:FormItem>
|
||||
<mx:ControlBar>
|
||||
<mx:Label id="labelStatus" text=""/>
|
||||
</mx:ControlBar>
|
||||
</mx:Form>
|
||||
</mx:Panel>
|
||||
</mx:Application>
|
46
PracticingFlex/03a5-local-connections/BasicTaskReceiver.mxml
Normal file
@ -0,0 +1,46 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml"
|
||||
layout="absolute"
|
||||
creationComplete="InitConn()"
|
||||
backgroundAlpha="0"
|
||||
backgroundColor="#FFFFFF">
|
||||
<mx:Script>
|
||||
<![CDATA[
|
||||
import flash.net.LocalConnection;
|
||||
|
||||
private var conn:LocalConnection;
|
||||
|
||||
private function InitConn():void{
|
||||
conn = new LocalConnection();
|
||||
conn.client = this;
|
||||
try {
|
||||
conn.connect("taskConnection");
|
||||
} catch (error:ArgumentError) {
|
||||
trace("Can't connect.");
|
||||
}
|
||||
}
|
||||
|
||||
public function localconnectionHandler(msg:String):void {
|
||||
textareaTasks.text= textareaTasks.text + msg + "\n";
|
||||
}
|
||||
|
||||
private function clearTasks(event:MouseEvent):void {
|
||||
textareaTasks.text="";
|
||||
}
|
||||
|
||||
]]>
|
||||
</mx:Script>
|
||||
<mx:Panel horizontalCenter="0"
|
||||
verticalCenter="0.5"
|
||||
verticalGap="15"
|
||||
paddingLeft="20" paddingRight="20" paddingBottom="20" paddingTop="20"
|
||||
height="300" width="500">
|
||||
<mx:Label text="Your tasks are..."/>
|
||||
<mx:TextArea id="textareaTasks"
|
||||
top="20" left="20" right="20" bottom="20"
|
||||
width="100%" height="100%"/>
|
||||
<mx:HBox>
|
||||
<mx:Button id="btnClearTasks" click="clearTasks(event)" label="Clear Tasks"/>
|
||||
</mx:HBox>
|
||||
</mx:Panel>
|
||||
</mx:Application>
|
47
PracticingFlex/03a5-local-connections/TaskSender.mxml
Normal file
@ -0,0 +1,47 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml"
|
||||
layout="absolute"
|
||||
creationComplete="initConn()"
|
||||
backgroundAlpha="0" backgroundColor="#FFFFFF">
|
||||
<mx:Script>
|
||||
<![CDATA[
|
||||
import flash.net.LocalConnection;
|
||||
|
||||
private var conn:LocalConnection;
|
||||
|
||||
private function initConn():void{
|
||||
btnSend.addEventListener(MouseEvent.CLICK, sendMessage);
|
||||
conn = new LocalConnection();
|
||||
conn.addEventListener(StatusEvent.STATUS, onStatus);
|
||||
}
|
||||
|
||||
private function sendMessage(event:MouseEvent):void {
|
||||
conn.send("taskConnection", "localconnectionHandler", inputTask.text);
|
||||
}
|
||||
|
||||
private function onStatus(event:StatusEvent):void {
|
||||
switch (event.level) {
|
||||
case "status":
|
||||
labelStatus.text = "LocalConnection.send() succeeded";
|
||||
break;
|
||||
case "error":
|
||||
labelStatus.text = "LocalConnection.send() failed";
|
||||
break;
|
||||
}
|
||||
}
|
||||
]]>
|
||||
</mx:Script>
|
||||
<mx:Panel horizontalCenter="0" verticalCenter="0">
|
||||
<mx:Form width="100%" height="100%" horizontalCenter="0" verticalCenter="0">
|
||||
<mx:FormItem label="Enter Task">
|
||||
<mx:TextInput id="inputTask"/>
|
||||
</mx:FormItem>
|
||||
<mx:FormItem label="Send Task ">
|
||||
<mx:Button id="btnSend" label="Send"/>
|
||||
</mx:FormItem>
|
||||
<mx:ControlBar>
|
||||
<mx:Label id="labelStatus" text=""/>
|
||||
</mx:ControlBar>
|
||||
</mx:Form>
|
||||
</mx:Panel>
|
||||
</mx:Application>
|
52
PracticingFlex/03a6-shared-objects/SharedObjectExample.mxml
Normal file
@ -0,0 +1,52 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml"
|
||||
layout="absolute"
|
||||
creationComplete="initSharedObject()">
|
||||
<mx:Script>
|
||||
<![CDATA[
|
||||
import flash.net.SharedObject;
|
||||
|
||||
public var sharedObj:SharedObject;
|
||||
|
||||
private function initSharedObject():void{
|
||||
sharedObj = SharedObject.getLocal("myTasks");
|
||||
if (sharedObj.size > 0)
|
||||
textareaTasks.text=sharedObj.data.tasks;
|
||||
}
|
||||
|
||||
public function localconnectionHandler(msg:String):void {
|
||||
textareaTasks.text= textareaTasks.text + msg + "\n";
|
||||
}
|
||||
|
||||
private function clearTasks(event:MouseEvent):void {
|
||||
textareaTasks.text="";
|
||||
}
|
||||
|
||||
private function saveTasks(event:MouseEvent):void {
|
||||
sharedObj.data.tasks = textareaTasks.text;
|
||||
sharedObj.flush();
|
||||
}
|
||||
|
||||
private function deleteSavedTasks(event:MouseEvent):void {
|
||||
sharedObj.clear();
|
||||
}
|
||||
|
||||
]]>
|
||||
</mx:Script>
|
||||
<mx:Panel horizontalCenter="0" verticalCenter="0.5" verticalGap="15"
|
||||
paddingLeft="20" paddingRight="20" paddingBottom="20" paddingTop="20"
|
||||
height="300">
|
||||
<mx:Label text="Your tasks are..."/>
|
||||
<mx:TextArea id="textareaTasks"
|
||||
top="20" left="20" right="20" bottom="20"
|
||||
width="100%" height="100%"/>
|
||||
<mx:HBox>
|
||||
<mx:Button id="btnClearTasks" click="clearTasks(event)"
|
||||
label="Clear Tasks"/>
|
||||
<mx:Button id="btnSaveTasks" click="saveTasks(event)"
|
||||
label="Save Tasks to Shared Object"/>
|
||||
<mx:Button id="btnDeleteSavedTasks" click="deleteSavedTasks(event)"
|
||||
label="Delete Saved Shared Object Tasks"/>
|
||||
</mx:HBox>
|
||||
</mx:Panel>
|
||||
</mx:Application>
|
@ -0,0 +1,57 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml"
|
||||
layout="vertical"
|
||||
backgroundAlpha="0" backgroundColor="#FFFFFF">
|
||||
|
||||
<mx:HTTPService
|
||||
id="areacodeService"
|
||||
url="http://www.webservicex.net/uszip.asmx/GetInfoByAreaCode"
|
||||
resultFormat="e4x"
|
||||
/>
|
||||
|
||||
<mx:Script>
|
||||
<![CDATA[
|
||||
public function requestAreacode():void {
|
||||
areacodeService.cancel();
|
||||
var params:Object = new Object();
|
||||
params.USAreaCode = code.text;
|
||||
areacodeService.send(params);
|
||||
}
|
||||
]]>
|
||||
</mx:Script>
|
||||
|
||||
<mx:PhoneNumberValidator source="{phone}" property="text" />
|
||||
<mx:PhoneFormatter id="phoneFormatter" formatString="###.###.####" />
|
||||
|
||||
<mx:Form>
|
||||
<mx:FormItem label="Enter a phone number. Characters allowed: ()-.+ and space">
|
||||
<mx:TextInput id="phone" />
|
||||
<mx:Button label="Lookup Area Code" click="requestAreacode();"/>
|
||||
</mx:FormItem>
|
||||
|
||||
<mx:FormItem label="Stripped phone number">
|
||||
<mx:Text id="stripped_phone" text="{phone.text.replace(/\D/g, '')}" />
|
||||
</mx:FormItem>
|
||||
|
||||
<mx:FormItem label="Formatted phone number">
|
||||
<mx:Text text="{phoneFormatter.format(stripped_phone.text)}" />
|
||||
</mx:FormItem>
|
||||
|
||||
<mx:FormItem label="Area Code">
|
||||
<mx:Text id="code" text="{stripped_phone.text.substr(0,3)}" />
|
||||
</mx:FormItem>
|
||||
</mx:Form>
|
||||
|
||||
<mx:DataGrid dataProvider="{areacodeService.lastResult.Table}">
|
||||
<mx:columns>
|
||||
<mx:DataGridColumn headerText="City" dataField="CITY" />
|
||||
<mx:DataGridColumn headerText="State" dataField="STATE" />
|
||||
<mx:DataGridColumn headerText="Zip" dataField="ZIP" />
|
||||
<mx:DataGridColumn headerText="Area Code" dataField="AREA_CODE" />
|
||||
<mx:DataGridColumn headerText="Time Zone" dataField="TIME_ZONE" />
|
||||
</mx:columns>
|
||||
</mx:DataGrid>
|
||||
|
||||
<mx:TextArea id="resultFld" text="{areacodeService.lastResult}" width="400" height="152"/>
|
||||
|
||||
</mx:Application>
|
22
PracticingFlex/03b-handling-events/TwitterTimeline.mxml
Normal file
@ -0,0 +1,22 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml"
|
||||
width="500" height="500">
|
||||
<mx:HTTPService
|
||||
id="twitterService"
|
||||
url="http://twitter.com/statuses/public_timeline.xml"
|
||||
resultFormat="e4x"
|
||||
result="twitterServiceResultHandler(event);"
|
||||
/>
|
||||
<mx:Script>
|
||||
<![CDATA[
|
||||
import mx.rpc.events.ResultEvent;
|
||||
private function twitterServiceResultHandler(event:ResultEvent):void
|
||||
{
|
||||
resultTxt.text = event.result.toString();
|
||||
}
|
||||
]]>
|
||||
</mx:Script>
|
||||
<mx:Button id="myButton" label="Send HTTP Request"
|
||||
click="twitterService.send()"/>
|
||||
<mx:TextArea id="resultTxt" width="100%" height="100%"/>
|
||||
</mx:Application>
|
62
PracticingFlex/03b1-event-listeners/VBoxDemo.mxml
Normal file
@ -0,0 +1,62 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml"
|
||||
name="DemoApplication"
|
||||
backgroundColor="#FFFFFF"
|
||||
backgroundAlpha="0"
|
||||
creationComplete="initApp()"
|
||||
>
|
||||
|
||||
<mx:Script>
|
||||
<![CDATA[
|
||||
import flash.events.EventPhase
|
||||
import mx.controls.Alert;
|
||||
|
||||
private function initApp():void {
|
||||
myVBox2.addEventListener("click", myHandleClick);
|
||||
myVBox3.addEventListener("click", myHandleClick2);
|
||||
}
|
||||
|
||||
private function myHandleClick(event:Event):void {
|
||||
label1.text = "You clicked VBox 2";
|
||||
}
|
||||
|
||||
private function myHandleClick2(event:Event):void {
|
||||
myVBox2.removeEventListener("click",myHandleClick);
|
||||
label1.text = "";
|
||||
}
|
||||
|
||||
]]>
|
||||
</mx:Script>
|
||||
<mx:Label text="Application"/>
|
||||
|
||||
<mx:VBox id="myVBox1"
|
||||
backgroundColor="#FFCCFF"
|
||||
width="300" height="100"
|
||||
horizontalAlign="center">
|
||||
|
||||
<mx:Label text="VBox 1" />
|
||||
|
||||
</mx:VBox>
|
||||
|
||||
<mx:VBox id="myVBox2"
|
||||
backgroundColor="#FFCCCC"
|
||||
width="300" height="100"
|
||||
horizontalAlign="center">
|
||||
|
||||
<mx:Label text="VBox 2" />
|
||||
|
||||
</mx:VBox>
|
||||
|
||||
<mx:VBox id="myVBox3"
|
||||
backgroundColor="#FFFFCC"
|
||||
width="300" height="100"
|
||||
horizontalAlign="center">
|
||||
|
||||
<mx:Label text="VBox 3" />
|
||||
|
||||
</mx:VBox>
|
||||
<mx:Label id="label1"
|
||||
width="80%" height="48"
|
||||
fontWeight="bold" />
|
||||
|
||||
</mx:Application>
|
57
PracticingFlex/03b2-event-propagation/DemoApplication.mxml
Normal file
@ -0,0 +1,57 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml"
|
||||
name="DemoApplication"
|
||||
backgroundColor="#FFFFFF"
|
||||
backgroundAlpha="0"
|
||||
creationComplete="initApp()"
|
||||
click="myHandleClick(event)"
|
||||
>
|
||||
|
||||
<mx:Script>
|
||||
<![CDATA[
|
||||
import flash.events.EventPhase
|
||||
import mx.controls.Alert;
|
||||
|
||||
private function initApp():void {
|
||||
myVBox.addEventListener("click", myHandleClick);
|
||||
}
|
||||
|
||||
private function myHandleClick(event:Event):void {
|
||||
label1.text = "You clicked on " + event.target +
|
||||
"\n" + "Current event phase is " +
|
||||
getPhaseName(event.eventPhase) + "\n" +
|
||||
"Current target is " + event.currentTarget
|
||||
}
|
||||
|
||||
private function getPhaseName(phase:uint):String {
|
||||
switch(phase) {
|
||||
case 1:
|
||||
return "CAPTURING PHASE";
|
||||
case 2:
|
||||
return "AT TARGET PHASE";
|
||||
case 3:
|
||||
return "BUBBLING PHASE";
|
||||
}
|
||||
return "";
|
||||
}
|
||||
]]>
|
||||
</mx:Script>
|
||||
<mx:Label text="Application"/>
|
||||
|
||||
<mx:VBox id="myVBox"
|
||||
backgroundColor="#FFCCCC"
|
||||
width="300" height="100"
|
||||
horizontalAlign="center">
|
||||
|
||||
<mx:Label text="VBox"/>
|
||||
|
||||
<mx:Button id="myButton"
|
||||
label="Create Click Event"
|
||||
click="myHandleClick(event)" />
|
||||
|
||||
</mx:VBox>
|
||||
<mx:Label id="label1"
|
||||
width="80%" height="48"
|
||||
fontWeight="bold" />
|
||||
|
||||
</mx:Application>
|
13
PracticingFlex/03b3-simple-ui-event/Example1.mxml
Normal file
@ -0,0 +1,13 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml">
|
||||
<mx:Script>
|
||||
<![CDATA[
|
||||
import mx.controls.Alert;
|
||||
private function myHandleClick(event:Event):void
|
||||
{
|
||||
Alert.show("Clicked!");
|
||||
}
|
||||
]]>
|
||||
</mx:Script>
|
||||
<mx:Button id="myButton" label="Create Click Event" click="myHandleClick(event)" />
|
||||
</mx:Application>
|
29
PracticingFlex/03b3-simple-ui-event/Example2.mxml
Normal file
@ -0,0 +1,29 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml"
|
||||
backgroundColor="#FFFFFF"
|
||||
backgroundAlpha="0">
|
||||
|
||||
<mx:HTTPService
|
||||
id="twitterService"
|
||||
url="http://twitter.com/statuses/public_timeline.xml"
|
||||
resultFormat="e4x"
|
||||
result="twitterServiceResultHandler(event)" />
|
||||
|
||||
<mx:Script>
|
||||
<![CDATA[
|
||||
import mx.rpc.events.ResultEvent;
|
||||
|
||||
private function twitterServiceResultHandler(event:ResultEvent):void {
|
||||
resultTxt.text = event.result.toString();
|
||||
}
|
||||
]]>
|
||||
</mx:Script>
|
||||
|
||||
<mx:Button id="myButton"
|
||||
label="Send HTTP Request"
|
||||
click="twitterService.send()" />
|
||||
<mx:TextArea id="resultTxt"
|
||||
fontSize="12"
|
||||
width="100%" height="100%" />
|
||||
|
||||
</mx:Application>
|
12
PracticingFlex/03c1-application-container/Demo.mxml
Normal file
@ -0,0 +1,12 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml"
|
||||
backgroundGradientColors="[#FFFFFF, #FFDE00]"
|
||||
verticalGap="15"
|
||||
layout="horizontal">
|
||||
|
||||
<mx:Image source="assets/animals03.jpg" />
|
||||
|
||||
<mx:Label text="Photographed by Elsie Weil"
|
||||
fontSize="15" fontWeight="bold" />
|
||||
|
||||
</mx:Application>
|
1
PracticingFlex/03c1-application-container/assets
Symbolic link
@ -0,0 +1 @@
|
||||
../_assets
|
22
PracticingFlex/03c2-box-model/HBoxExample.mxml
Normal file
@ -0,0 +1,22 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml"
|
||||
backgroundColor="#FFFFFF"
|
||||
backgroundAlpha="0">
|
||||
|
||||
<mx:HBox>
|
||||
|
||||
<mx:Button label="< prev"
|
||||
left="10" top="120" />
|
||||
|
||||
<mx:Image source="assets/animals03.jpg"
|
||||
horizontalCenter="0" top="30"/>
|
||||
|
||||
<mx:Label text="Photographed by Elsie Weil"
|
||||
horizontalCenter="0" top="250"/>
|
||||
|
||||
<mx:Button label="next >"
|
||||
right="10" top="120"/>
|
||||
|
||||
</mx:HBox>
|
||||
|
||||
</mx:Application>
|
22
PracticingFlex/03c2-box-model/VBoxExample.mxml
Normal file
@ -0,0 +1,22 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml"
|
||||
backgroundColor="#FFFFFF"
|
||||
backgroundAlpha="0">
|
||||
|
||||
<mx:VBox>
|
||||
|
||||
<mx:Button label="< prev"
|
||||
left="10" top="120" />
|
||||
|
||||
<mx:Image source="assets/animals03.jpg"
|
||||
horizontalCenter="0" top="30"/>
|
||||
|
||||
<mx:Label text="Photographed by Elsie Weil"
|
||||
horizontalCenter="0" top="250"/>
|
||||
|
||||
<mx:Button label="next >"
|
||||
right="10" top="120"/>
|
||||
|
||||
</mx:VBox>
|
||||
|
||||
</mx:Application>
|
28
PracticingFlex/03c2-box-model/VBoxHBoxCombo.mxml
Normal file
@ -0,0 +1,28 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml"
|
||||
backgroundColor="#FFFFFF"
|
||||
backgroundAlpha="0">
|
||||
|
||||
<mx:VBox horizontalAlign="center"
|
||||
verticalGap="15">
|
||||
|
||||
<mx:HBox verticalAlign="middle"
|
||||
horizontalGap="15">
|
||||
|
||||
<mx:Button label="< prev"
|
||||
left="10" top="120" />
|
||||
|
||||
<mx:Image source="assets/animals03.jpg"
|
||||
horizontalCenter="0" top="30"/>
|
||||
|
||||
<mx:Button label="next >"
|
||||
right="10" top="120"/>
|
||||
|
||||
</mx:HBox>
|
||||
|
||||
<mx:Label text="Photographed by Elsie Weil"
|
||||
horizontalCenter="0" top="250"/>
|
||||
|
||||
</mx:VBox>
|
||||
|
||||
</mx:Application>
|
1
PracticingFlex/03c2-box-model/assets
Symbolic link
@ -0,0 +1 @@
|
||||
../_assets
|
23
PracticingFlex/03c3-canvas-absolute/Example.mxml
Normal file
@ -0,0 +1,23 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml"
|
||||
layout="absolute"
|
||||
backgroundColor="#FFFFFF"
|
||||
backgroundAlpha="0">
|
||||
|
||||
<mx:Canvas x="23" y="34">
|
||||
|
||||
<mx:Button label="< prev"
|
||||
x="4" y="97" />
|
||||
|
||||
<mx:Image source="assets/animals03.jpg"
|
||||
x="85" y="4" />
|
||||
|
||||
<mx:Label text="Photographed by Elsie Weil"
|
||||
x="85" y="230" />
|
||||
|
||||
<mx:Button label="next >"
|
||||
x="381" y="97" />
|
||||
|
||||
</mx:Canvas>
|
||||
|
||||
</mx:Application>
|
1
PracticingFlex/03c3-canvas-absolute/assets
Symbolic link
@ -0,0 +1 @@
|
||||
../_assets
|
28
PracticingFlex/03c4-canvas-relative/Photo.mxml
Normal file
@ -0,0 +1,28 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml"
|
||||
layout="absolute"
|
||||
backgroundColor="#FFFFFF"
|
||||
backgroundAlpha="0">
|
||||
|
||||
|
||||
<mx:HDividedBox width="100%" height="300">
|
||||
<mx:Canvas backgroundColor="#FFFFCC"
|
||||
width="150" height="100%">
|
||||
<mx:Label text="Adjust this section" left="15" />
|
||||
</mx:Canvas>
|
||||
|
||||
<mx:Canvas>
|
||||
<mx:Button label="< prev"
|
||||
left="10" top="120"/>
|
||||
|
||||
<mx:Image source="assets/animals03.jpg"
|
||||
horizontalCenter="0" top="30"/>
|
||||
|
||||
<mx:Label text="Photographed by Elsie Weil"
|
||||
horizontalCenter="0" top="250"/>
|
||||
|
||||
<mx:Button label="next >"
|
||||
right="10" top="120"/>
|
||||
</mx:Canvas>
|
||||
</mx:HDividedBox>
|
||||
</mx:Application>
|
1
PracticingFlex/03c4-canvas-relative/assets
Symbolic link
@ -0,0 +1 @@
|
||||
../_assets
|
94
PracticingFlex/03c5-combined-layout/Combined.mxml
Normal file
@ -0,0 +1,94 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml"
|
||||
backgroundColor="#000000"
|
||||
layout="horizontal"
|
||||
horizontalGap="25">
|
||||
|
||||
<mx:Style>
|
||||
Panel {
|
||||
backgroundAlpha: 1;
|
||||
borderAlpha: 1;
|
||||
headerColors: #c7c7c7, #ffffff;
|
||||
footerColors: #ffffff, #c7c7c7;
|
||||
paddingTop: 15;
|
||||
paddingRight: 15;
|
||||
paddingLeft: 15;
|
||||
paddingBottom: 15;
|
||||
shadowDirection: "right";
|
||||
}
|
||||
.header {
|
||||
color: #ffffff;
|
||||
fontSize: 15;
|
||||
fontWeight: "bold";
|
||||
}
|
||||
</mx:Style>
|
||||
|
||||
<mx:VBox verticalGap="10">
|
||||
|
||||
<mx:Panel title="Featured Photograph">
|
||||
|
||||
<mx:Image source="assets/animals03.jpg"
|
||||
horizontalCenter="0" top="30" />
|
||||
|
||||
<mx:Label text="Photographed by Elsie Weil"
|
||||
horizontalCenter="0" top="250" />
|
||||
|
||||
</mx:Panel>
|
||||
|
||||
<mx:Panel title="Provide feedback">
|
||||
|
||||
<mx:Form x="50" y="50"
|
||||
verticalGap="15">
|
||||
|
||||
<mx:FormHeading label="Send us comments" />
|
||||
|
||||
<mx:FormItem label="Full Name:">
|
||||
<mx:TextInput id="fullName" />
|
||||
</mx:FormItem>
|
||||
|
||||
<mx:FormItem label="Email:">
|
||||
<mx:TextInput id="email" />
|
||||
</mx:FormItem>
|
||||
|
||||
<mx:FormItem label="Comments:">
|
||||
<mx:TextArea id="comments" />
|
||||
</mx:FormItem>
|
||||
|
||||
<mx:FormItem>
|
||||
<mx:Button id="submit"
|
||||
label="submit" />
|
||||
</mx:FormItem>
|
||||
|
||||
</mx:Form>
|
||||
|
||||
</mx:Panel>
|
||||
|
||||
</mx:VBox>
|
||||
|
||||
<mx:VBox verticalGap="25">
|
||||
|
||||
<mx:Canvas>
|
||||
<mx:Label text="Category: Animals"
|
||||
styleName="header" />
|
||||
<mx:Image source="assets/animals03_sm.jpg" y="30" />
|
||||
<mx:Image source="assets/animals08_sm.jpg" y="120" />
|
||||
<mx:Image source="assets/animals09_sm.jpg" y="120" x="120" />
|
||||
<mx:Image source="assets/animals10_sm.jpg" y="120" x="240" />
|
||||
<mx:Image source="assets/animals11_sm.jpg" y="211" />
|
||||
<mx:Image source="assets/animals12_sm.jpg" y="211" x="120" />
|
||||
<mx:Image source="assets/animals06_sm.jpg" y="30" x="120" />
|
||||
<mx:Image source="assets/animals07_sm.jpg" y="30" x="240" />
|
||||
</mx:Canvas>
|
||||
|
||||
<mx:Canvas>
|
||||
<mx:Label text="Category: Cities"
|
||||
styleName="header" />
|
||||
<mx:Image source="assets/city01_sm.jpg" y="30" />
|
||||
<mx:Image source="assets/city02_sm.jpg" y="30" x="120"/>
|
||||
<mx:Image source="assets/city03_sm.jpg" y="30" x="240" />
|
||||
<mx:Image source="assets/city04_sm.jpg" y="120" x="0" />
|
||||
</mx:Canvas>
|
||||
|
||||
</mx:VBox>
|
||||
|
||||
</mx:Application>
|
1
PracticingFlex/03c5-combined-layout/assets
Symbolic link
@ -0,0 +1 @@
|
||||
../_assets
|
31
PracticingFlex/03c6-form/CommentForm.mxml
Normal file
@ -0,0 +1,31 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml"
|
||||
layout="absolute"
|
||||
backgroundColor="#FFFFFF"
|
||||
backgroundAlpha="0">
|
||||
|
||||
<mx:Form x="50" y="50"
|
||||
verticalGap="15">
|
||||
|
||||
<mx:FormHeading label="Send us comments" />
|
||||
|
||||
<mx:FormItem label="Full Name:">
|
||||
<mx:TextInput id="fullName" />
|
||||
</mx:FormItem>
|
||||
|
||||
<mx:FormItem label="Email:">
|
||||
<mx:TextInput id="email" />
|
||||
</mx:FormItem>
|
||||
|
||||
<mx:FormItem label="Comments:">
|
||||
<mx:TextArea id="comments" />
|
||||
</mx:FormItem>
|
||||
|
||||
<mx:FormItem>
|
||||
<mx:Button id="submit"
|
||||
label="submit" />
|
||||
</mx:FormItem>
|
||||
|
||||
</mx:Form>
|
||||
|
||||
</mx:Application>
|
33
PracticingFlex/03c7-mxml-vs-as3/WithAs3.mxml
Normal file
@ -0,0 +1,33 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml"
|
||||
backgroundColor="#FFFFFF"
|
||||
backgroundAlpha="0"
|
||||
initialize="addControls()">
|
||||
|
||||
<mx:Script>
|
||||
<![CDATA[
|
||||
import mx.controls.Image;
|
||||
import mx.controls.Label;
|
||||
|
||||
private function addControls():void {
|
||||
createImage();
|
||||
createPhotographer();
|
||||
}
|
||||
|
||||
private function createImage():void {
|
||||
var photo:Image = new Image();
|
||||
photo.source = "assets/animals03.jpg";
|
||||
boxetyBox.addChild(photo);
|
||||
}
|
||||
|
||||
private function createPhotographer():void {
|
||||
var photographer:Label = new Label();
|
||||
photographer.text = "Photographed by Elsie Weil";
|
||||
boxetyBox.addChild(photographer);
|
||||
}
|
||||
|
||||
]]>
|
||||
</mx:Script>
|
||||
<mx:Box id="boxetyBox"/>
|
||||
|
||||
</mx:Application>
|
10
PracticingFlex/03c7-mxml-vs-as3/WithMxml.mxml
Normal file
@ -0,0 +1,10 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml"
|
||||
backgroundColor="#FFFFFF"
|
||||
backgroundAlpha="0">
|
||||
|
||||
<mx:Image source="assets/animals03.jpg" />
|
||||
|
||||
<mx:Label text="Photographed by Elsie Weil" />
|
||||
|
||||
</mx:Application>
|
1
PracticingFlex/03c7-mxml-vs-as3/assets
Symbolic link
@ -0,0 +1 @@
|
||||
../_assets
|
21
PracticingFlex/03c8-panel/Photo.mxml
Normal file
@ -0,0 +1,21 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml"
|
||||
backgroundGradientColors="[#FFFFFF, #000000]">
|
||||
|
||||
<mx:Panel title="Featured Photograph"
|
||||
backgroundAlpha=".25"
|
||||
borderAlpha="1"
|
||||
headerColors="[#c7c7c7, #ffffff]"
|
||||
footerColors="[#ffffff, #c7c7c7]"
|
||||
paddingTop="15" paddingRight="15" paddingLeft="15" paddingBottom="15"
|
||||
shadowDirection="right">
|
||||
|
||||
<mx:Image source="assets/animals03.jpg"
|
||||
horizontalCenter="0" top="30" />
|
||||
|
||||
<mx:Label text="Photographed by Elsie Weil"
|
||||
horizontalCenter="0" top="250" />
|
||||
|
||||
</mx:Panel>
|
||||
|
||||
</mx:Application>
|
1
PracticingFlex/03c8-panel/assets
Symbolic link
@ -0,0 +1 @@
|
||||
../_assets
|
61
PracticingFlex/03d1-datagrid/DataGridApp.as
Normal file
@ -0,0 +1,61 @@
|
||||
package
|
||||
{
|
||||
import mx.core.Application;
|
||||
|
||||
import mx.collections.ArrayCollection;
|
||||
import mx.containers.Panel;
|
||||
import mx.controls.Alert;
|
||||
import mx.controls.DataGrid;
|
||||
import mx.controls.Image;
|
||||
import mx.controls.Label;
|
||||
import mx.controls.TextInput;
|
||||
import mx.rpc.events.FaultEvent;
|
||||
import mx.rpc.events.ResultEvent;
|
||||
import mx.rpc.http.HTTPService;
|
||||
|
||||
import RequestParams;
|
||||
|
||||
public class DataGridApp extends Application
|
||||
{
|
||||
[Bindable]
|
||||
public var dataGrid:DataGrid;
|
||||
public var photoFeed:ArrayCollection;
|
||||
public var photoService:HTTPService;
|
||||
public var searchTerms:TextInput;
|
||||
public var vboxImage:Image;
|
||||
public var vboxDesc:Label;
|
||||
public var popup:Panel;
|
||||
|
||||
function DataGridApp()
|
||||
{
|
||||
}
|
||||
|
||||
public function requestPhotos():void {
|
||||
var params:RequestParams = new RequestParams();
|
||||
params.format = 'rss_200_enc';
|
||||
params.tags = searchTerms.text;
|
||||
photoService.send(params);
|
||||
}
|
||||
|
||||
public function photoHandler(event:ResultEvent):void {
|
||||
photoFeed= event.result.rss.channel.item as ArrayCollection;
|
||||
dataGrid.dataProvider = photoFeed;
|
||||
dataGrid.visible = true;
|
||||
}
|
||||
|
||||
public function faultHandler(event:FaultEvent):void{
|
||||
Alert.show(event.fault.faultCode + " , " + event.fault.faultString);
|
||||
}
|
||||
|
||||
public function showPopup(event:Event):void{
|
||||
vboxImage.source = photoFeed.getItemAt(event.currentTarget.selectedIndex).content.url
|
||||
vboxDesc.text = photoFeed.getItemAt(event.currentTarget.selectedIndex).title.getItemAt(0)
|
||||
popup.visible = true;
|
||||
}
|
||||
|
||||
public function hidePopup():void{
|
||||
popup.visible = false;
|
||||
popup.includeInLayout = false;
|
||||
}
|
||||
}
|
||||
}
|
62
PracticingFlex/03d1-datagrid/DataGridExample.mxml
Normal file
@ -0,0 +1,62 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<loc:DataGridApp xmlns:mx="http://www.adobe.com/2006/mxml"
|
||||
xmlns:loc="*"
|
||||
backgroundColor="#FFFFFF"
|
||||
backgroundAlpha="0"
|
||||
horizontalAlign="left"
|
||||
verticalGap="15"
|
||||
horizontalGap="15">
|
||||
|
||||
<mx:HTTPService id="photoService"
|
||||
url="http://api.flickr.com/services/feeds/photos_public.gne"
|
||||
result="photoHandler(event)"
|
||||
fault="faultHandler(event)" />
|
||||
|
||||
<mx:HBox>
|
||||
<mx:Label text="Enter Search Terms"/>
|
||||
<mx:TextInput id="searchTerms" enter="requestPhotos()" />
|
||||
<mx:Button label="Search"
|
||||
click="requestPhotos()" />
|
||||
</mx:HBox>
|
||||
|
||||
<mx:HBox>
|
||||
<mx:DataGrid id="dataGrid"
|
||||
visible="false"
|
||||
itemClick="showPopup(event)">
|
||||
<mx:columns>
|
||||
<mx:DataGridColumn dataField="title" headerText="Title"
|
||||
width="100" >
|
||||
<mx:itemRenderer>
|
||||
<mx:Component>
|
||||
<mx:Label text="{data.title.getItemAt(0)}"
|
||||
textAlign="center"/>
|
||||
</mx:Component>
|
||||
</mx:itemRenderer>
|
||||
</mx:DataGridColumn>
|
||||
<mx:DataGridColumn dataField="credit" headerText="Author"
|
||||
width="100" />
|
||||
<mx:DataGridColumn dataField="thumbnail" headerText="Photo"
|
||||
width="100">
|
||||
<mx:itemRenderer>
|
||||
<mx:Component>
|
||||
<mx:Image height="75"
|
||||
horizontalAlign="center"
|
||||
source="{data.thumbnail.url}"/>
|
||||
</mx:Component>
|
||||
</mx:itemRenderer>
|
||||
</mx:DataGridColumn>
|
||||
</mx:columns>
|
||||
</mx:DataGrid>
|
||||
|
||||
<mx:Panel id="popup"
|
||||
visible="false"
|
||||
click="hidePopup()"
|
||||
paddingLeft="10" paddingTop="10" paddingRight="10"
|
||||
layout="horizontal">
|
||||
<mx:VBox width="325" height="400">
|
||||
<mx:Label id="vboxDesc"/>
|
||||
<mx:Image id="vboxImage"/>
|
||||
</mx:VBox>
|
||||
</mx:Panel>
|
||||
</mx:HBox>
|
||||
</loc:DataGridApp>
|
8
PracticingFlex/03d1-datagrid/RequestParams.as
Normal file
@ -0,0 +1,8 @@
|
||||
package
|
||||
{
|
||||
public class RequestParams
|
||||
{
|
||||
public var format:String;
|
||||
public var tags:String;
|
||||
}
|
||||
}
|
31
PracticingFlex/03d2-item-renderers/HBoxWeatherDisplay.mxml
Normal file
@ -0,0 +1,31 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<mx:HBox xmlns:mx="http://www.adobe.com/2006/mxml" width="400" height="100"
|
||||
xmlns:me="components.*" >
|
||||
<mx:Script>
|
||||
<![CDATA[
|
||||
private var _data:Object;
|
||||
|
||||
override public function set data(value:Object):void {
|
||||
_data = value;
|
||||
if (data != null) {
|
||||
zip.text = _data.zip;
|
||||
city.text = _data.city;
|
||||
temp.text = _data.temp + 'F';
|
||||
img.source = _data.imgsource;
|
||||
}
|
||||
}
|
||||
|
||||
override public function get data():Object {
|
||||
return _data;
|
||||
}
|
||||
|
||||
]]>
|
||||
</mx:Script>
|
||||
|
||||
<mx:Image id="img" />
|
||||
<mx:VBox height="100%">
|
||||
<mx:Text id="zip" />
|
||||
<mx:Text id="city" />
|
||||
<mx:Text id="temp" />
|
||||
</mx:VBox>
|
||||
</mx:HBox>
|
88
PracticingFlex/03d2-item-renderers/WeatherDisplay.mxml
Normal file
@ -0,0 +1,88 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml"
|
||||
backgroundColor="#FFFFFF"
|
||||
backgroundAlpha="0"
|
||||
horizontalAlign="left"
|
||||
verticalGap="15" horizontalGap="15">
|
||||
<mx:Script>
|
||||
<![CDATA[
|
||||
import mx.collections.ArrayCollection;
|
||||
import mx.rpc.events.ResultEvent;
|
||||
|
||||
[Bindable]
|
||||
private var myResult:XML;
|
||||
|
||||
[Bindable]
|
||||
private var weatherObject:Object;
|
||||
|
||||
[Bindable]
|
||||
private var listContents:ArrayCollection;
|
||||
|
||||
private namespace yweather = "http://xml.weather.yahoo.com/ns/rss/1.0";
|
||||
use namespace yweather;
|
||||
|
||||
public function requestWeather():void {
|
||||
weatherService.cancel();
|
||||
var params:Object = new Object();
|
||||
params.p = zip.text;
|
||||
weatherService.send(params);
|
||||
}
|
||||
|
||||
public function resultHandler(event:ResultEvent):void {
|
||||
myResult = XML(event.result);
|
||||
weatherObject = new Object();
|
||||
weatherObject.zip = zip.text;
|
||||
weatherObject.city = myResult.channel.yweather::location.@city;
|
||||
weatherObject.temp = myResult.channel.item.yweather::condition.@temp;
|
||||
weatherObject.imgsource = parseImageUrl(myResult.channel.item.description);
|
||||
|
||||
var a:Array = new Array(weatherObject);
|
||||
listContents = new ArrayCollection(a);
|
||||
}
|
||||
|
||||
private function parseImageUrl(fromHtml:XMLList):String {
|
||||
var pattern:RegExp = /img src="(.+?)"/;
|
||||
var results:Array = pattern.exec(fromHtml);
|
||||
var imageURL:String = results[1]; // backreference 1 from pattern
|
||||
return imageURL;
|
||||
}
|
||||
]]>
|
||||
</mx:Script>
|
||||
|
||||
<mx:HTTPService
|
||||
id="weatherService"
|
||||
url="http://weather.yahooapis.com/forecastrss"
|
||||
resultFormat="e4x"
|
||||
result="resultHandler(event)" />
|
||||
|
||||
<mx:Text text="1. Basic Form + HTTPService Retrieval" />
|
||||
|
||||
<mx:Form width="400">
|
||||
<mx:FormItem label="Zip Code">
|
||||
<mx:TextInput id="zip" />
|
||||
<mx:Button label="Get Weather"
|
||||
click="requestWeather()" />
|
||||
</mx:FormItem>
|
||||
</mx:Form>
|
||||
|
||||
<mx:Text text="Raw RSS Feed" />
|
||||
|
||||
<mx:TextArea id="resultFld"
|
||||
text="{myResult}"
|
||||
width="400" height="152" />
|
||||
|
||||
<mx:Text text="1. List w/ Image Item Renderer (Drop-In)" />
|
||||
|
||||
<mx:List dataProvider="{listContents}"
|
||||
labelField="imgsource"
|
||||
width="400" height="100"
|
||||
itemRenderer="mx.controls.Image" />
|
||||
|
||||
<mx:Text text="2. List w/ HBoxWeatherDisplay itemRenderer" />
|
||||
|
||||
<mx:List dataProvider="{listContents}"
|
||||
labelField="zip"
|
||||
width="400" height="100"
|
||||
itemRenderer="HBoxWeatherDisplay" />
|
||||
|
||||
</mx:Application>
|
55
PracticingFlex/03d3-lists/HorizontalListControl.mxml
Normal file
@ -0,0 +1,55 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml"
|
||||
backgroundColor="#FFFFFF"
|
||||
backgroundAlpha="0"
|
||||
horizontalAlign="left"
|
||||
verticalGap="15" horizontalGap="15">
|
||||
|
||||
<mx:Script>
|
||||
<![CDATA[
|
||||
import mx.collections.ArrayCollection;
|
||||
import mx.rpc.events.ResultEvent;
|
||||
import mx.events.ListEvent;
|
||||
|
||||
[Bindable]
|
||||
private var employeeList:ArrayCollection = new ArrayCollection();
|
||||
|
||||
private function requestEmployees():void {
|
||||
employeesService.send();
|
||||
}
|
||||
|
||||
private function resultHandler(event:ResultEvent):void {
|
||||
employeeList = event.result.employees.employee as ArrayCollection;
|
||||
|
||||
}
|
||||
|
||||
//show text message when user selects image
|
||||
private function showMessage(event:Event):void {
|
||||
message.text = "You selected: " +
|
||||
event.currentTarget.selectedItem.firstName + ' ' +
|
||||
event.currentTarget.selectedItem.lastName;
|
||||
}
|
||||
]]>
|
||||
</mx:Script>
|
||||
|
||||
|
||||
<mx:HTTPService
|
||||
id="employeesService"
|
||||
url="http://www.flexmonkeys.com/F3GSE/PartIII/CRUD/employees.xml"
|
||||
result="resultHandler(event)"
|
||||
/>
|
||||
|
||||
<mx:Button label="Return Employees"
|
||||
click="requestEmployees()" />
|
||||
|
||||
<mx:HorizontalList id="mylist"
|
||||
labelField="firstName"
|
||||
dataProvider="{employeeList}"
|
||||
columnWidth="100" rowHeight="50"
|
||||
columnCount="5"
|
||||
itemClick="showMessage(event)"/>
|
||||
|
||||
<mx:Text id="message"
|
||||
paddingTop="20" />
|
||||
|
||||
</mx:Application>
|
52
PracticingFlex/03d3-lists/ListControl.mxml
Normal file
@ -0,0 +1,52 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml"
|
||||
backgroundColor="#FFFFFF"
|
||||
backgroundAlpha="0"
|
||||
horizontalAlign="left"
|
||||
verticalGap="15" horizontalGap="15">
|
||||
|
||||
<mx:Script>
|
||||
<![CDATA[
|
||||
import mx.collections.ArrayCollection;
|
||||
import mx.rpc.events.ResultEvent;
|
||||
import mx.events.ListEvent;
|
||||
|
||||
[Bindable]
|
||||
private var employeeList:ArrayCollection = new ArrayCollection();
|
||||
|
||||
private function requestEmployees():void {
|
||||
employeesService.send();
|
||||
}
|
||||
|
||||
private function resultHandler(event:ResultEvent):void {
|
||||
employeeList = event.result.employees.employee as ArrayCollection;
|
||||
}
|
||||
|
||||
private function showMessage(event:Event):void {
|
||||
message.text = "You selected: " +
|
||||
event.currentTarget.selectedItem.firstName + ' ' +
|
||||
event.currentTarget.selectedItem.lastName;
|
||||
}
|
||||
]]>
|
||||
</mx:Script>
|
||||
|
||||
|
||||
<mx:HTTPService
|
||||
id="employeesService"
|
||||
url="http://www.flexmonkeys.com/F3GSE/PartIII/CRUD/employees.xml"
|
||||
result="resultHandler(event)"
|
||||
/>
|
||||
|
||||
<mx:Button label="Return Employees"
|
||||
click="requestEmployees()" />
|
||||
|
||||
<mx:List id="mylist"
|
||||
labelField="firstName"
|
||||
dataProvider="{employeeList}"
|
||||
width="200" height="200"
|
||||
itemClick="showMessage(event)"/>
|
||||
|
||||
<mx:Text id="message"
|
||||
paddingTop="20" />
|
||||
|
||||
</mx:Application>
|
75
PracticingFlex/03d4-tilelist/TileListExample.mxml
Normal file
@ -0,0 +1,75 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml"
|
||||
backgroundColor="#FFFFFF"
|
||||
backgroundAlpha="0"
|
||||
horizontalAlign="left"
|
||||
verticalGap="15" horizontalGap="15">
|
||||
|
||||
<mx:Script>
|
||||
<![CDATA[
|
||||
import mx.collections.ArrayCollection;
|
||||
import mx.rpc.events.ResultEvent;
|
||||
import mx.events.ListEvent;
|
||||
|
||||
[Bindable]
|
||||
private var photoFeed:ArrayCollection = new ArrayCollection();
|
||||
|
||||
private function requestPhotos():void {
|
||||
var params:Object = new Object();
|
||||
params.format = 'rss_200_enc';
|
||||
params.tags = searchTerms.text;
|
||||
photoService.send(params);
|
||||
}
|
||||
|
||||
private function photoHandler(event:ResultEvent):void {
|
||||
photoFeed = event.result.rss.channel.item as ArrayCollection;
|
||||
}
|
||||
|
||||
//show text message when user selects image
|
||||
private function showMessage(event:Event):void {
|
||||
message.text = "You selected: " +
|
||||
event.currentTarget.selectedItem.title + "\nUploaded by: " +
|
||||
event.currentTarget.selectedItem.credit;
|
||||
}
|
||||
]]>
|
||||
</mx:Script>
|
||||
|
||||
<!-- photo service -->
|
||||
<mx:HTTPService id="photoService"
|
||||
url="http://api.flickr.com/services/feeds/photos_public.gne"
|
||||
result="photoHandler(event)" />
|
||||
|
||||
<!-- search -->
|
||||
<mx:Form>
|
||||
<mx:FormItem label="Search Term"
|
||||
direction="horizontal">
|
||||
<mx:TextInput id="searchTerms" />
|
||||
<mx:Button label="Search"
|
||||
click="requestPhotos()" />
|
||||
</mx:FormItem>
|
||||
</mx:Form>
|
||||
|
||||
<!-- result, data is passed to the itemRenderer by Flex through the data property -->
|
||||
<mx:TileList id="mylist"
|
||||
labelField="thumbnail"
|
||||
dataProvider="{photoFeed}"
|
||||
width="600" height="200"
|
||||
paddingTop="25" left="5"
|
||||
itemClick="showMessage(event)">
|
||||
<mx:itemRenderer>
|
||||
<mx:Component>
|
||||
<mx:VBox width="125" height="125"
|
||||
paddingRight="5" paddingLeft="5"
|
||||
horizontalAlign="center">
|
||||
<mx:Image
|
||||
height="75" width="75"
|
||||
source="{data.thumbnail.url}"/>
|
||||
</mx:VBox>
|
||||
</mx:Component>
|
||||
</mx:itemRenderer>
|
||||
</mx:TileList>
|
||||
|
||||
<mx:Text id="message"
|
||||
paddingTop="20" />
|
||||
|
||||
</mx:Application>
|
107
PracticingFlex/03e1-accordion/Recipe.mxml
Normal file
@ -0,0 +1,107 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml"
|
||||
backgroundColor="#FFFFFF"
|
||||
backgroundAlpha="0"
|
||||
horizontalAlign="left"
|
||||
verticalGap="15" horizontalGap="15">
|
||||
|
||||
<mx:Panel title="Chocolate Cake">
|
||||
|
||||
<mx:Accordion id="ac"
|
||||
width="335"
|
||||
selectedIndex="0"
|
||||
historyManagementEnabled="false">
|
||||
|
||||
<mx:VBox label="Yummy!"
|
||||
horizontalAlign="center"
|
||||
verticalAlign="middle"
|
||||
width="300" height="300">
|
||||
<mx:Image source="assets/dessert_decadent_cake.jpg" />
|
||||
<mx:Button label="Order - $5.00"
|
||||
click="ac.selectedIndex=5" />
|
||||
</mx:VBox>
|
||||
|
||||
<mx:VBox label="Equipment Needed"
|
||||
height="300">
|
||||
<mx:TextArea width="300" height="100%"
|
||||
borderThickness="0">
|
||||
<mx:htmlText>
|
||||
<![CDATA[
|
||||
- Mixer
|
||||
- Measuring cups
|
||||
- Measuring spoons
|
||||
- Mixing Bowls
|
||||
- Mixing spoons
|
||||
- Cake pans
|
||||
]]>
|
||||
</mx:htmlText>
|
||||
</mx:TextArea>
|
||||
</mx:VBox>
|
||||
|
||||
<mx:VBox label="Ingredients"
|
||||
height="300">
|
||||
<mx:TextArea width="300" height="100%"
|
||||
borderThickness="0">
|
||||
<mx:htmlText>
|
||||
<![CDATA[
|
||||
- Eggs
|
||||
- Butter
|
||||
- Flour
|
||||
- Salt
|
||||
- Chocolate
|
||||
- Vanilla
|
||||
- Baking Powder
|
||||
- Milk
|
||||
]]>
|
||||
</mx:htmlText>
|
||||
</mx:TextArea>
|
||||
</mx:VBox>
|
||||
|
||||
<mx:VBox label="Instructions"
|
||||
height="300">
|
||||
<mx:Text text="1. Mix all dry ingredients in mixing bowl" />
|
||||
<mx:Text text="2. Mix all wet ingredients in another mixing bowl" />
|
||||
<mx:Text text="3. Mix wet and dry ingredients with mixer until smooth." />
|
||||
<mx:Text text="4. Melt chocolate, add to mixture and mix until even." />
|
||||
<mx:Text text="5. Pour into cake pan and bake at 350 for 40 minutes." />
|
||||
<mx:Text text="6. Let cool then frost." />
|
||||
</mx:VBox>
|
||||
|
||||
<mx:VBox label="Nutritional Information"
|
||||
height="300">
|
||||
<mx:Text text="Servings: 1" />
|
||||
<mx:Text text="Calories: 10,000" />
|
||||
<mx:Text text="Fat: 10 grams" />
|
||||
</mx:VBox>
|
||||
|
||||
<mx:VBox label="Order Form">
|
||||
<mx:Form>
|
||||
<mx:FormItem label="Name">
|
||||
<mx:TextInput id="customer" />
|
||||
</mx:FormItem>
|
||||
<mx:FormItem label="Address">
|
||||
<mx:TextInput id="address" />
|
||||
</mx:FormItem>
|
||||
<mx:FormItem label="City">
|
||||
<mx:TextInput id="city" />
|
||||
</mx:FormItem>
|
||||
<mx:FormItem label="State">
|
||||
<mx:TextInput id="state" />
|
||||
</mx:FormItem>
|
||||
<mx:FormItem label="Zip">
|
||||
<mx:TextInput id="zip" />
|
||||
</mx:FormItem>
|
||||
<mx:FormItem label="Credit Card">
|
||||
<mx:TextInput id="cc" />
|
||||
</mx:FormItem>
|
||||
<mx:FormItem>
|
||||
<mx:Button label="submit" />
|
||||
</mx:FormItem>
|
||||
</mx:Form>
|
||||
</mx:VBox>
|
||||
|
||||
</mx:Accordion>
|
||||
|
||||
</mx:Panel>
|
||||
|
||||
</mx:Application>
|
1
PracticingFlex/03e1-accordion/assets
Symbolic link
@ -0,0 +1 @@
|
||||
../_assets
|
50
PracticingFlex/03e2-tabbar-linkbar/LinkBar.mxml
Normal file
@ -0,0 +1,50 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml"
|
||||
backgroundColor="#FFFFFF"
|
||||
backgroundAlpha="0">
|
||||
|
||||
<mx:Panel>
|
||||
<mx:LinkBar dataProvider="{viewstack1}"/>
|
||||
|
||||
<mx:ViewStack id="viewstack1"
|
||||
x="30" y="32"
|
||||
width="452" height="339"
|
||||
selectedIndex="0">
|
||||
<mx:Form label="Store"
|
||||
width="100%" height="100%">
|
||||
<mx:FormItem label="Acme Widget 1.0">
|
||||
<mx:NumericStepper id="num"
|
||||
value="1" />
|
||||
<mx:Button label="Add to Cart"
|
||||
click="viewstack1.selectedIndex=1" />
|
||||
</mx:FormItem>
|
||||
</mx:Form>
|
||||
<mx:Form label="Shopping Cart"
|
||||
width="100%" height="100%">
|
||||
<mx:FormItem label="Acme Widget 1.0">
|
||||
<mx:Text text="Quantity: {num.value}" />
|
||||
<mx:Text text="Total: ${num.value * 15.00}" />
|
||||
<mx:Button label="Checkout"
|
||||
click="viewstack1.selectedIndex=2" />
|
||||
</mx:FormItem>
|
||||
</mx:Form>
|
||||
<mx:Form label="Checkout"
|
||||
width="100%" height="100%">
|
||||
<mx:FormItem label="Name on Credit Card" required="true">
|
||||
<mx:TextInput id="ccname" />
|
||||
</mx:FormItem>
|
||||
<mx:FormItem label="Credit Card Number">
|
||||
<mx:TextInput id="ccnum" />
|
||||
<mx:Button id="buyButton"
|
||||
label="Buy" />
|
||||
</mx:FormItem>
|
||||
</mx:Form>
|
||||
<mx:Form label="Thank You!"
|
||||
width="100%" height="100%">
|
||||
<mx:Text text="Thanks for your purchase!" />
|
||||
</mx:Form>
|
||||
</mx:ViewStack>
|
||||
|
||||
</mx:Panel>
|
||||
|
||||
</mx:Application>
|
50
PracticingFlex/03e2-tabbar-linkbar/TabBarDemo.mxml
Normal file
@ -0,0 +1,50 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml"
|
||||
backgroundColor="#FFFFFF"
|
||||
backgroundAlpha="0">
|
||||
|
||||
<mx:Panel>
|
||||
<mx:TabBar dataProvider="{viewstack1}" />
|
||||
|
||||
<mx:ViewStack id="viewstack1"
|
||||
x="30" y="32"
|
||||
width="452" height="339"
|
||||
selectedIndex="0">
|
||||
<mx:Form label="Store"
|
||||
width="100%" height="100%">
|
||||
<mx:FormItem label="Acme Widget 1.0">
|
||||
<mx:NumericStepper id="num"
|
||||
value="1" />
|
||||
<mx:Button label="Add to Cart"
|
||||
click="viewstack1.selectedIndex=1" />
|
||||
</mx:FormItem>
|
||||
</mx:Form>
|
||||
<mx:Form label="Shopping Cart"
|
||||
width="100%" height="100%">
|
||||
<mx:FormItem label="Acme Widget 1.0">
|
||||
<mx:Text text="Quantity: {num.value}" />
|
||||
<mx:Text text="Total: ${num.value * 15.00}" />
|
||||
<mx:Button label="Checkout"
|
||||
click="viewstack1.selectedIndex=2" />
|
||||
</mx:FormItem>
|
||||
</mx:Form>
|
||||
<mx:Form label="Checkout"
|
||||
width="100%" height="100%">
|
||||
<mx:FormItem label="Name on Credit Card"
|
||||
required="true">
|
||||
<mx:TextInput id="ccname" />
|
||||
</mx:FormItem>
|
||||
<mx:FormItem label="Credit Card Number">
|
||||
<mx:TextInput id="ccnum" />
|
||||
<mx:Button id="buyButton"
|
||||
label="Buy" />
|
||||
</mx:FormItem>
|
||||
</mx:Form>
|
||||
<mx:Form label="Thank You!"
|
||||
width="100%" height="100%">
|
||||
<mx:Text text="Thanks for your purchase!" />
|
||||
</mx:Form>
|
||||
</mx:ViewStack>
|
||||
</mx:Panel>
|
||||
|
||||
</mx:Application>
|
48
PracticingFlex/03e3-tabnavigator/Shopping.mxml
Normal file
@ -0,0 +1,48 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml"
|
||||
backgroundColor="#FFFFFF"
|
||||
backgroundAlpha="0">
|
||||
|
||||
<mx:Move id="hideEffect"
|
||||
xTo="-500" />
|
||||
<mx:Move id="showEffect"
|
||||
xFrom="500" />
|
||||
|
||||
<mx:Panel width="500" height="300"
|
||||
headerColors="[#000000,#FFFFFF]">
|
||||
|
||||
<mx:TabNavigator id="viewstack2"
|
||||
selectedIndex="0"
|
||||
historyManagementEnabled="false"
|
||||
width="100%" height="100%">
|
||||
|
||||
<mx:Form label="Shopping Cart"
|
||||
hideEffect="{hideEffect}" showEffect="{showEffect}">
|
||||
<mx:FormItem label="Acme Widget 1.0">
|
||||
<mx:NumericStepper value="1" />
|
||||
<mx:Button label="Add to Cart"
|
||||
click="viewstack2.selectedIndex=1" />
|
||||
</mx:FormItem>
|
||||
</mx:Form>
|
||||
|
||||
<mx:Form label="Enter Your Payment Information"
|
||||
hideEffect="{hideEffect}" showEffect="{showEffect}">
|
||||
<mx:FormItem label="Name on Credit Card">
|
||||
<mx:TextInput />
|
||||
</mx:FormItem>
|
||||
<mx:FormItem label="Credit Card Number">
|
||||
<mx:TextInput />
|
||||
<mx:Button label="Buy"
|
||||
click="viewstack2.selectedIndex=2" />
|
||||
</mx:FormItem>
|
||||
</mx:Form>
|
||||
|
||||
<mx:Form label="Thank You!"
|
||||
hideEffect="{hideEffect}" showEffect="{showEffect}">
|
||||
<mx:Text text="Thanks for your purchase!" />
|
||||
</mx:Form>
|
||||
|
||||
</mx:TabNavigator>
|
||||
|
||||
</mx:Panel>
|
||||
</mx:Application>
|
44
PracticingFlex/03e4-viewstack/ViewStackDemo.mxml
Normal file
@ -0,0 +1,44 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml"
|
||||
backgroundColor="#FFFFFF"
|
||||
backgroundAlpha="0"
|
||||
horizontalAlign="left"
|
||||
verticalGap="15" horizontalGap="15">
|
||||
|
||||
<mx:Panel>
|
||||
|
||||
<mx:ViewStack id="vs"
|
||||
x="30" y="32"
|
||||
width="452" height="339"
|
||||
selectedIndex="0">
|
||||
|
||||
<mx:Canvas backgroundColor="#FFFFCC">
|
||||
<mx:Text text="This is Area 1"
|
||||
fontWeight="bold"
|
||||
paddingTop="10" paddingLeft="10" />
|
||||
</mx:Canvas>
|
||||
|
||||
<mx:Canvas backgroundColor="#D7D7D7">
|
||||
<mx:Text text="This is Area 2"
|
||||
fontWeight="bold"
|
||||
paddingTop="10" paddingLeft="10" />
|
||||
</mx:Canvas>
|
||||
|
||||
<mx:Canvas backgroundColor="#CCCCFF">
|
||||
<mx:Text text="This is Area 3" fontWeight="bold" paddingTop="10" paddingLeft="10" />
|
||||
</mx:Canvas>
|
||||
|
||||
</mx:ViewStack>
|
||||
|
||||
</mx:Panel>
|
||||
|
||||
<mx:HBox>
|
||||
<mx:Button label="Area 1"
|
||||
click="vs.selectedIndex=0" />
|
||||
<mx:Button label="Area 2"
|
||||
click="vs.selectedIndex=1" />
|
||||
<mx:Button label="Area 3"
|
||||
click="vs.selectedIndex=2" />
|
||||
</mx:HBox>
|
||||
|
||||
</mx:Application>
|
16
PracticingFlex/03f1-custom-components/MainForm.mxml
Normal file
@ -0,0 +1,16 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml"
|
||||
backgroundColor="#FFFFFF"
|
||||
backgroundAlpha="0"
|
||||
xmlns:me="com.mycustom.components.*">
|
||||
|
||||
<mx:Form>
|
||||
<mx:FormItem label="Email Address:" >
|
||||
<me:TextInputEmail />
|
||||
</mx:FormItem>
|
||||
<mx:FormItem>
|
||||
<mx:Button label="Submit" />
|
||||
</mx:FormItem>
|
||||
</mx:Form>
|
||||
|
||||
</mx:Application>
|
@ -0,0 +1,35 @@
|
||||
package com.mycustom.components
|
||||
{
|
||||
import mx.controls.TextInput;
|
||||
import mx.events.ValidationResultEvent;
|
||||
import mx.validators.EmailValidator;
|
||||
import flash.events.Event;
|
||||
import mx.validators.ValidationResult;
|
||||
|
||||
public class TextInputEmail extends TextInput
|
||||
{
|
||||
private var emailValidator:EmailValidator = new EmailValidator();
|
||||
private var validator:ValidationResultEvent;
|
||||
|
||||
public function TextInputEmail()
|
||||
{
|
||||
super();
|
||||
this.emailValidator.source = this;
|
||||
this.emailValidator.property = "text";
|
||||
this.addEventListener("enter", this.validate);
|
||||
|
||||
}
|
||||
|
||||
private function validate(event:Event):void
|
||||
{
|
||||
validator = emailValidator.validate();
|
||||
|
||||
if (validator.type == ValidationResultEvent.VALID)
|
||||
{
|
||||
this.errorString = "";
|
||||
} else {
|
||||
this.errorString = validator.message;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
9
PracticingFlex/03f2-code-behind/CodeBehindDisplay.mxml
Normal file
@ -0,0 +1,9 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<custom:ComboBoxCodeBehind
|
||||
xmlns:mx="http://www.adobe.com/2006/mxml"
|
||||
xmlns:custom="as_components.*">
|
||||
|
||||
<mx:ComboBox id="monthsCB" dataProvider="{months}" selectedIndex="{selectedIndexMonth}"/>
|
||||
<mx:ComboBox id="daysCB" dataProvider="{days}" selectedIndex="{selectedIndexDay}"/>
|
||||
<mx:ComboBox id="yearsCB" dataProvider="{years}" selectedIndex="{selectedIndexYear}" />
|
||||
</custom:ComboBoxCodeBehind>
|
10
PracticingFlex/03f2-code-behind/CodeExample.mxml
Normal file
@ -0,0 +1,10 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml"
|
||||
layout="vertical"
|
||||
backgroundColor="#FFFFFF"
|
||||
backgroundAlpha="0"
|
||||
xmlns:local="*">
|
||||
<mx:VBox>
|
||||
<local:CodeBehindDisplay />
|
||||
</mx:VBox>
|
||||
</mx:Application>
|
@ -0,0 +1,105 @@
|
||||
package as_components
|
||||
{
|
||||
import mx.containers.HBox;
|
||||
import mx.controls.ComboBox;
|
||||
import mx.events.FlexEvent;
|
||||
import mx.events.ListEvent;
|
||||
import mx.formatters.DateFormatter;
|
||||
|
||||
[Bindable]
|
||||
public class ComboBoxCodeBehind extends HBox
|
||||
{
|
||||
public var months:Array = new Array();
|
||||
public var dateformatter:DateFormatter = new DateFormatter();
|
||||
public var selectedIndex:int;
|
||||
public var days:Array;
|
||||
public var years:Array = new Array();
|
||||
public var monthsCB:ComboBox;
|
||||
public var daysCB:ComboBox;
|
||||
public var yearsCB:ComboBox;
|
||||
public var selectedIndexYear:int;
|
||||
public var selectedIndexMonth:int;
|
||||
public var selectedIndexDay:int;
|
||||
public var thisYear:int;
|
||||
|
||||
|
||||
public function ComboBoxCodeBehind()
|
||||
{
|
||||
super();
|
||||
init();
|
||||
this.addEventListener(FlexEvent.CREATION_COMPLETE, creationCompleteHandler);
|
||||
}
|
||||
|
||||
private function init():void{
|
||||
var i:int;
|
||||
var now:Date = new Date();
|
||||
|
||||
var currentMonth:int = now.getMonth();
|
||||
var currentYear:int = now.getFullYear();
|
||||
var currentDay:int = now.getDate();
|
||||
|
||||
thisYear = currentYear;
|
||||
dateformatter.formatString = "MMMM";
|
||||
|
||||
for (i=0; i<12; i++){
|
||||
now.setMonth(i);
|
||||
months[i] = dateformatter.format(now);
|
||||
}
|
||||
|
||||
setYears(currentYear);
|
||||
setDays(currentMonth);
|
||||
|
||||
selectedIndexMonth = currentMonth;
|
||||
selectedIndexYear = years.indexOf(currentYear);
|
||||
selectedIndexDay = days.indexOf(currentDay);
|
||||
}
|
||||
|
||||
private function creationCompleteHandler(event:FlexEvent):void{
|
||||
monthsCB.addEventListener(ListEvent.CHANGE,monthsHandler);
|
||||
yearsCB.addEventListener(ListEvent.CHANGE, yearsHandler);
|
||||
}
|
||||
|
||||
|
||||
private function setDays(month:int):void{
|
||||
days = new Array();
|
||||
var i:int;
|
||||
|
||||
if (month == 0 || month == 2 || month == 4 || month == 6 || month == 7 || month == 9 || month == 11){
|
||||
for(i=1; i<=31; i++)
|
||||
days.push(i);
|
||||
}else if (month == 3 || month == 5 || month == 8 || month == 10){
|
||||
for(i=1; i<=30; i++)
|
||||
days.push(i);
|
||||
}else if (month == 1){
|
||||
if (thisYear % 4 == 0){
|
||||
for(i=1; i<=29; i++)
|
||||
days.push(i);
|
||||
}else{
|
||||
for(i=1; i<=28; i++)
|
||||
days.push(i);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private function setYears(year:int):void{
|
||||
var j:int;
|
||||
for(j=1950; j<=year; j++){
|
||||
years.push(j);
|
||||
}
|
||||
}
|
||||
|
||||
private function monthsHandler(event:ListEvent):void{
|
||||
setDays(event.currentTarget.selectedIndex);
|
||||
selectedIndexDay = 0;
|
||||
}
|
||||
|
||||
private function yearsHandler(event:ListEvent):void{
|
||||
if (monthsCB.selectedIndex == 1){
|
||||
var selectedDay:int = daysCB.selectedIndex;
|
||||
thisYear = event.currentTarget.selectedItem as int;
|
||||
setDays(monthsCB.selectedIndex);
|
||||
selectedIndexDay = selectedDay;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
46
PracticingFlex/03f3-composite-component/ComponentForm.mxml
Normal file
@ -0,0 +1,46 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml"
|
||||
backgroundColor="#FFFFFF"
|
||||
backgroundAlpha="0"
|
||||
xmlns:custom="components.*">
|
||||
|
||||
<mx:Script>
|
||||
<![CDATA[
|
||||
import mx.controls.Alert;
|
||||
|
||||
private function show(event:Event):void {
|
||||
var day:String = bday.daysCB.selectedItem.toString();
|
||||
var month:String = bday.monthsCB.selectedItem.toString();
|
||||
var year:String = bday.yearsCB.selectedItem.toString();
|
||||
|
||||
var birthdayString:String = month + ' ' + day + ', ' + year;
|
||||
var birthdayDate:Date = new Date(bday.yearsCB.selectedItem, bday.monthsCB.selectedIndex,bday.daysCB.selectedIndex + 1);
|
||||
|
||||
var now:Date = new Date();
|
||||
|
||||
if (birthdayDate.toDateString() == now.toDateString()) {
|
||||
Alert.show("HAPPY BIRTHDAY " + fullname.text + '!');
|
||||
} else {
|
||||
Alert.show("Hello " + fullname.text + '! ' + '\nYour birthday is ' + birthdayString + '.');
|
||||
}
|
||||
}
|
||||
]]>
|
||||
</mx:Script>
|
||||
|
||||
<mx:Form>
|
||||
<mx:FormHeading label="Tell us your birthday to get a free gift!" />
|
||||
<mx:FormItem label="Name:">
|
||||
<mx:TextInput id="fullname" />
|
||||
</mx:FormItem>
|
||||
<mx:FormItem label="Your Birthday:"
|
||||
direction="horizontal">
|
||||
<custom:ComboBoxDateEntry id="bday" />
|
||||
</mx:FormItem>
|
||||
<mx:FormItem>
|
||||
<mx:Button id="myButton"
|
||||
label="Submit"
|
||||
click="show(event)" />
|
||||
</mx:FormItem>
|
||||
</mx:Form>
|
||||
|
||||
</mx:Application>
|
@ -0,0 +1,53 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!--
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
// ADOBE SYSTEMS INCORPORATED
|
||||
// Copyright 2007 Adobe Systems Incorporated
|
||||
// All Rights Reserved.
|
||||
//
|
||||
// NOTICE: Adobe permits you to use, modify, and distribute this file in accordance with the
|
||||
// terms of the Adobe license agreement accompanying it. If you have received this file from a
|
||||
// source other than Adobe, then your use, modification, or distribution of it requires the prior
|
||||
// written permission of Adobe.
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
-->
|
||||
<mx:HBox xmlns:mx="http://www.adobe.com/2006/mxml"
|
||||
xmlns:me="components.*"
|
||||
creationComplete="init()">
|
||||
<mx:Script>
|
||||
<![CDATA[
|
||||
|
||||
//create bindable variables to share with components
|
||||
[Bindable]
|
||||
private var days:Array = new Array();
|
||||
|
||||
[Bindable]
|
||||
private var years:Array = new Array();
|
||||
|
||||
private function init():void{
|
||||
|
||||
//get current date
|
||||
var now:Date = new Date();
|
||||
|
||||
//populate day array
|
||||
for(var i:int=1; i<=31; i++){
|
||||
this.days.push(i);
|
||||
}
|
||||
//populate the years array up to the current year
|
||||
for(var j:int=1950; j<=now.getFullYear(); j++){
|
||||
this.years.push(j);
|
||||
}
|
||||
|
||||
//select the display values for the combo boxes based on the current date
|
||||
this.daysCB.selectedIndex = days.indexOf(now.getDate());
|
||||
this.yearsCB.selectedIndex = years.indexOf(now.getFullYear());
|
||||
}
|
||||
|
||||
|
||||
]]>
|
||||
</mx:Script>
|
||||
|
||||
<me:ComboBoxMonths id="monthsCB"/>
|
||||
<mx:ComboBox id="daysCB" dataProvider="{this.days}" width="50"/>
|
||||
<mx:ComboBox id="yearsCB" dataProvider="{this.years}" width="65"/>
|
||||
</mx:HBox>
|
@ -0,0 +1,48 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!--
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
// ADOBE SYSTEMS INCORPORATED
|
||||
// Copyright 2007 Adobe Systems Incorporated
|
||||
// All Rights Reserved.
|
||||
//
|
||||
// NOTICE: Adobe permits you to use, modify, and distribute this file in accordance with the
|
||||
// terms of the Adobe license agreement accompanying it. If you have received this file from a
|
||||
// source other than Adobe, then your use, modification, or distribution of it requires the prior
|
||||
// written permission of Adobe.
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
-->
|
||||
<mx:ComboBox xmlns:mx="http://www.adobe.com/2006/mxml" initialize="init()">
|
||||
<mx:Script>
|
||||
<![CDATA[
|
||||
import mx.formatters.DateFormatter;
|
||||
|
||||
//variable does not need to be bindable since it is not shared or changed after creation.
|
||||
private var months:Array = new Array();
|
||||
private var dateformatter:DateFormatter = new DateFormatter();
|
||||
|
||||
private function init():void{
|
||||
var i:int;
|
||||
//get the date
|
||||
var now:Date = new Date();
|
||||
//set current month
|
||||
var currentMonth:int = now.getMonth();
|
||||
//format the string to show only the month
|
||||
dateformatter.formatString = "MMMM";
|
||||
|
||||
//loop 12 times
|
||||
for (i=0; i<12; i++){
|
||||
//change the month of the date
|
||||
now.setMonth(i);
|
||||
//poplate the array with the month string
|
||||
months[i] = dateformatter.format(now);
|
||||
}
|
||||
|
||||
//set the array as the dataprovider of this combobox
|
||||
this.dataProvider = months;
|
||||
//select current month
|
||||
this.selectedIndex = currentMonth;
|
||||
}
|
||||
]]>
|
||||
</mx:Script>
|
||||
</mx:ComboBox>
|
||||
|
52
PracticingFlex/03f4-multiple-composite-components/Main.mxml
Normal file
@ -0,0 +1,52 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml"
|
||||
backgroundColor="#FFFFFF"
|
||||
backgroundAlpha="0"
|
||||
xmlns:custom="components.*">
|
||||
|
||||
<mx:Script>
|
||||
<![CDATA[
|
||||
import mx.controls.Alert;
|
||||
|
||||
private function show(event:Event):void {
|
||||
var sday:Number = sdate.daysCB.selectedIndex + 1;
|
||||
var smonth:Number = sdate.monthsCB.selectedIndex;
|
||||
var syear:Object = sdate.yearsCB.selectedItem.toString();
|
||||
|
||||
var eday:Number = edate.daysCB.selectedIndex + 1;
|
||||
var emonth:Number = edate.monthsCB.selectedIndex;
|
||||
var eyear:Object = edate.yearsCB.selectedItem.toString();
|
||||
|
||||
var startDate:Date = new Date(syear,smonth,sday);
|
||||
var endDate:Date = new Date(eyear,emonth,eday);
|
||||
|
||||
if (endDate < startDate){
|
||||
Alert.show("Please enter a end date greater than the start date.");
|
||||
}else{
|
||||
Alert.show("The record search is between " +
|
||||
dateFormat.format(startDate) + ' and ' +
|
||||
dateFormat.format(endDate));
|
||||
}
|
||||
}
|
||||
]]>
|
||||
</mx:Script>
|
||||
|
||||
<mx:DateFormatter id="dateFormat"
|
||||
formatString="MM/DD/YYYY" />
|
||||
|
||||
<mx:Form>
|
||||
<mx:FormHeading label="Record Search" />
|
||||
<mx:FormItem label="Start Date">
|
||||
<custom:ComboBoxDateEntry id="sdate" />
|
||||
</mx:FormItem>
|
||||
<mx:FormItem label="End Date">
|
||||
<custom:ComboBoxDateEntry id="edate" />
|
||||
</mx:FormItem>
|
||||
<mx:FormItem>
|
||||
<mx:Button id="myButton"
|
||||
label="Search"
|
||||
click="show(event)" />
|
||||
</mx:FormItem>
|
||||
</mx:Form>
|
||||
|
||||
</mx:Application>
|
@ -0,0 +1,82 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!--
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
// ADOBE SYSTEMS INCORPORATED
|
||||
// Copyright 2007 Adobe Systems Incorporated
|
||||
// All Rights Reserved.
|
||||
//
|
||||
// NOTICE: Adobe permits you to use, modify, and distribute this file in accordance with the
|
||||
// terms of the Adobe license agreement accompanying it. If you have received this file from a
|
||||
// source other than Adobe, then your use, modification, or distribution of it requires the prior
|
||||
// written permission of Adobe.
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
-->
|
||||
<mx:HBox xmlns:mx="http://www.adobe.com/2006/mxml"
|
||||
xmlns:custom="components.*"
|
||||
creationComplete="init()">
|
||||
<mx:Script>
|
||||
<![CDATA[
|
||||
import mx.events.ListEvent;
|
||||
//create bindable variables to share with components
|
||||
[Bindable]
|
||||
private var days:Array;
|
||||
|
||||
[Bindable]
|
||||
private var years:Array = new Array();
|
||||
|
||||
private function init():void{
|
||||
this.monthsCB.addEventListener(ListEvent.CHANGE,monthsHandler);
|
||||
//get current date
|
||||
var now:Date = new Date();
|
||||
|
||||
//populate days and year
|
||||
setDays(now.getMonth());
|
||||
setYears(now.getFullYear());
|
||||
|
||||
//select the display values for the combo boxes based on the current date
|
||||
this.daysCB.selectedIndex = 0;
|
||||
this.yearsCB.selectedIndex = years.indexOf(now.getFullYear());
|
||||
|
||||
}
|
||||
|
||||
private function monthsHandler(event:ListEvent):void{
|
||||
setDays(event.currentTarget.selectedIndex);
|
||||
this.daysCB.selectedIndex = 0;
|
||||
}
|
||||
|
||||
private function setDays(month:int):void{
|
||||
this.days = new Array();
|
||||
var i:int;
|
||||
|
||||
if (month == 0 || month == 2 || month == 4 || month == 6 || month == 7 || month == 9 || month == 11){
|
||||
for(i=1; i<=31; i++)
|
||||
this.days.push(i);
|
||||
|
||||
}else if (month == 3 || month == 5 || month == 8 || month == 10){
|
||||
for(i=1; i<=30; i++)
|
||||
this.days.push(i);
|
||||
|
||||
}else if (month == 1){
|
||||
if (yearsCB.selectedIndex % 4 == 0){
|
||||
for(i=1; i<=29; i++)
|
||||
this.days.push(i);
|
||||
}else{
|
||||
for(i=1; i<=28; i++)
|
||||
this.days.push(i);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private function setYears(year:int):void{
|
||||
var j:int;
|
||||
for(j=1950; j<=year; j++){
|
||||
this.years.push(j);
|
||||
}
|
||||
}
|
||||
]]>
|
||||
</mx:Script>
|
||||
|
||||
<custom:ComboBoxMonths id="monthsCB"/>
|
||||
<mx:ComboBox id="daysCB" dataProvider="{this.days}" width="50"/>
|
||||
<mx:ComboBox id="yearsCB" dataProvider="{this.years}" width="70"/>
|
||||
</mx:HBox>
|
@ -0,0 +1,53 @@
|
||||
package components
|
||||
{
|
||||
import mx.controls.ComboBox;
|
||||
import mx.formatters.DateFormatter;
|
||||
/*
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
// ADOBE SYSTEMS INCORPORATED
|
||||
// Copyright 2007 Adobe Systems Incorporated
|
||||
// All Rights Reserved.
|
||||
//
|
||||
// NOTICE: Adobe permits you to use, modify, and distribute this file in accordance with the
|
||||
// terms of the Adobe license agreement accompanying it. If you have received this file from a
|
||||
// source other than Adobe, then your use, modification, or distribution of it requires the prior
|
||||
// written permission of Adobe.
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
*/
|
||||
public class ComboBoxMonths extends ComboBox
|
||||
{
|
||||
private var months:Array = new Array();
|
||||
private var dateformatter:DateFormatter = new DateFormatter();
|
||||
|
||||
public function ComboBoxMonths()
|
||||
{
|
||||
super();
|
||||
init();
|
||||
|
||||
}
|
||||
|
||||
private function init():void{
|
||||
var i:int;
|
||||
//get the date
|
||||
var now:Date = new Date();
|
||||
//set current month
|
||||
var currentMonth:int = now.getMonth();
|
||||
//format the string to show only the month
|
||||
dateformatter.formatString = "MMMM";
|
||||
|
||||
//loop 12 times
|
||||
for (i=0; i<12; i++){
|
||||
//change the month of the date
|
||||
now.setMonth(i);
|
||||
//poplate the array with the month string
|
||||
months[i] = dateformatter.format(now);
|
||||
}
|
||||
|
||||
//set the array as the dataprovider of this combobox
|
||||
this.dataProvider = months;
|
||||
//select current month
|
||||
this.selectedIndex = currentMonth;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
32
PracticingFlex/03f5-mxml/MainForm.mxml
Normal file
@ -0,0 +1,32 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml"
|
||||
backgroundColor="#FFFFFF"
|
||||
backgroundAlpha="0"
|
||||
xmlns:custom="components.*">
|
||||
|
||||
<mx:Script>
|
||||
<![CDATA[
|
||||
import mx.controls.Alert;
|
||||
|
||||
private function showMonth():void{
|
||||
Alert.show("Thank you " + fullname.text +
|
||||
'! \nYour gift will arrive in ' +
|
||||
month.selectedItem + '.');
|
||||
}
|
||||
]]>
|
||||
</mx:Script>
|
||||
|
||||
<mx:Form>
|
||||
<mx:FormHeading label="Get a free gift!" />
|
||||
<mx:FormItem label="Name">
|
||||
<mx:TextInput id="fullname" />
|
||||
</mx:FormItem>
|
||||
<mx:FormItem label="Select delivery month">
|
||||
<custom:ComboBoxMonths id="month" />
|
||||
</mx:FormItem>
|
||||
<mx:FormItem>
|
||||
<mx:Button label="Submit"
|
||||
click="showMonth()" />
|
||||
</mx:FormItem>
|
||||
</mx:Form>
|
||||
</mx:Application>
|
19
PracticingFlex/03f5-mxml/components/ComboBoxMonths.mxml
Normal file
@ -0,0 +1,19 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<mx:ComboBox xmlns:mx="http://www.adobe.com/2006/mxml">
|
||||
<mx:dataProvider>
|
||||
<mx:ArrayCollection>
|
||||
<mx:String>January</mx:String>
|
||||
<mx:String>February</mx:String>
|
||||
<mx:String>March</mx:String>
|
||||
<mx:String>April</mx:String>
|
||||
<mx:String>May</mx:String>
|
||||
<mx:String>June</mx:String>
|
||||
<mx:String>July</mx:String>
|
||||
<mx:String>August</mx:String>
|
||||
<mx:String>September</mx:String>
|
||||
<mx:String>October</mx:String>
|
||||
<mx:String>November</mx:String>
|
||||
<mx:String>December</mx:String>
|
||||
</mx:ArrayCollection>
|
||||
</mx:dataProvider>
|
||||
</mx:ComboBox>
|
18
PracticingFlex/03g1-debugging/Debugging.mxml
Normal file
@ -0,0 +1,18 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute"
|
||||
creationComplete="initApp()">
|
||||
<mx:Script>
|
||||
<![CDATA[
|
||||
import mx.controls.Alert;
|
||||
|
||||
private function initApp():void
|
||||
{
|
||||
trace("Hello from Flex Debugging!");
|
||||
var myVar:Number = 9;
|
||||
trace("The value of myVar is " + myVar);
|
||||
}
|
||||
]]>
|
||||
</mx:Script>
|
||||
|
||||
<mx:Button label="Click Me" click="Alert.show('Hello from Flex');"/>
|
||||
</mx:Application>
|
67
PracticingFlex/Makefile
Normal file
@ -0,0 +1,67 @@
|
||||
# Makefile for building flex apps associated with
|
||||
# the Adobe Flex "Geting Started" tutorial at:
|
||||
# http://learn.adobe.com/wiki/display/Flex/Getting+Started
|
||||
|
||||
# sets mxmlc and compc to their respective basenames
|
||||
# if not overridden in command line like so:
|
||||
# make MXMLC=/path/to/my/mxmlc
|
||||
MXMLC ?= mxmlc
|
||||
COMPC ?= compc
|
||||
|
||||
ifdef DEBUG
|
||||
MXMLC_FLAGS ?= -warnings -strict -debug -keep-generated-actionscript
|
||||
else
|
||||
MXMLC_FLAGS ?= -warnings -strict
|
||||
endif
|
||||
|
||||
ifdef OLD
|
||||
MXMLC_FLAGS += -target-player 9.0.0
|
||||
endif
|
||||
|
||||
MXMLC_FLAGS += -l+=$(HOME)/.local/share/flexunit
|
||||
|
||||
|
||||
# define all dependency mxml paths and their swf path targets
|
||||
# (which don't yet exist if they've never been built)
|
||||
MXML = $(wildcard ./*-*/*.mxml)
|
||||
TEST_CLASSES = $(wildcard ./*-*/*/tests/Test*.as) \
|
||||
$(wildcard ./*-*/tests/Test*.as) \
|
||||
$(wildcard ./*-*/*/*/tests/Test*.as)
|
||||
SWFS = $(patsubst %.mxml,%.swf,$(MXML)) $(patsubst %.as,%.swf,$(TEST_CLASSES))
|
||||
|
||||
|
||||
# glob up all component files as well, since changes to them
|
||||
# should also prompt rebuild
|
||||
COMPONENTS = $(wildcard [0-9]*-*/*.as) $(wildcard custom-*/*.as)
|
||||
export COMPONENTS
|
||||
|
||||
|
||||
include rules.mk
|
||||
|
||||
|
||||
all: $(SWFS)
|
||||
|
||||
|
||||
include targets.mk
|
||||
|
||||
|
||||
components:
|
||||
@echo $(COMPONENTS)
|
||||
|
||||
|
||||
mxml:
|
||||
@echo $(MXML)
|
||||
|
||||
|
||||
swfs:
|
||||
@echo $(SWFS)
|
||||
|
||||
|
||||
test_classes:
|
||||
@echo $(TEST_CLASSES)
|
||||
|
||||
|
||||
# remove all swf files in the tree
|
||||
clean:
|
||||
find -name \*.swf -exec rm {} \; ; \
|
||||
find -name \*.swc -exec rm {} \;
|
1
PracticingFlex/README
Normal file
@ -0,0 +1 @@
|
||||
crap I'm doing to (re)learn Adobe Flex
|
BIN
PracticingFlex/_assets/animals03.jpg
Normal file
After Width: | Height: | Size: 25 KiB |
BIN
PracticingFlex/_assets/animals03_sm.jpg
Normal file
After Width: | Height: | Size: 9.1 KiB |
BIN
PracticingFlex/_assets/animals06_sm.jpg
Normal file
After Width: | Height: | Size: 2.3 KiB |
BIN
PracticingFlex/_assets/animals07_sm.jpg
Normal file
After Width: | Height: | Size: 1.6 KiB |
BIN
PracticingFlex/_assets/animals08_sm.jpg
Normal file
After Width: | Height: | Size: 1.7 KiB |
BIN
PracticingFlex/_assets/animals09_sm.jpg
Normal file
After Width: | Height: | Size: 1.8 KiB |
BIN
PracticingFlex/_assets/animals10_sm.jpg
Normal file
After Width: | Height: | Size: 2.1 KiB |
BIN
PracticingFlex/_assets/animals11_sm.jpg
Normal file
After Width: | Height: | Size: 2.3 KiB |
BIN
PracticingFlex/_assets/animals12_sm.jpg
Normal file
After Width: | Height: | Size: 2.0 KiB |
BIN
PracticingFlex/_assets/city01_sm.jpg
Normal file
After Width: | Height: | Size: 2.8 KiB |
BIN
PracticingFlex/_assets/city02_sm.jpg
Normal file
After Width: | Height: | Size: 2.2 KiB |
BIN
PracticingFlex/_assets/city03_sm.jpg
Normal file
After Width: | Height: | Size: 1.4 KiB |
BIN
PracticingFlex/_assets/city04_sm.jpg
Normal file
After Width: | Height: | Size: 2.0 KiB |
BIN
PracticingFlex/_assets/dessert_decadent_cake.jpg
Normal file
After Width: | Height: | Size: 7.9 KiB |
76
PracticingFlex/build.xml
Normal file
@ -0,0 +1,76 @@
|
||||
<project name="LearningFlex" basedir="." default="build">
|
||||
<property environment="env"/>
|
||||
<property name="FLEX_HOME" value="${env.FLEX_HOME}"/>
|
||||
<property name="FLEXUNIT_HOME" value="${env.FLEXUNIT_HOME}"/>
|
||||
<taskdef resource="flexTasks.tasks" classpath="${env.FLEX_HOME}/ant/lib/flexTasks.jar"/>
|
||||
<target name="build">
|
||||
<mxmlc as3="true" file="./01-flickr/FlickrRIA.mxml"/>
|
||||
<mxmlc as3="true" file="./01-flickr/FlickrThumbnail.mxml"/>
|
||||
<mxmlc as3="true" file="./02-shipping/PlainText.mxml"/>
|
||||
<mxmlc as3="true" file="./03a1-binding-and-modeling/YahooWeather.mxml"/>
|
||||
<mxmlc as3="true" file="./03a2-crud-dynamic/CRUDDynamic.mxml"/>
|
||||
<mxmlc as3="true" file="./03a3-crud-static/CRUDStatic.mxml"/>
|
||||
<mxmlc as3="true" file="./03a4-external-interface/Main.mxml"/>
|
||||
<mxmlc as3="true" file="./03a5-local-connections/BasicTaskReceiver.mxml"/>
|
||||
<mxmlc as3="true" file="./03a5-local-connections/TaskSender.mxml"/>
|
||||
<mxmlc as3="true" file="./03a6-shared-objects/SharedObjectExample.mxml"/>
|
||||
<mxmlc as3="true" file="./03a7-validation-and-formatting/ValidatorsandFormattersExampleWithAreaCodeLookup.mxml"/>
|
||||
<mxmlc as3="true" file="./03b-handling-events/TwitterTimeline.mxml"/>
|
||||
<mxmlc as3="true" file="./03b1-event-listeners/VBoxDemo.mxml"/>
|
||||
<mxmlc as3="true" file="./03b2-event-propagation/DemoApplication.mxml"/>
|
||||
<mxmlc as3="true" file="./03b3-simple-ui-event/Example1.mxml"/>
|
||||
<mxmlc as3="true" file="./03b3-simple-ui-event/Example2.mxml"/>
|
||||
<mxmlc as3="true" file="./03c1-application-container/Demo.mxml"/>
|
||||
<mxmlc as3="true" file="./03c2-box-model/HBoxExample.mxml"/>
|
||||
<mxmlc as3="true" file="./03c2-box-model/VBoxExample.mxml"/>
|
||||
<mxmlc as3="true" file="./03c2-box-model/VBoxHBoxCombo.mxml"/>
|
||||
<mxmlc as3="true" file="./03c3-canvas-absolute/Example.mxml"/>
|
||||
<mxmlc as3="true" file="./03c4-canvas-relative/Photo.mxml"/>
|
||||
<mxmlc as3="true" file="./03c5-combined-layout/Combined.mxml"/>
|
||||
<mxmlc as3="true" file="./03c6-form/CommentForm.mxml"/>
|
||||
<mxmlc as3="true" file="./03c7-mxml-vs-as3/WithAs3.mxml"/>
|
||||
<mxmlc as3="true" file="./03c7-mxml-vs-as3/WithMxml.mxml"/>
|
||||
<mxmlc as3="true" file="./03c8-panel/Photo.mxml"/>
|
||||
<mxmlc as3="true" file="./03d1-datagrid/DataGridExample.mxml"/>
|
||||
<mxmlc as3="true" file="./03d2-item-renderers/HBoxWeatherDisplay.mxml"/>
|
||||
<mxmlc as3="true" file="./03d2-item-renderers/WeatherDisplay.mxml"/>
|
||||
<mxmlc as3="true" file="./03d3-lists/HorizontalListControl.mxml"/>
|
||||
<mxmlc as3="true" file="./03d3-lists/ListControl.mxml"/>
|
||||
<mxmlc as3="true" file="./03d4-tilelist/TileListExample.mxml"/>
|
||||
<mxmlc as3="true" file="./03e1-accordion/Recipe.mxml"/>
|
||||
<mxmlc as3="true" file="./03e2-tabbar-linkbar/LinkBar.mxml"/>
|
||||
<mxmlc as3="true" file="./03e2-tabbar-linkbar/TabBarDemo.mxml"/>
|
||||
<mxmlc as3="true" file="./03e3-tabnavigator/Shopping.mxml"/>
|
||||
<mxmlc as3="true" file="./03e4-viewstack/ViewStackDemo.mxml"/>
|
||||
<mxmlc as3="true" file="./03f1-custom-components/MainForm.mxml"/>
|
||||
<mxmlc as3="true" file="./03f2-code-behind/CodeBehindDisplay.mxml"/>
|
||||
<mxmlc as3="true" file="./03f2-code-behind/CodeExample.mxml"/>
|
||||
<mxmlc as3="true" file="./03f3-composite-component/ComponentForm.mxml"/>
|
||||
<mxmlc as3="true" file="./03f4-multiple-composite-components/Main.mxml"/>
|
||||
<mxmlc as3="true" file="./03f5-mxml/MainForm.mxml"/>
|
||||
<mxmlc as3="true" file="./03g1-debugging/Debugging.mxml"/>
|
||||
<mxmlc as3="true" file="./custom-03d1-datagrid/Snarf.mxml"/>
|
||||
<mxmlc as3="true" file="./custom-03d2-item-renderers/HBoxWeatherDisplay.mxml"/>
|
||||
<mxmlc as3="true" file="./custom-03d2-item-renderers/WeatherDisplay.mxml"/>
|
||||
<mxmlc as3="true" file="./custom-03d3-lists/ListControl.mxml"/>
|
||||
<mxmlc as3="true" file="./custom-03d4-tilelist/TileListExample.mxml"/>
|
||||
<mxmlc as3="true" file="./custom-03g1-debugging/Debugging.mxml"/>
|
||||
<compc output="./custom-03g1-debugging/me/tests/TestSuite.swf" include-classes="me.tests.TestSuite">
|
||||
<sp path-element="./custom-03g1-debugging"/>
|
||||
<l dir="${FLEXUNIT_HOME}" append="yes"/>
|
||||
</compc>
|
||||
</target>
|
||||
<target name="clean">
|
||||
<delete>
|
||||
<fileset dir="${basedir}" casesensitive="yes">
|
||||
<patternset id="swf.files">
|
||||
<include name="**/*.swf"/>
|
||||
</patternset>
|
||||
<patternset id="swf.files">
|
||||
<include name="**/*.swc"/>
|
||||
</patternset>
|
||||
</fileset>
|
||||
</delete>
|
||||
</target>
|
||||
</project>
|
||||
|
22
PracticingFlex/custom-03d1-datagrid/CustomApp.as
Normal file
@ -0,0 +1,22 @@
|
||||
package
|
||||
{
|
||||
import mx.core.Application;
|
||||
import mx.controls.Alert;
|
||||
import flash.events.MouseEvent;
|
||||
|
||||
public class CustomApp extends Application
|
||||
{
|
||||
|
||||
function CustomApp()
|
||||
{
|
||||
}
|
||||
|
||||
public function butterCup(event:MouseEvent):void
|
||||
{
|
||||
var msg:String = "clicked" + event;
|
||||
trace(msg);
|
||||
Alert.show(msg);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
5
PracticingFlex/custom-03d1-datagrid/Snarf.mxml
Normal file
@ -0,0 +1,5 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<loc:CustomApp xmlns:mx="http://www.adobe.com/2006/mxml"
|
||||
xmlns:loc="*" layout="absolute">
|
||||
<mx:Button id="mutton" label="howdy" click="butterCup(event)" />
|
||||
</loc:CustomApp>
|
@ -0,0 +1,31 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<mx:HBox xmlns:mx="http://www.adobe.com/2006/mxml" width="400" height="100"
|
||||
xmlns:me="components.*" >
|
||||
<mx:Script>
|
||||
<![CDATA[
|
||||
private var _data:Object;
|
||||
|
||||
override public function set data(value:Object):void {
|
||||
_data = value;
|
||||
if (data != null) {
|
||||
zip.text = _data.zip;
|
||||
city.text = _data.city;
|
||||
temp.text = _data.temp + 'F';
|
||||
img.source = _data.imgsource;
|
||||
}
|
||||
}
|
||||
|
||||
override public function get data():Object {
|
||||
return _data;
|
||||
}
|
||||
|
||||
]]>
|
||||
</mx:Script>
|
||||
|
||||
<mx:Image id="img" />
|
||||
<mx:VBox height="100%">
|
||||
<mx:Text id="zip" />
|
||||
<mx:Text id="city" />
|
||||
<mx:Text id="temp" />
|
||||
</mx:VBox>
|
||||
</mx:HBox>
|
57
PracticingFlex/custom-03d2-item-renderers/WeatherApp.as
Normal file
@ -0,0 +1,57 @@
|
||||
package
|
||||
{
|
||||
import mx.collections.ArrayCollection;
|
||||
import mx.controls.TextInput;
|
||||
import mx.core.Application;
|
||||
import mx.rpc.events.ResultEvent;
|
||||
import mx.rpc.http.HTTPService;
|
||||
|
||||
public class WeatherApp extends Application
|
||||
{
|
||||
|
||||
function WeatherApp()
|
||||
{
|
||||
}
|
||||
|
||||
[Bindable]
|
||||
public var myResult:XML;
|
||||
|
||||
[Bindable]
|
||||
public var weatherObject:Object;
|
||||
|
||||
[Bindable]
|
||||
public var listContents:ArrayCollection;
|
||||
|
||||
public var weatherService:HTTPService;
|
||||
public var zip:TextInput;
|
||||
|
||||
public namespace yweather = "http://xml.weather.yahoo.com/ns/rss/1.0";
|
||||
use namespace yweather;
|
||||
|
||||
public function requestWeather():void {
|
||||
weatherService.cancel();
|
||||
var params:Object = new Object();
|
||||
params.p = zip.text;
|
||||
weatherService.send(params);
|
||||
}
|
||||
|
||||
public function resultHandler(event:ResultEvent):void {
|
||||
myResult = XML(event.result);
|
||||
weatherObject = new Object();
|
||||
weatherObject.zip = zip.text;
|
||||
weatherObject.city = myResult.channel.yweather::location.@city;
|
||||
weatherObject.temp = myResult.channel.item.yweather::condition.@temp;
|
||||
weatherObject.imgsource = parseImageUrl(myResult.channel.item.description);
|
||||
|
||||
var a:Array = new Array(weatherObject);
|
||||
listContents = new ArrayCollection(a);
|
||||
}
|
||||
|
||||
public function parseImageUrl(fromHtml:XMLList):String {
|
||||
var pattern:RegExp = /img src="(.+?)"/;
|
||||
var results:Array = pattern.exec(fromHtml);
|
||||
var imageURL:String = results[1]; // backreference 1 from pattern
|
||||
return imageURL;
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,45 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<loc:WeatherApp xmlns:mx="http://www.adobe.com/2006/mxml"
|
||||
xmlns:loc="*"
|
||||
backgroundColor="#FFFFFF"
|
||||
backgroundAlpha="0"
|
||||
horizontalAlign="left"
|
||||
verticalGap="15" horizontalGap="15">
|
||||
|
||||
<mx:HTTPService
|
||||
id="weatherService"
|
||||
url="http://weather.yahooapis.com/forecastrss"
|
||||
resultFormat="e4x"
|
||||
result="resultHandler(event)" />
|
||||
|
||||
<mx:Text text="1. Basic Form + HTTPService Retrieval" />
|
||||
|
||||
<mx:Form width="400">
|
||||
<mx:FormItem label="Zip Code">
|
||||
<mx:TextInput id="zip" />
|
||||
<mx:Button label="Get Weather"
|
||||
click="requestWeather()" />
|
||||
</mx:FormItem>
|
||||
</mx:Form>
|
||||
|
||||
<mx:Text text="Raw RSS Feed" />
|
||||
|
||||
<mx:TextArea id="resultFld"
|
||||
text="{myResult}"
|
||||
width="400" height="152" />
|
||||
|
||||
<mx:Text text="1. List w/ Image Item Renderer (Drop-In)" />
|
||||
|
||||
<mx:List dataProvider="{listContents}"
|
||||
labelField="imgsource"
|
||||
width="400" height="100"
|
||||
itemRenderer="mx.controls.Image" />
|
||||
|
||||
<mx:Text text="2. List w/ HBoxWeatherDisplay itemRenderer" />
|
||||
|
||||
<mx:List dataProvider="{listContents}"
|
||||
labelField="zip"
|
||||
width="400" height="100"
|
||||
itemRenderer="HBoxWeatherDisplay" />
|
||||
|
||||
</loc:WeatherApp>
|
89
PracticingFlex/custom-03d3-lists/ListApp.as
Normal file
@ -0,0 +1,89 @@
|
||||
package
|
||||
{
|
||||
import flash.events.MouseEvent;
|
||||
import mx.collections.ArrayCollection;
|
||||
import mx.controls.Alert;
|
||||
import mx.controls.Button;
|
||||
import mx.controls.List;
|
||||
import mx.controls.Text;
|
||||
import mx.core.Application;
|
||||
import mx.events.ListEvent;
|
||||
import mx.rpc.events.FaultEvent;
|
||||
import mx.rpc.events.ResultEvent;
|
||||
import mx.rpc.http.HTTPService;
|
||||
|
||||
public class ListApp extends Application
|
||||
{
|
||||
[Bindable]
|
||||
public var employeeList:ArrayCollection = new ArrayCollection();
|
||||
public var employeesService:HTTPService;
|
||||
public var textMessage:Text;
|
||||
public var mylist:List;
|
||||
public var mybutton:Button;
|
||||
|
||||
public static const employeesServiceUrl:String =
|
||||
"http://localhost:18080/employees.xml";
|
||||
|
||||
public function appComplete():void
|
||||
{
|
||||
_initButtonControl();
|
||||
_initListControl();
|
||||
_initEmployeesService();
|
||||
trace(this + " initialized!");
|
||||
}
|
||||
|
||||
private function _initButtonControl():void
|
||||
{
|
||||
trace(this + "._initButtonControl()");
|
||||
mybutton.addEventListener(MouseEvent.CLICK, requestEmployees);
|
||||
}
|
||||
|
||||
private function _initListControl():void
|
||||
{
|
||||
trace(this + "._initListControl()");
|
||||
mylist.addEventListener(ListEvent.ITEM_CLICK, showMessage);
|
||||
trace(this + ".mylist.dataProvider = " + mylist.dataProvider);
|
||||
}
|
||||
|
||||
private function _initEmployeesService():void
|
||||
{
|
||||
trace(this + "._initEmployeesService()");
|
||||
employeesService = new HTTPService();
|
||||
employeesService.url = employeesServiceUrl;
|
||||
employeesService.method = "GET";
|
||||
employeesService.resultFormat = "object";
|
||||
employeesService.addEventListener("result", resultHandler);
|
||||
employeesService.addEventListener("fault", faultHandler);
|
||||
}
|
||||
|
||||
public function requestEmployees(event:Event):void
|
||||
{
|
||||
trace(this + ".requestEmployees(" + event + ")");
|
||||
employeesService.send();
|
||||
}
|
||||
|
||||
public function resultHandler(event:ResultEvent):void
|
||||
{
|
||||
trace(this + ".resultHandler(" + event + ")");
|
||||
trace(this + " event.result = " + event.result);
|
||||
trace(this + " event.headers = " + event.headers);
|
||||
trace(this + " event.statusCode = " + event.statusCode);
|
||||
trace(this + " event.result.employees = " + event.result.employees);
|
||||
employeeList = event.result.employees.employee as ArrayCollection;
|
||||
// mylist.dataProvider = employeeList;
|
||||
trace(this + ".employeeList = " + employeeList);
|
||||
}
|
||||
|
||||
public function faultHandler(event:FaultEvent):void {
|
||||
var faultstring:String = event.fault.faultString;
|
||||
Alert.show(faultstring);
|
||||
}
|
||||
|
||||
public function showMessage(event:Event):void
|
||||
{
|
||||
textMessage.text = "You selected: " +
|
||||
event.currentTarget.selectedItem.firstName + ' ' +
|
||||
event.currentTarget.selectedItem.lastName;
|
||||
}
|
||||
}
|
||||
}
|
10
PracticingFlex/custom-03d3-lists/ListControl.mxml
Normal file
@ -0,0 +1,10 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<loc:ListApp xmlns:loc="*"
|
||||
xmlns:mx="http://www.adobe.com/2006/mxml"
|
||||
applicationComplete="appComplete();">
|
||||
<mx:Style source="listapp.css" />
|
||||
<mx:Button id="mybutton" label="Return Employees" />
|
||||
<mx:List id="mylist" styleName="basic-list"
|
||||
dataProvider="{employeeList}" labelField="firstName" />
|
||||
<mx:Text id="textMessage" styleName="basic-text" />
|
||||
</loc:ListApp>
|
66
PracticingFlex/custom-03d3-lists/employees.py
Normal file
@ -0,0 +1,66 @@
|
||||
import sys
|
||||
from wsgiref.simple_server import make_server
|
||||
|
||||
|
||||
EMPLOYEES_XML = """\
|
||||
<employees>
|
||||
<employee id="101" code="233">
|
||||
<firstName>Bob</firstName>
|
||||
<lastName>Costas</lastName>
|
||||
</employee>
|
||||
<employee id="102" code="233">
|
||||
<firstName>Bob</firstName>
|
||||
<lastName>Sagat</lastName>
|
||||
</employee>
|
||||
<employee id="103" code="233">
|
||||
<firstName>Harbor</firstName>
|
||||
<lastName>Oaks</lastName>
|
||||
</employee>
|
||||
<employee id="104" code="233">
|
||||
<firstName>Oak</firstName>
|
||||
<lastName>Barrel</lastName>
|
||||
</employee>
|
||||
<employee id="105" code="233">
|
||||
<firstName>Sag</firstName>
|
||||
<lastName>Harbor</lastName>
|
||||
</employee>
|
||||
</employees>
|
||||
"""
|
||||
EMPLOYEES_XML_LEN = str(len(EMPLOYEES_XML))
|
||||
CROSSDOMAIN_XML = """\
|
||||
<cross-domain-policy>
|
||||
<allow-access-from domain="*"/>
|
||||
</cross-domain-policy>
|
||||
"""
|
||||
CROSSDOMAIN_XML_LEN = str(len(CROSSDOMAIN_XML))
|
||||
|
||||
|
||||
def main(sysargs=sys.argv[:]):
|
||||
server = make_server('0.0.0.0', 18080, employees_app)
|
||||
server.serve_forever()
|
||||
return 0
|
||||
|
||||
|
||||
def employees_app(environ, start_response):
|
||||
path_info = environ.get('PATH_INFO', '/').strip(' /')
|
||||
if path_info == 'employees.xml':
|
||||
start_response('200 OK', [
|
||||
('content-type', 'text/xml'),
|
||||
('content-length', EMPLOYEES_XML_LEN),
|
||||
])
|
||||
return [EMPLOYEES_XML]
|
||||
elif path_info == 'crossdomain.xml':
|
||||
start_response('200 OK', [
|
||||
('content-type', 'text/xml'),
|
||||
('content-length', CROSSDOMAIN_XML_LEN),
|
||||
])
|
||||
return [CROSSDOMAIN_XML]
|
||||
else:
|
||||
start_response('404 Not Found', [('content-type', 'text/plain')])
|
||||
return ['sorry charlie']
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
sys.exit(main())
|
||||
|
||||
# vim:filetype=python
|
16
PracticingFlex/custom-03d3-lists/listapp.css
Normal file
@ -0,0 +1,16 @@
|
||||
ListApp {
|
||||
backgroundColor: #ffffff;
|
||||
backgroundAlpha: 0;
|
||||
horizontalAlign: left;
|
||||
verticalGap: 15;
|
||||
horizontalGap: 15;
|
||||
}
|
||||
|
||||
.basic-list {
|
||||
width: 200;
|
||||
height: 200;
|
||||
}
|
||||
|
||||
.basic-text {
|
||||
paddingTop: 20;
|
||||
}
|
37
PracticingFlex/custom-03d4-tilelist/TileListApp.as
Normal file
@ -0,0 +1,37 @@
|
||||
package
|
||||
{
|
||||
import mx.core.Application;
|
||||
import mx.controls.TextInput;
|
||||
import mx.controls.Text;
|
||||
import mx.collections.ArrayCollection;
|
||||
import mx.events.ListEvent;
|
||||
import mx.rpc.events.ResultEvent;
|
||||
import mx.rpc.http.HTTPService;
|
||||
|
||||
public class TileListApp extends Application
|
||||
{
|
||||
[Bindable]
|
||||
public var photoFeed:ArrayCollection = new ArrayCollection();
|
||||
public var searchTerms:TextInput;
|
||||
public var photoService:HTTPService;
|
||||
public var textMessage:Text;
|
||||
|
||||
public function requestPhotos():void {
|
||||
var params:Object = new Object();
|
||||
params.format = 'rss_200_enc';
|
||||
params.tags = searchTerms.text;
|
||||
photoService.send(params);
|
||||
}
|
||||
|
||||
public function photoHandler(event:ResultEvent):void {
|
||||
photoFeed = event.result.rss.channel.item as ArrayCollection;
|
||||
}
|
||||
|
||||
//show text message when user selects image
|
||||
public function showMessage(event:Event):void {
|
||||
textMessage.text = "You selected: " +
|
||||
event.currentTarget.selectedItem.title + "\nUploaded by: " +
|
||||
event.currentTarget.selectedItem.credit;
|
||||
}
|
||||
}
|
||||
}
|
38
PracticingFlex/custom-03d4-tilelist/TileListExample.mxml
Normal file
@ -0,0 +1,38 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<loc:TileListApp xmlns:mx="http://www.adobe.com/2006/mxml"
|
||||
styleName="basic-app" xmlns:loc="*">
|
||||
<mx:Style source="tilelist.css" />
|
||||
|
||||
<!-- photo service -->
|
||||
<mx:HTTPService id="photoService"
|
||||
url="http://api.flickr.com/services/feeds/photos_public.gne"
|
||||
result="photoHandler(event)" />
|
||||
|
||||
<!-- search -->
|
||||
<mx:Form>
|
||||
<mx:FormItem label="Search Term" direction="horizontal">
|
||||
<mx:TextInput id="searchTerms" />
|
||||
<mx:Button label="Search" click="requestPhotos()" />
|
||||
</mx:FormItem>
|
||||
</mx:Form>
|
||||
|
||||
<!-- result, data is passed to the itemRenderer by Flex
|
||||
through the data property -->
|
||||
<mx:TileList id="mylist"
|
||||
styleName="basic-style-list"
|
||||
labelField="thumbnail"
|
||||
dataProvider="{photoFeed}"
|
||||
itemClick="showMessage(event)">
|
||||
<mx:itemRenderer>
|
||||
<mx:Component>
|
||||
<mx:VBox styleName="basic-vbox">
|
||||
<mx:Image styleName="basic-image"
|
||||
source="{data.thumbnail.url}"/>
|
||||
</mx:VBox>
|
||||
</mx:Component>
|
||||
</mx:itemRenderer>
|
||||
</mx:TileList>
|
||||
|
||||
<mx:Text id="textMessage" styleName="basic-text" />
|
||||
|
||||
</loc:TileListApp>
|
39
PracticingFlex/custom-03d4-tilelist/tilelist.css
Normal file
@ -0,0 +1,39 @@
|
||||
.basic-app {
|
||||
backgroundColor: #ffffff;
|
||||
backgroundAlpha: 0;
|
||||
horizontalAlign: left;
|
||||
verticalGap: 15;
|
||||
horizontalGap: 15;
|
||||
}
|
||||
|
||||
.basic-style-list {
|
||||
width: 600;
|
||||
height: 200;
|
||||
paddingTop: 25;
|
||||
left: 5;
|
||||
}
|
||||
|
||||
|
||||
.basic-form-item {
|
||||
direction: horizontal;
|
||||
}
|
||||
|
||||
|
||||
.basic-vbox {
|
||||
width: 125;
|
||||
height: 125;
|
||||
paddingRight: 5;
|
||||
paddingLeft: 5;
|
||||
horizontalAlign: center;
|
||||
}
|
||||
|
||||
|
||||
.basic-image {
|
||||
height: 75;
|
||||
width: 75;
|
||||
}
|
||||
|
||||
|
||||
.basic-text {
|
||||
paddingTop: 20;
|
||||
}
|
5
PracticingFlex/custom-03g1-debugging/Debugging.mxml
Normal file
@ -0,0 +1,5 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<me:DebuggingApp
|
||||
xmlns:mx="http://www.adobe.com/2006/mxml"
|
||||
layout="absolute"
|
||||
xmlns:me="me.*" />
|
37
PracticingFlex/custom-03g1-debugging/me/DebuggingApp.as
Normal file
@ -0,0 +1,37 @@
|
||||
package me
|
||||
{
|
||||
//namespace me = "me.*";
|
||||
import mx.core.Application;
|
||||
import mx.controls.Alert;
|
||||
import mx.controls.Button;
|
||||
|
||||
import flash.events.Event;
|
||||
import flash.events.MouseEvent;
|
||||
|
||||
public class DebuggingApp extends Application
|
||||
{
|
||||
public var clickButton:Button;
|
||||
|
||||
public function DebuggingApp():void
|
||||
{
|
||||
this.addEventListener("creationComplete", initApp);
|
||||
clickButton = new Button();
|
||||
clickButton.label = "Click Me";
|
||||
clickButton.addEventListener("click", showAlert);
|
||||
this.addChild(clickButton);
|
||||
}
|
||||
|
||||
public function showAlert(event:MouseEvent):void
|
||||
{
|
||||
Alert.show('Hello from Flex');
|
||||
trace("Clickety Click! -> " + event);
|
||||
}
|
||||
|
||||
public function initApp(event:Event):void
|
||||
{
|
||||
trace("Hello from Flex Debugging!");
|
||||
var myVar:Number = 9;
|
||||
trace("The value of myVar is " + myVar);
|
||||
}
|
||||
}
|
||||
}
|
18
PracticingFlex/custom-03g1-debugging/me/tests/TestSuite.as
Normal file
@ -0,0 +1,18 @@
|
||||
package me.tests
|
||||
{
|
||||
import me.tests.cases.TestCase01;
|
||||
|
||||
import mx.core.Application;
|
||||
import org.flexunit.Assert;
|
||||
|
||||
[Suite]
|
||||
[RunWith("org.flexunit.runners.Suite")]
|
||||
public class TestSuite extends Application
|
||||
{
|
||||
public var t1:TestCase01;
|
||||
|
||||
public function TestSuite():void
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,17 @@
|
||||
package me.tests.cases
|
||||
{
|
||||
import org.flexunit.Assert;
|
||||
|
||||
public class TestCase01
|
||||
{
|
||||
public function TestCase01():void
|
||||
{
|
||||
}
|
||||
|
||||
[Test]
|
||||
public function testMathIsRealistic():void
|
||||
{
|
||||
Assert.assertEquals(12, 2 * 6);
|
||||
}
|
||||
}
|
||||
}
|
190
PracticingFlex/mkbuildxml.py
Executable file
@ -0,0 +1,190 @@
|
||||
#!/usr/bin/env python
|
||||
from __future__ import print_function
|
||||
|
||||
import os
|
||||
import re
|
||||
import sys
|
||||
import glob
|
||||
from io import BytesIO
|
||||
from fnmatch import fnmatch
|
||||
from itertools import ifilter
|
||||
from os.path import join as pathjoin, relpath, dirname, \
|
||||
abspath, basename, splitext, sep as pathsep
|
||||
|
||||
import lxml.etree as ET
|
||||
|
||||
|
||||
HERE = dirname(abspath(__file__))
|
||||
AUTOGEN_WARNING = ('<!-- ******** AUTOGENERATED by {0} ' +
|
||||
('*' * 20) + '-->').format(basename(sys.argv[0]))
|
||||
|
||||
ROOT = ''.join([_line.strip() for _line in """\
|
||||
<project name="{PROJECT_NAME}" basedir="." default="build">
|
||||
<property environment="env" />
|
||||
<property name="FLEX_HOME" value="${{env.FLEX_HOME}}" />
|
||||
<property name="FLEXUNIT_HOME" value="${{env.FLEXUNIT_HOME}}" />
|
||||
<taskdef resource="flexTasks.tasks" """
|
||||
"""classpath="${{env.FLEX_HOME}}/ant/lib/flexTasks.jar" />
|
||||
<target name="build" />
|
||||
<target name="clean">
|
||||
<delete>
|
||||
<fileset dir="${{basedir}}" casesensitive="yes">
|
||||
<patternset id="swf.files">
|
||||
<include name="**/*.swf" />
|
||||
</patternset>
|
||||
<patternset id="swf.files">
|
||||
<include name="**/*.swc" />
|
||||
</patternset>
|
||||
</fileset>
|
||||
</delete>
|
||||
</target>
|
||||
</project>
|
||||
""".splitlines() if _line.strip()])
|
||||
|
||||
|
||||
def main(sysargs=sys.argv[:]):
|
||||
build_xml = pathjoin(HERE, 'build.xml')
|
||||
os.chmod(build_xml, 0600)
|
||||
buildxml_maker = \
|
||||
BuildXMLMaker(project_name=sysargs[1], outstream=open(build_xml, 'wb'))
|
||||
buildxml_maker.make()
|
||||
os.chmod(build_xml, 0444)
|
||||
return 0
|
||||
|
||||
|
||||
class BuildXMLMaker(object):
|
||||
_to_glob = (
|
||||
pathjoin(HERE, '[0-9]*-*', '*.mxml'),
|
||||
pathjoin(HERE, 'custom-*', '*.mxml'),
|
||||
)
|
||||
_source_fileexts = ('.mxml', '.as', '.css')
|
||||
|
||||
def __init__(self, project_name='%PROJECT%', outstream=sys.stdout):
|
||||
self.outstream = outstream
|
||||
self.targets = {'compc': {}, 'mxmlc': {}}
|
||||
self.tree = ET.parse(BytesIO(ROOT.format(PROJECT_NAME=project_name)))
|
||||
self.root = self.tree.getroot()
|
||||
self.build = self.tree.xpath('//target[@name="build"]')[0]
|
||||
|
||||
def make(self):
|
||||
self._glob_for_top_level_mxml_targets()
|
||||
self._find_test_suite_targets()
|
||||
self._write_out_targets()
|
||||
|
||||
def _glob_for_top_level_mxml_targets(self):
|
||||
for pattern in self._to_glob:
|
||||
for mxml in glob.glob(pattern):
|
||||
self._add_target_from_mxml(mxml)
|
||||
|
||||
def _find_test_suite_targets(self):
|
||||
for dirpath, dirnames, filenames in os.walk(HERE):
|
||||
filter_generated_dirs(dirnames)
|
||||
for filename in filenames:
|
||||
if is_test_suite(filename):
|
||||
test_suite = pathjoin(dirpath, filename)
|
||||
self._add_target_from_test_suite(test_suite)
|
||||
|
||||
def _add_target_from_test_suite(self, test_suite):
|
||||
rel_class = relpath(test_suite, HERE)
|
||||
self.targets['compc'][rel_class] = {}
|
||||
|
||||
def _add_target_from_mxml(self, mxml):
|
||||
rel_mxml = relpath(mxml, HERE)
|
||||
self.targets['mxmlc'][rel_mxml] = {} #dict(sources='')
|
||||
self._add_deps_from_alt_source_file_extensions(rel_mxml)
|
||||
|
||||
def _add_deps_from_alt_source_file_extensions(self, rel_mxml):
|
||||
basedir = dirname(rel_mxml)
|
||||
# sources = self.targets['mxmlc'][rel_mxml]['sources']
|
||||
|
||||
for dirpath, dirnames, filenames in os.walk(basedir):
|
||||
filter_generated_dirs(dirnames)
|
||||
filter_test_suitees(filenames)
|
||||
for filename in filenames:
|
||||
if ext(filename) in self._source_fileexts:
|
||||
rel_source = relpath(pathjoin(dirpath, filename), HERE)
|
||||
# sources += (' ' + rel_source)
|
||||
|
||||
def _write_out_targets(self):
|
||||
for mxml in sorted(self.targets['mxmlc'].iterkeys()):
|
||||
rel_target = './' + mxml.lstrip('./')
|
||||
attrs = dict(file=rel_target, as3='true')
|
||||
attrs.update(self.targets['mxmlc'][mxml])
|
||||
ET.SubElement(self.build, 'mxmlc', **attrs)
|
||||
|
||||
for as3 in sorted(self.targets['compc'].iterkeys()):
|
||||
rel_target = './' + as3.lstrip('./')
|
||||
as_swf = re.sub('(.*).as$', '\\1.swf', rel_target)
|
||||
as_class = re.sub('(.*).as$', '\\1', rel_target).replace('/', '.')
|
||||
class_parts = as_class.strip('./').split('.')
|
||||
as_class = '.'.join(class_parts[1:])
|
||||
source_path_dir = './' + '/'.join(class_parts[:1])
|
||||
attrs = {'output': as_swf, 'include-classes': as_class}
|
||||
attrs.update(self.targets['compc'][as3])
|
||||
compc_element = ET.SubElement(self.build, 'compc', **attrs)
|
||||
ET.SubElement(compc_element, 'sp',
|
||||
**{'path-element': source_path_dir})
|
||||
library_path = ET.SubElement(compc_element, 'l',
|
||||
**{'dir': '${FLEXUNIT_HOME}', 'append': 'yes'})
|
||||
|
||||
print(ET.tostring(self.root, pretty_print=True),
|
||||
file=self.outstream)
|
||||
|
||||
def _get_deps_for_target(self, target):
|
||||
deps = []
|
||||
for dep in reversed(sorted(list(self.targets[target]), key=ext)):
|
||||
deps.append(dep)
|
||||
return deps
|
||||
|
||||
def _get_primary_dep(self, target, deps):
|
||||
primary_dep = deps[0]
|
||||
|
||||
for dependency in deps:
|
||||
if fnmatch(target, namebase(dependency) + '.*'):
|
||||
primary_dep = dependency
|
||||
|
||||
return primary_dep
|
||||
|
||||
def _get_pattern_rule_kwargs(self, primary_dep, target):
|
||||
ret = dict(
|
||||
primary_dep=primary_dep,
|
||||
parent_dir=dirname(primary_dep),
|
||||
package_base=primary_dep.strip('./').split(pathsep)[0],
|
||||
target=target,
|
||||
flexunit=FLEXUNIT
|
||||
)
|
||||
return ret
|
||||
|
||||
|
||||
def ext(filename):
|
||||
return splitext(filename)[-1]
|
||||
|
||||
|
||||
def namebase(filename):
|
||||
return splitext(filename)[0]
|
||||
|
||||
|
||||
def filter_generated_dirs(dirnames):
|
||||
for i, directory in enumerate(dirnames[:]):
|
||||
if directory == 'generated':
|
||||
dirnames[i] = None
|
||||
dirnames[:] = list(ifilter(None, dirnames))
|
||||
|
||||
|
||||
def filter_test_suitees(filenames):
|
||||
for i, filename in enumerate(filenames[:]):
|
||||
if is_test_suite(filename):
|
||||
filenames[i] = None
|
||||
filenames[:] = list(ifilter(None, filenames))
|
||||
|
||||
|
||||
def is_test_suite(filename):
|
||||
base_filename = basename(filename)
|
||||
return base_filename.startswith('TestSuite') and \
|
||||
ext(filename) == '.as'
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
sys.exit(main())
|
||||
|
||||
# vim:filetype=python
|