adding example for 03f2
This commit is contained in:
parent
0c5ccef815
commit
d956f7dd15
9
03f2-code-behind/CodeBehindDisplay.mxml
Normal file
9
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
03f2-code-behind/CodeExample.mxml
Normal file
10
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>
|
105
03f2-code-behind/as_components/ComboBoxCodeBehind.as
Normal file
105
03f2-code-behind/as_components/ComboBoxCodeBehind.as
Normal file
@ -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;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
51
mktargets.py
51
mktargets.py
@ -5,15 +5,16 @@ import os
|
||||
import re
|
||||
import sys
|
||||
import glob
|
||||
from fnmatch import fnmatch
|
||||
from os.path import join as pathjoin, relpath, dirname, \
|
||||
abspath, basename, splitext
|
||||
abspath, basename, splitext
|
||||
|
||||
|
||||
HERE = dirname(abspath(__file__))
|
||||
AUTOGEN_WARNING = ('# ******** AUTOGENERATED by {0} ' +
|
||||
('*' * 20)).format(basename(sys.argv[0]))
|
||||
PATTERN_RULE_MXMLC = \
|
||||
'$(MXMLC) {firstdep} -warnings -l+={parent_dir} -output {target}'
|
||||
'$(MXMLC) {primary_dep} -warnings -l+={parent_dir} -output {target}'
|
||||
|
||||
|
||||
def main(sysargs=sys.argv[:]):
|
||||
@ -53,22 +54,52 @@ class TargetMaker(object):
|
||||
basedir = dirname(rel_mxml)
|
||||
for dirpath, dirnames, filenames in os.walk(basedir):
|
||||
for filename in filenames:
|
||||
if splitext(filename)[-1] in self._source_fileexts:
|
||||
if ext(filename) in self._source_fileexts:
|
||||
rel_source = relpath(pathjoin(dirpath, filename), HERE)
|
||||
self.targets[as_swf].add(rel_source)
|
||||
|
||||
def _write_out_targets(self):
|
||||
print(AUTOGEN_WARNING, file=self.outstream)
|
||||
for target in sorted(self.targets.iterkeys()):
|
||||
deps = list(reversed(sorted(list(self.targets[target]),
|
||||
key=lambda d: splitext(d)[-1])))
|
||||
deps = self._get_deps_for_target(target)
|
||||
primary_dep = self._get_primary_dep(target, deps)
|
||||
pattern_rule_kwargs = \
|
||||
self._get_pattern_rule_kwargs(primary_dep, target)
|
||||
|
||||
print('{target}: {deps}'.format(target=target,
|
||||
deps=' '.join(deps)), file=self.outstream)
|
||||
print('\t' +
|
||||
PATTERN_RULE_MXMLC.format(firstdep=deps[0],
|
||||
parent_dir=dirname(deps[0]),
|
||||
target=target) +
|
||||
'\n\n', file=self.outstream)
|
||||
print('\t' + PATTERN_RULE_MXMLC.format(**pattern_rule_kwargs) +
|
||||
'\n\n', 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),
|
||||
target=target
|
||||
)
|
||||
return ret
|
||||
|
||||
def ext(filename):
|
||||
return splitext(filename)[-1]
|
||||
|
||||
|
||||
def namebase(filename):
|
||||
return splitext(filename)[0]
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
|
26
targets.mk
26
targets.mk
@ -1,6 +1,6 @@
|
||||
# ******** AUTOGENERATED by mktargets.py ********************
|
||||
01-flickr/FlickrRIA.swf: 01-flickr/FlickrThumbnail.mxml 01-flickr/FlickrRIA.mxml
|
||||
$(MXMLC) 01-flickr/FlickrThumbnail.mxml -warnings -l+=01-flickr -output 01-flickr/FlickrRIA.swf
|
||||
$(MXMLC) 01-flickr/FlickrRIA.mxml -warnings -l+=01-flickr -output 01-flickr/FlickrRIA.swf
|
||||
|
||||
|
||||
01-flickr/FlickrThumbnail.swf: 01-flickr/FlickrThumbnail.mxml 01-flickr/FlickrRIA.mxml
|
||||
@ -32,7 +32,7 @@
|
||||
|
||||
|
||||
03a5-local-connections/TaskSender.swf: 03a5-local-connections/BasicTaskReceiver.mxml 03a5-local-connections/TaskSender.mxml
|
||||
$(MXMLC) 03a5-local-connections/BasicTaskReceiver.mxml -warnings -l+=03a5-local-connections -output 03a5-local-connections/TaskSender.swf
|
||||
$(MXMLC) 03a5-local-connections/TaskSender.mxml -warnings -l+=03a5-local-connections -output 03a5-local-connections/TaskSender.swf
|
||||
|
||||
|
||||
03a6-shared-objects/SharedObjectExample.swf: 03a6-shared-objects/SharedObjectExample.mxml
|
||||
@ -60,7 +60,7 @@
|
||||
|
||||
|
||||
03b3-simple-ui-event/Example2.swf: 03b3-simple-ui-event/Example1.mxml 03b3-simple-ui-event/Example2.mxml
|
||||
$(MXMLC) 03b3-simple-ui-event/Example1.mxml -warnings -l+=03b3-simple-ui-event -output 03b3-simple-ui-event/Example2.swf
|
||||
$(MXMLC) 03b3-simple-ui-event/Example2.mxml -warnings -l+=03b3-simple-ui-event -output 03b3-simple-ui-event/Example2.swf
|
||||
|
||||
|
||||
03c1-application-container/Demo.swf: 03c1-application-container/Demo.mxml
|
||||
@ -68,7 +68,7 @@
|
||||
|
||||
|
||||
03c2-box-model/HBoxExample.swf: 03c2-box-model/VBoxExample.mxml 03c2-box-model/VBoxHBoxCombo.mxml 03c2-box-model/HBoxExample.mxml
|
||||
$(MXMLC) 03c2-box-model/VBoxExample.mxml -warnings -l+=03c2-box-model -output 03c2-box-model/HBoxExample.swf
|
||||
$(MXMLC) 03c2-box-model/HBoxExample.mxml -warnings -l+=03c2-box-model -output 03c2-box-model/HBoxExample.swf
|
||||
|
||||
|
||||
03c2-box-model/VBoxExample.swf: 03c2-box-model/VBoxExample.mxml 03c2-box-model/VBoxHBoxCombo.mxml 03c2-box-model/HBoxExample.mxml
|
||||
@ -76,7 +76,7 @@
|
||||
|
||||
|
||||
03c2-box-model/VBoxHBoxCombo.swf: 03c2-box-model/VBoxExample.mxml 03c2-box-model/VBoxHBoxCombo.mxml 03c2-box-model/HBoxExample.mxml
|
||||
$(MXMLC) 03c2-box-model/VBoxExample.mxml -warnings -l+=03c2-box-model -output 03c2-box-model/VBoxHBoxCombo.swf
|
||||
$(MXMLC) 03c2-box-model/VBoxHBoxCombo.mxml -warnings -l+=03c2-box-model -output 03c2-box-model/VBoxHBoxCombo.swf
|
||||
|
||||
|
||||
03c3-canvas-absolute/Example.swf: 03c3-canvas-absolute/Example.mxml
|
||||
@ -116,11 +116,11 @@
|
||||
|
||||
|
||||
03d2-item-renderers/WeatherDisplay.swf: 03d2-item-renderers/HBoxWeatherDisplay.mxml 03d2-item-renderers/WeatherDisplay.mxml
|
||||
$(MXMLC) 03d2-item-renderers/HBoxWeatherDisplay.mxml -warnings -l+=03d2-item-renderers -output 03d2-item-renderers/WeatherDisplay.swf
|
||||
$(MXMLC) 03d2-item-renderers/WeatherDisplay.mxml -warnings -l+=03d2-item-renderers -output 03d2-item-renderers/WeatherDisplay.swf
|
||||
|
||||
|
||||
03d3-lists/HorizontalListControl.swf: 03d3-lists/ListControl.mxml 03d3-lists/HorizontalListControl.mxml
|
||||
$(MXMLC) 03d3-lists/ListControl.mxml -warnings -l+=03d3-lists -output 03d3-lists/HorizontalListControl.swf
|
||||
$(MXMLC) 03d3-lists/HorizontalListControl.mxml -warnings -l+=03d3-lists -output 03d3-lists/HorizontalListControl.swf
|
||||
|
||||
|
||||
03d3-lists/ListControl.swf: 03d3-lists/ListControl.mxml 03d3-lists/HorizontalListControl.mxml
|
||||
@ -140,7 +140,7 @@
|
||||
|
||||
|
||||
03e2-tabbar-linkbar/TabBarDemo.swf: 03e2-tabbar-linkbar/LinkBar.mxml 03e2-tabbar-linkbar/TabBarDemo.mxml
|
||||
$(MXMLC) 03e2-tabbar-linkbar/LinkBar.mxml -warnings -l+=03e2-tabbar-linkbar -output 03e2-tabbar-linkbar/TabBarDemo.swf
|
||||
$(MXMLC) 03e2-tabbar-linkbar/TabBarDemo.mxml -warnings -l+=03e2-tabbar-linkbar -output 03e2-tabbar-linkbar/TabBarDemo.swf
|
||||
|
||||
|
||||
03e3-tabnavigator/Shopping.swf: 03e3-tabnavigator/Shopping.mxml
|
||||
@ -155,6 +155,14 @@
|
||||
$(MXMLC) 03f1-custom-components/MainForm.mxml -warnings -l+=03f1-custom-components -output 03f1-custom-components/MainForm.swf
|
||||
|
||||
|
||||
03f2-code-behind/CodeBehindDisplay.swf: 03f2-code-behind/CodeBehindDisplay.mxml 03f2-code-behind/CodeExample.mxml 03f2-code-behind/as_components/ComboBoxCodeBehind.as
|
||||
$(MXMLC) 03f2-code-behind/CodeBehindDisplay.mxml -warnings -l+=03f2-code-behind -output 03f2-code-behind/CodeBehindDisplay.swf
|
||||
|
||||
|
||||
03f2-code-behind/CodeExample.swf: 03f2-code-behind/CodeBehindDisplay.mxml 03f2-code-behind/CodeExample.mxml 03f2-code-behind/as_components/ComboBoxCodeBehind.as
|
||||
$(MXMLC) 03f2-code-behind/CodeExample.mxml -warnings -l+=03f2-code-behind -output 03f2-code-behind/CodeExample.swf
|
||||
|
||||
|
||||
custom-03d1-datagrid/Snarf.swf: custom-03d1-datagrid/Snarf.mxml custom-03d1-datagrid/CustomApp.as
|
||||
$(MXMLC) custom-03d1-datagrid/Snarf.mxml -warnings -l+=custom-03d1-datagrid -output custom-03d1-datagrid/Snarf.swf
|
||||
|
||||
@ -164,7 +172,7 @@ custom-03d2-item-renderers/HBoxWeatherDisplay.swf: custom-03d2-item-renderers/HB
|
||||
|
||||
|
||||
custom-03d2-item-renderers/WeatherDisplay.swf: custom-03d2-item-renderers/HBoxWeatherDisplay.mxml custom-03d2-item-renderers/WeatherDisplay.mxml custom-03d2-item-renderers/WeatherApp.as
|
||||
$(MXMLC) custom-03d2-item-renderers/HBoxWeatherDisplay.mxml -warnings -l+=custom-03d2-item-renderers -output custom-03d2-item-renderers/WeatherDisplay.swf
|
||||
$(MXMLC) custom-03d2-item-renderers/WeatherDisplay.mxml -warnings -l+=custom-03d2-item-renderers -output custom-03d2-item-renderers/WeatherDisplay.swf
|
||||
|
||||
|
||||
custom-03d3-lists/ListControl.swf: custom-03d3-lists/ListControl.mxml custom-03d3-lists/listapp.css custom-03d3-lists/ListApp.as
|
||||
|
Loading…
Reference in New Issue
Block a user