diff --git a/03f1-custom-components/MainForm.mxml b/03f1-custom-components/MainForm.mxml new file mode 100644 index 0000000..a21c678 --- /dev/null +++ b/03f1-custom-components/MainForm.mxml @@ -0,0 +1,16 @@ + + + + + + + + + + + + + diff --git a/03f1-custom-components/com/mycustom/components/TextInputEmail.as b/03f1-custom-components/com/mycustom/components/TextInputEmail.as new file mode 100644 index 0000000..7a21fbf --- /dev/null +++ b/03f1-custom-components/com/mycustom/components/TextInputEmail.as @@ -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; + } + } + } +} diff --git a/mktargets.py b/mktargets.py index a057ea6..7b24179 100755 --- a/mktargets.py +++ b/mktargets.py @@ -5,12 +5,13 @@ import os import re import sys import glob -from os.path import join as pathjoin +from os.path import join as pathjoin, relpath, dirname, \ + abspath, basename, splitext -HERE = os.path.dirname(os.path.abspath(__file__)) +HERE = dirname(abspath(__file__)) AUTOGEN_WARNING = ('# ******** AUTOGENERATED by {0} ' + - ('*' * 20)).format(os.path.basename(sys.argv[0])) + ('*' * 20)).format(basename(sys.argv[0])) PATTERN_RULE_MXMLC = \ '$(MXMLC) {firstdep} -warnings -l+={parent_dir} -output {target}' @@ -29,7 +30,7 @@ class TargetMaker(object): pathjoin(HERE, '[0-9]*-*', '*.mxml'), pathjoin(HERE, 'custom-*', '*.mxml'), ) - _sibling_fileexts = ('.as', '.css') + _source_fileexts = ('.mxml', '.as', '.css') def __init__(self, outstream=sys.stdout): self.outstream = outstream @@ -42,30 +43,30 @@ class TargetMaker(object): self._write_out_targets() def _add_target_from_mxml(self, mxml): - rel_mxml = os.path.relpath(mxml, HERE) + rel_mxml = relpath(mxml, HERE) as_swf = re.sub('(.*)\.mxml$', '\\1.swf', rel_mxml) self.targets[as_swf] = set([rel_mxml]) - self._add_deps_from_sibling_file_extensions(as_swf, rel_mxml) + self._add_deps_from_alt_source_file_extensions(as_swf, rel_mxml) - def _add_deps_from_sibling_file_extensions(self, as_swf, rel_mxml): - for fileext in self._sibling_fileexts: - sibling_glob = re.sub('(.*)/(.*)\.mxml$', '\\1/*' + fileext, - rel_mxml) - for sibling in glob.glob(sibling_glob): - rel_sibling = os.path.relpath(sibling, HERE) - self.targets[as_swf].add(rel_sibling) + def _add_deps_from_alt_source_file_extensions(self, as_swf, rel_mxml): + basedir = dirname(rel_mxml) + for dirpath, dirnames, filenames in os.walk(basedir): + for filename in filenames: + if splitext(filename)[-1] 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: os.path.splitext(d)[-1]))) + key=lambda d: splitext(d)[-1]))) print('{target}: {deps}'.format(target=target, deps=' '.join(deps)), file=self.outstream) print('\t' + PATTERN_RULE_MXMLC.format(firstdep=deps[0], - parent_dir=os.path.dirname(deps[0]), + parent_dir=dirname(deps[0]), target=target) + '\n\n', file=self.outstream) diff --git a/targets.mk b/targets.mk index f832b49..9927802 100644 --- a/targets.mk +++ b/targets.mk @@ -1,9 +1,9 @@ # ******** AUTOGENERATED by mktargets.py ******************** -01-flickr/FlickrRIA.swf: 01-flickr/FlickrRIA.mxml - $(MXMLC) 01-flickr/FlickrRIA.mxml -warnings -l+=01-flickr -output 01-flickr/FlickrRIA.swf +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 -01-flickr/FlickrThumbnail.swf: 01-flickr/FlickrThumbnail.mxml +01-flickr/FlickrThumbnail.swf: 01-flickr/FlickrThumbnail.mxml 01-flickr/FlickrRIA.mxml $(MXMLC) 01-flickr/FlickrThumbnail.mxml -warnings -l+=01-flickr -output 01-flickr/FlickrThumbnail.swf @@ -27,12 +27,12 @@ $(MXMLC) 03a4-external-interface/Main.mxml -warnings -l+=03a4-external-interface -output 03a4-external-interface/Main.swf -03a5-local-connections/BasicTaskReceiver.swf: 03a5-local-connections/BasicTaskReceiver.mxml +03a5-local-connections/BasicTaskReceiver.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/BasicTaskReceiver.swf -03a5-local-connections/TaskSender.swf: 03a5-local-connections/TaskSender.mxml - $(MXMLC) 03a5-local-connections/TaskSender.mxml -warnings -l+=03a5-local-connections -output 03a5-local-connections/TaskSender.swf +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 03a6-shared-objects/SharedObjectExample.swf: 03a6-shared-objects/SharedObjectExample.mxml @@ -55,28 +55,28 @@ $(MXMLC) 03b2-event-propagation/DemoApplication.mxml -warnings -l+=03b2-event-propagation -output 03b2-event-propagation/DemoApplication.swf -03b3-simple-ui-event/Example1.swf: 03b3-simple-ui-event/Example1.mxml +03b3-simple-ui-event/Example1.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/Example1.swf -03b3-simple-ui-event/Example2.swf: 03b3-simple-ui-event/Example2.mxml - $(MXMLC) 03b3-simple-ui-event/Example2.mxml -warnings -l+=03b3-simple-ui-event -output 03b3-simple-ui-event/Example2.swf +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 03c1-application-container/Demo.swf: 03c1-application-container/Demo.mxml $(MXMLC) 03c1-application-container/Demo.mxml -warnings -l+=03c1-application-container -output 03c1-application-container/Demo.swf -03c2-box-model/HBoxExample.swf: 03c2-box-model/HBoxExample.mxml - $(MXMLC) 03c2-box-model/HBoxExample.mxml -warnings -l+=03c2-box-model -output 03c2-box-model/HBoxExample.swf +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 -03c2-box-model/VBoxExample.swf: 03c2-box-model/VBoxExample.mxml +03c2-box-model/VBoxExample.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/VBoxExample.swf -03c2-box-model/VBoxHBoxCombo.swf: 03c2-box-model/VBoxHBoxCombo.mxml - $(MXMLC) 03c2-box-model/VBoxHBoxCombo.mxml -warnings -l+=03c2-box-model -output 03c2-box-model/VBoxHBoxCombo.swf +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 03c3-canvas-absolute/Example.swf: 03c3-canvas-absolute/Example.mxml @@ -95,11 +95,11 @@ $(MXMLC) 03c6-form/CommentForm.mxml -warnings -l+=03c6-form -output 03c6-form/CommentForm.swf -03c7-mxml-vs-as3/WithAs3.swf: 03c7-mxml-vs-as3/WithAs3.mxml +03c7-mxml-vs-as3/WithAs3.swf: 03c7-mxml-vs-as3/WithAs3.mxml 03c7-mxml-vs-as3/WithMxml.mxml $(MXMLC) 03c7-mxml-vs-as3/WithAs3.mxml -warnings -l+=03c7-mxml-vs-as3 -output 03c7-mxml-vs-as3/WithAs3.swf -03c7-mxml-vs-as3/WithMxml.swf: 03c7-mxml-vs-as3/WithMxml.mxml +03c7-mxml-vs-as3/WithMxml.swf: 03c7-mxml-vs-as3/WithMxml.mxml 03c7-mxml-vs-as3/WithAs3.mxml $(MXMLC) 03c7-mxml-vs-as3/WithMxml.mxml -warnings -l+=03c7-mxml-vs-as3 -output 03c7-mxml-vs-as3/WithMxml.swf @@ -111,19 +111,19 @@ $(MXMLC) 03d1-datagrid/DataGridExample.mxml -warnings -l+=03d1-datagrid -output 03d1-datagrid/DataGridExample.swf -03d2-item-renderers/HBoxWeatherDisplay.swf: 03d2-item-renderers/HBoxWeatherDisplay.mxml +03d2-item-renderers/HBoxWeatherDisplay.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/HBoxWeatherDisplay.swf -03d2-item-renderers/WeatherDisplay.swf: 03d2-item-renderers/WeatherDisplay.mxml - $(MXMLC) 03d2-item-renderers/WeatherDisplay.mxml -warnings -l+=03d2-item-renderers -output 03d2-item-renderers/WeatherDisplay.swf +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 -03d3-lists/HorizontalListControl.swf: 03d3-lists/HorizontalListControl.mxml - $(MXMLC) 03d3-lists/HorizontalListControl.mxml -warnings -l+=03d3-lists -output 03d3-lists/HorizontalListControl.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 -03d3-lists/ListControl.swf: 03d3-lists/ListControl.mxml +03d3-lists/ListControl.swf: 03d3-lists/ListControl.mxml 03d3-lists/HorizontalListControl.mxml $(MXMLC) 03d3-lists/ListControl.mxml -warnings -l+=03d3-lists -output 03d3-lists/ListControl.swf @@ -135,12 +135,12 @@ $(MXMLC) 03e1-accordion/Recipe.mxml -warnings -l+=03e1-accordion -output 03e1-accordion/Recipe.swf -03e2-tabbar-linkbar/LinkBar.swf: 03e2-tabbar-linkbar/LinkBar.mxml +03e2-tabbar-linkbar/LinkBar.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/LinkBar.swf -03e2-tabbar-linkbar/TabBarDemo.swf: 03e2-tabbar-linkbar/TabBarDemo.mxml - $(MXMLC) 03e2-tabbar-linkbar/TabBarDemo.mxml -warnings -l+=03e2-tabbar-linkbar -output 03e2-tabbar-linkbar/TabBarDemo.swf +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 03e3-tabnavigator/Shopping.swf: 03e3-tabnavigator/Shopping.mxml @@ -151,16 +151,20 @@ $(MXMLC) 03e4-viewstack/ViewStackDemo.mxml -warnings -l+=03e4-viewstack -output 03e4-viewstack/ViewStackDemo.swf +03f1-custom-components/MainForm.swf: 03f1-custom-components/MainForm.mxml 03f1-custom-components/com/mycustom/components/TextInputEmail.as + $(MXMLC) 03f1-custom-components/MainForm.mxml -warnings -l+=03f1-custom-components -output 03f1-custom-components/MainForm.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 -custom-03d2-item-renderers/HBoxWeatherDisplay.swf: custom-03d2-item-renderers/HBoxWeatherDisplay.mxml custom-03d2-item-renderers/WeatherApp.as +custom-03d2-item-renderers/HBoxWeatherDisplay.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/HBoxWeatherDisplay.swf -custom-03d2-item-renderers/WeatherDisplay.swf: custom-03d2-item-renderers/WeatherDisplay.mxml custom-03d2-item-renderers/WeatherApp.as - $(MXMLC) custom-03d2-item-renderers/WeatherDisplay.mxml -warnings -l+=custom-03d2-item-renderers -output custom-03d2-item-renderers/WeatherDisplay.swf +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 custom-03d3-lists/ListControl.swf: custom-03d3-lists/ListControl.mxml custom-03d3-lists/listapp.css custom-03d3-lists/ListApp.as