Repository: flex-asjs Updated Branches: refs/heads/develop b0aec1322 -> 40b5b8cfb
Added example showing how to make a controller bead. Project: http://git-wip-us.apache.org/repos/asf/flex-asjs/repo Commit: http://git-wip-us.apache.org/repos/asf/flex-asjs/commit/40b5b8cf Tree: http://git-wip-us.apache.org/repos/asf/flex-asjs/tree/40b5b8cf Diff: http://git-wip-us.apache.org/repos/asf/flex-asjs/diff/40b5b8cf Branch: refs/heads/develop Commit: 40b5b8cfb39d6e88c7161e2c8ad3a9eb93000d2e Parents: b0aec13 Author: Peter Ent <[email protected]> Authored: Mon May 18 13:23:41 2015 -0400 Committer: Peter Ent <[email protected]> Committed: Mon May 18 13:23:41 2015 -0400 ---------------------------------------------------------------------- examples/RollEventsTest/build.xml | 44 ++++++++++++++ examples/RollEventsTest/src/RollEvent.as | 15 +++++ .../RollEventsTest/src/RollEventController.as | 61 ++++++++++++++++++++ examples/RollEventsTest/src/RollEventsTest.mxml | 51 ++++++++++++++++ examples/build.xml | 2 + 5 files changed, 173 insertions(+) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/40b5b8cf/examples/RollEventsTest/build.xml ---------------------------------------------------------------------- diff --git a/examples/RollEventsTest/build.xml b/examples/RollEventsTest/build.xml new file mode 100644 index 0000000..7b5ed2a --- /dev/null +++ b/examples/RollEventsTest/build.xml @@ -0,0 +1,44 @@ +<?xml version="1.0"?> +<!-- + + Licensed to the Apache Software Foundation (ASF) under one or more + contributor license agreements. See the NOTICE file distributed with + this work for additional information regarding copyright ownership. + The ASF licenses this file to You under the Apache License, Version 2.0 + (the "License"); you may not use this file except in compliance with + the License. You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. + +--> + + +<project name="rolleventstest" default="main" basedir="."> + <property name="FLEXJS_HOME" location="../.."/> + <property name="example" value="RollEventsTest" /> + + <property environment="env"/> + <property file="${FLEXJS_HOME}/build.properties"/> + <property name="FLEX_HOME" value="${FLEXJS_HOME}"/> + <property name="FALCON_HOME" value="${env.FALCON_HOME}"/> + <property name="FALCONJX_HOME" value="${env.FALCONJX_HOME}"/> + <property name="GOOG_HOME" value="${env.GOOG_HOME}"/> + + <include file="${basedir}/../build_example.xml" /> + + <target name="main" depends="clean,build_example.compile,build_example.compilejs" description="Clean build of FlexJSUI.swc"> + </target> + + <target name="clean"> + <delete dir="${basedir}/bin" failonerror="false" /> + <delete dir="${basedir}/bin-debug" failonerror="false" /> + <delete dir="${basedir}/bin-release" failonerror="false" /> + </target> + +</project> http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/40b5b8cf/examples/RollEventsTest/src/RollEvent.as ---------------------------------------------------------------------- diff --git a/examples/RollEventsTest/src/RollEvent.as b/examples/RollEventsTest/src/RollEvent.as new file mode 100644 index 0000000..b334bdb --- /dev/null +++ b/examples/RollEventsTest/src/RollEvent.as @@ -0,0 +1,15 @@ +package +{ + import org.apache.flex.events.Event; + + public class RollEvent extends Event + { + public function RollEvent(type:String, bubbles:Boolean=false, cancelable:Boolean=false) + { + super("rollEvent", bubbles, cancelable); + rollEventType = type; + } + + public var rollEventType:String; + } +} \ No newline at end of file http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/40b5b8cf/examples/RollEventsTest/src/RollEventController.as ---------------------------------------------------------------------- diff --git a/examples/RollEventsTest/src/RollEventController.as b/examples/RollEventsTest/src/RollEventController.as new file mode 100644 index 0000000..47a1dbb --- /dev/null +++ b/examples/RollEventsTest/src/RollEventController.as @@ -0,0 +1,61 @@ +package +{ + import org.apache.flex.core.IBeadController; + import org.apache.flex.core.IStrand; + import org.apache.flex.events.Event; + import org.apache.flex.events.EventDispatcher; + import org.apache.flex.events.IEventDispatcher; + import org.apache.flex.events.MouseEvent; + + [Event("rollEvent")] + + public class RollEventController extends EventDispatcher implements IBeadController + { + public function RollEventController() + { + super(); + } + + private var _strand:IStrand; + + public function set strand(value:IStrand):void + { + _strand = value; + + var dispatcher:IEventDispatcher = value as IEventDispatcher; + + dispatcher.addEventListener(MouseEvent.MOUSE_OVER, handleOver); + dispatcher.addEventListener(MouseEvent.MOUSE_OUT, handleOut); + dispatcher.addEventListener(MouseEvent.MOUSE_DOWN, handleDown); + dispatcher.addEventListener(MouseEvent.MOUSE_UP, handleUp); + } + + private function handleOver(event:MouseEvent):void + { + trace("RolledOver"); + + dispatchEvent(new RollEvent("rollOver")); + } + + private function handleOut(event:MouseEvent):void + { + trace("RolledOut"); + + dispatchEvent(new RollEvent("rollOut")); + } + + private function handleDown(event:MouseEvent):void + { + trace("Detected Down"); + + dispatchEvent(new RollEvent("mouseDown")); + } + + private function handleUp(event:MouseEvent):void + { + trace("Detected Up"); + + dispatchEvent(new RollEvent("mouseUp")); + } + } +} \ No newline at end of file http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/40b5b8cf/examples/RollEventsTest/src/RollEventsTest.mxml ---------------------------------------------------------------------- diff --git a/examples/RollEventsTest/src/RollEventsTest.mxml b/examples/RollEventsTest/src/RollEventsTest.mxml new file mode 100644 index 0000000..38b6ef3 --- /dev/null +++ b/examples/RollEventsTest/src/RollEventsTest.mxml @@ -0,0 +1,51 @@ +<?xml version="1.0" encoding="utf-8"?> +<!--- +// +// Licensed to the Apache Software Foundation (ASF) under one or more +// contributor license agreements. See the NOTICE file distributed with +// this work for additional information regarding copyright ownership. +// The ASF licenses this file to You under the Apache License, Version 2.0 +// (the "License"); you may not use this file except in compliance with +// the License. You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +//////////////////////////////////////////////////////////////////////////////// +--> +<js:Application xmlns:fx="http://ns.adobe.com/mxml/2009" + xmlns:local="*" + xmlns:models="models.*" + xmlns:js="library://ns.apache.org/flexjs/basic" + xmlns:controller="controller.*" + xmlns:views="views.*" + > + + <js:valuesImpl> + <js:SimpleCSSValuesImpl /> + </js:valuesImpl> + + <fx:Style> + @namespace js "library://ns.apache.org/flexjs/basic"; + + .ContainerBackground { + background-color: #FFFFCC; + } + </fx:Style> + + <js:initialView> + <js:ViewBase> + <js:Container x="50" y="50" width="400" height="400" className="ContainerBackground"> + <js:beads> + <local:RollEventController rollEvent="output.text=(event as RollEvent).rollEventType" /> + </js:beads> + </js:Container> + <js:Label id="output" x="500" y="50" text="roll here" /> + </js:ViewBase> + </js:initialView> +</js:Application> http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/40b5b8cf/examples/build.xml ---------------------------------------------------------------------- diff --git a/examples/build.xml b/examples/build.xml index c62b9b6..fc48330 100644 --- a/examples/build.xml +++ b/examples/build.xml @@ -95,6 +95,7 @@ <ant dir="${basedir}/ListsTest"/> <ant dir="${basedir}/MapSearch"/> <ant dir="${basedir}/MobileTrader"/> + <ant dir="${basedir}/RollEventsTest"/> <ant dir="${basedir}/StockQuote"/> <ant dir="${basedir}/ChartExample"/> <ant dir="${basedir}/TodoListSampleApp"/> @@ -133,6 +134,7 @@ <ant dir="${basedir}/ListsTest" target="clean"/> <ant dir="${basedir}/MapSearch" target="clean"/> <ant dir="${basedir}/MobileTrader" target="clean"/> + <ant dir="${basedir}/RollEventsTest" target="clean"/> <ant dir="${basedir}/StatesTest" target="clean"/> <ant dir="${basedir}/StockQuote" target="clean"/> <ant dir="${basedir}/ChartExample" target="clean"/>
