diff --git a/build_and_copy.sh b/build_and_copy.sh new file mode 100644 index 0000000..bc37201 --- /dev/null +++ b/build_and_copy.sh @@ -0,0 +1,5 @@ +#!/bin/sh + +./build.py -t all +cp org/flex_pilot/FlexPilot.swf tests +(cd tests && ./build.py -t all) diff --git a/src/org/flex_pilot/FPController.as b/src/org/flex_pilot/FPController.as index 25b4a6d..5b4c7b6 100644 --- a/src/org/flex_pilot/FPController.as +++ b/src/org/flex_pilot/FPController.as @@ -23,6 +23,7 @@ package org.flex_pilot { import flash.display.DisplayObject; import flash.display.DisplayObjectContainer; import mx.events.* + import mx.controls.DateField; public class FPController { public function FPController():void {} @@ -325,7 +326,14 @@ package org.flex_pilot { // Do nothing } } - + + public static function date(params:Object):void { + // Look up the item to write to + var obj:* = FPLocator.lookupDisplayObject(params); + obj.selectedDate = DateField.stringToDate(params.date, "MM/DD/YYYY"); + Events.triggerCalendarLayoutChangeEvent(obj); + } + public static function getTextValue(params:Object):String { // Look up the item where we want to get the property var obj:* = FPLocator.lookupDisplayObject(params); diff --git a/src/org/flex_pilot/FPRecorder.as b/src/org/flex_pilot/FPRecorder.as index 6e3e5b9..ba7225d 100644 --- a/src/org/flex_pilot/FPRecorder.as +++ b/src/org/flex_pilot/FPRecorder.as @@ -28,8 +28,10 @@ package org.flex_pilot { import flash.events.KeyboardEvent; import flash.external.ExternalInterface; import mx.events.ListEvent; + import mx.events.CalendarLayoutChangeEvent; import mx.controls.ComboBox; import mx.controls.List; + import mx.controls.DateField; import mx.core.IRawChildrenContainer; public class FPRecorder { @@ -69,6 +71,10 @@ package org.flex_pilot { FPRecorder.listItems.push(item); item.addEventListener(ListEvent.CHANGE, FPRecorder.handleEvent); } + if (item is DateField) { + FPRecorder.listItems.push(item); + item.addEventListener(CalendarLayoutChangeEvent.CHANGE, FPRecorder.handleEvent); + } if (item is DisplayObjectContainer) { if (item is IRawChildrenContainer) { count = item.rawChildren.numChildren; @@ -98,7 +104,6 @@ package org.flex_pilot { stage.addEventListener(MouseEvent.DOUBLE_CLICK, FPRecorder.handleEvent); stage.addEventListener(TextEvent.LINK, FPRecorder.handleEvent); stage.addEventListener(KeyboardEvent.KEY_DOWN, FPRecorder.handleEvent); - FPRecorder.running = true; } @@ -109,17 +114,28 @@ package org.flex_pilot { stage.removeEventListener(MouseEvent.DOUBLE_CLICK, FPRecorder.handleEvent); stage.removeEventListener(TextEvent.LINK, FPRecorder.handleEvent); stage.removeEventListener(KeyboardEvent.KEY_DOWN, FPRecorder.handleEvent); + var list:Array = FPRecorder.listItems; for each (var item:* in list) { - item.removeEventListener(ListEvent.CHANGE, FPRecorder.handleEvent); + if (item is ComboBox || item is List) { + item.removeEventListener(ListEvent.CHANGE, FPRecorder.handleEvent); + } + if (item is DateField) { + item.removeEventListener(CalendarLayoutChangeEvent.CHANGE, FPRecorder.handleEvent); + } } } private static function handleEvent(e:*):void { + if (!FPRecorder.running) { return; } var targ:* = e.target; var _this:* = FPRecorder; var chain:String = FPLocator.generateLocator(targ); - + + if (e.target is DateField) { + _this.generateAction("date", targ, {date: DateField.dateToString(e.newDate, "MM/DD/YYYY")}); + return; + } switch (e.type) { // Keyboard input -- append to the stored string reference case KeyboardEvent.KEY_DOWN: @@ -239,9 +255,15 @@ package org.flex_pilot { case 'select': var sel:* = targ.selectedItem; // Can set a custom label field via labelField attr - var labelField:String = targ.labelField ? - targ.labelField : 'label'; - params.label = sel[labelField]; + try { + var labelField:String = targ.labelField ? + targ.labelField : 'label'; + params.label = sel[labelField]; + } + catch (e:Error) { + var idx:* = targ.selectedIndex; + params.index = idx; + } break; case 'type': break; diff --git a/src/org/flex_pilot/FlexPilot.as b/src/org/flex_pilot/FlexPilot.as index 894a604..e1f305c 100644 --- a/src/org/flex_pilot/FlexPilot.as +++ b/src/org/flex_pilot/FlexPilot.as @@ -16,7 +16,7 @@ Copyright 2009, Matthew Eernisse (mde@fleegix.org) and Slide, Inc. package org.flex_pilot { import com.adobe.serialization.json.JSON; - + import org.flex_pilot.astest.ASTest; import org.flex_pilot.FPLocator; import org.flex_pilot.FPController; diff --git a/src/org/flex_pilot/events/Events.as b/src/org/flex_pilot/events/Events.as index d7efa82..0a30b3d 100644 --- a/src/org/flex_pilot/events/Events.as +++ b/src/org/flex_pilot/events/Events.as @@ -146,6 +146,7 @@ package org.flex_pilot.events { p.ctrlKey, p.altKey, p.shiftKey); obj.dispatchEvent(ev); } + public static function triggerListEvent(obj:*, type:String, ...args):void { // AS3 Object keys don't iterate in insertion order @@ -163,6 +164,20 @@ package org.flex_pilot.events { p.itemRenderer); obj.dispatchEvent(ev); } + + public static function triggerCalendarLayoutChangeEvent(obj:*, + ...args):void { + var defaults:Array = [ + ['bubbles', false], // Don't override -- the real one doesn't bubble + ['cancelable', false], + ['newDate', null], + ['triggerEvent', new Event("change")] + ]; + var p:Object = Events.normalizeParams(defaults, args); + var ev:CalendarLayoutChangeEvent = new CalendarLayoutChangeEvent("change", + p.bubbles, p.cancelable, p.newDate, p.triggerEvent); + obj.dispatchEvent(ev); + } } } diff --git a/tests/GetDocumentName.as b/tests/GetDocumentName.as new file mode 100644 index 0000000..c5eec7b --- /dev/null +++ b/tests/GetDocumentName.as @@ -0,0 +1,106 @@ +package +{ + + import flash.display.DisplayObject; + import flash.events.MouseEvent; + + import mx.containers.ControlBar; + import mx.containers.Panel; + import mx.containers.VBox; + import mx.controls.Button; + import mx.controls.Label; + import mx.controls.Spacer; + import mx.controls.TextInput; + import mx.managers.PopUpManager; + import mx.styles.StyleManager; + + public class GetDocumentName + { + private var panel:Panel; + private var parent:DisplayObject; + private var textInput:TextInput; + + + public function GetDocumentName(parent:DisplayObject) : void + { + var vb:VBox = new VBox(); + vb.percentWidth = 100; + var label:Label = new Label(); + var subHeader:Label = new Label(); + textInput = new TextInput(); + + var cb:ControlBar = new ControlBar(); + cb.percentWidth = 100; + var s:Spacer = new Spacer(); + var b1:Button = new Button(); + var b2:Button = new Button(); + + this.parent = parent; + + s.width = 100; + + textInput.maxChars = 50; + textInput.percentWidth = 100; + textInput.automationName = "modalSaveCancelButton"; + + b1.label = "Save"; + b1.addEventListener(MouseEvent.CLICK, setName); + b1.automationName = "modalSaveSaveButton"; + b1.width = 80; + b2.label = "Cancel"; + b2.automationName = "modalSaveCancelButton"; + b2.addEventListener(MouseEvent.CLICK, closePopUp); + b2.width = 80; + + cb.addChild(s); + cb.addChild(b2); + cb.addChild(b1); + + label.text = "Project Name:"; + label.percentWidth = 100; + + subHeader.text = "Enter your project name, and then click Save."; + subHeader.percentWidth = 100; + + + vb.setStyle("paddingBottom", 5); + vb.setStyle("paddingLeft", 5); + vb.setStyle("paddingRight", 5); + vb.setStyle("paddingTop", 5); + vb.addChild(subHeader); + vb.addChild(label); + vb.addChild(textInput); + + panel = new Panel(); + panel.title = "Save Your Project"; + panel.width = 300; + panel.height = 175; + panel.addChild(vb); + panel.addChild(cb); + panel.automationName = "modalDialogSave"; + } + + private function setName(evt:MouseEvent):void + { + + PopUpManager.removePopUp(panel); + } + + private function closePopUp(evt:MouseEvent):void + { + PopUpManager.removePopUp(panel); + } + + public function ShowPopUp(defaultName:String="Untitled Project") : void + { + var projName:String; + + PopUpManager.addPopUp(panel, parent, true); + PopUpManager.centerPopUp(panel); + this.textInput.text = defaultName; + this.textInput.selectionBeginIndex = 0; + this.textInput.selectionEndIndex = textInput.length; + this.textInput.setFocus(); + } + } +} \ No newline at end of file diff --git a/tests/TestAccordion.html b/tests/TestAccordion.html new file mode 100644 index 0000000..150d861 --- /dev/null +++ b/tests/TestAccordion.html @@ -0,0 +1,44 @@ + +
+ + +