http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/c99bd398/frameworks/projects/Effects/as/src/org/apache/flex/states/Transition.as ---------------------------------------------------------------------- diff --git a/frameworks/projects/Effects/as/src/org/apache/flex/states/Transition.as b/frameworks/projects/Effects/as/src/org/apache/flex/states/Transition.as deleted file mode 100644 index 3469417..0000000 --- a/frameworks/projects/Effects/as/src/org/apache/flex/states/Transition.as +++ /dev/null @@ -1,80 +0,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. -// -//////////////////////////////////////////////////////////////////////////////// -package org.apache.flex.states -{ - - [DefaultProperty("effects")] - - /** - * The Transition class holds information describing what to do when - * changing from one state to another. - * - * @langversion 3.0 - * @playerversion Flash 10.2 - * @playerversion AIR 2.6 - * @productversion FlexJS 0.0 - */ - public class Transition - { - /** - * constructor. - * - * @langversion 3.0 - * @playerversion Flash 10.2 - * @playerversion AIR 2.6 - * @productversion FlexJS 0.0 - */ - public function Transition() - { - super(); - } - - /** - * The state or states from which the view is leaving. - * - * @langversion 3.0 - * @playerversion Flash 10.2 - * @playerversion AIR 2.6 - * @productversion FlexJS 0.0 - */ - public var fromState:String; - - /** - * The state or states to which the view is going. - * - * @langversion 3.0 - * @playerversion Flash 10.2 - * @playerversion AIR 2.6 - * @productversion FlexJS 0.0 - */ - public var toState:String; - - - /** - * The list of effects to play - * - * @langversion 3.0 - * @playerversion Flash 10.2 - * @playerversion AIR 2.6 - * @productversion FlexJS 0.0 - */ - public var effects:Array; - - } -}
http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/c99bd398/frameworks/projects/Effects/basic-manifest.xml ---------------------------------------------------------------------- diff --git a/frameworks/projects/Effects/basic-manifest.xml b/frameworks/projects/Effects/basic-manifest.xml deleted file mode 100644 index 64a6c26..0000000 --- a/frameworks/projects/Effects/basic-manifest.xml +++ /dev/null @@ -1,32 +0,0 @@ -<?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. - ---> - - -<componentPackage> - - <component id="Fade" class="org.apache.flex.effects.Fade"/> - <component id="Move" class="org.apache.flex.effects.Move"/> - <component id="Resize" class="org.apache.flex.effects.Resize"/> - <component id="Wipe" class="org.apache.flex.effects.Wipe"/> - <component id="Sequence" class="org.apache.flex.effects.Sequence"/> - <component id="Parallel" class="org.apache.flex.effects.Parallel"/> - <component id="Transition" class="org.apache.flex.states.Transition" /> - -</componentPackage> http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/c99bd398/frameworks/projects/Effects/compile-asjs-config.xml ---------------------------------------------------------------------- diff --git a/frameworks/projects/Effects/compile-asjs-config.xml b/frameworks/projects/Effects/compile-asjs-config.xml deleted file mode 100644 index 8f64d55..0000000 --- a/frameworks/projects/Effects/compile-asjs-config.xml +++ /dev/null @@ -1,79 +0,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. - ---> -<flex-config> - - <compiler> - <accessible>false</accessible> - - <external-library-path> - </external-library-path> - - <mxml> - <children-as-data>true</children-as-data> - </mxml> - <binding-value-change-event>org.apache.flex.events.ValueChangeEvent</binding-value-change-event> - <binding-value-change-event-kind>org.apache.flex.events.ValueChangeEvent</binding-value-change-event-kind> - <binding-value-change-event-type>valueChange</binding-value-change-event-type> - - <keep-as3-metadata> - <name>Bindable</name> - <name>Managed</name> - <name>ChangeEvent</name> - <name>NonCommittingChangeEvent</name> - <name>Transient</name> - </keep-as3-metadata> - - <locale/> - - <library-path> - <!-- asjscompc won't 'link' these classes in, but will list their requires - if these swcs are on the external-library-path then their requires - will not be listed --> - <path-element>../../externs/Core.swc</path-element> - </library-path> - - <source-path> - <path-element>as/src</path-element> - </source-path> - - <namespaces> - <namespace> - <uri>library://ns.apache.org/flexjs/basic</uri> - <manifest>basic-manifest.xml</manifest> - </namespace> - </namespaces> - - <warn-no-constructor>false</warn-no-constructor> - </compiler> - - <include-file> - </include-file> - - <include-classes> - <class>EffectsClasses</class> - </include-classes> - - <include-namespaces> - <uri>library://ns.apache.org/flexjs/basic</uri> - </include-namespaces> - - <target-player>${playerglobal.version}</target-player> - - -</flex-config> http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/c99bd398/frameworks/projects/Effects/compile-config.xml ---------------------------------------------------------------------- diff --git a/frameworks/projects/Effects/compile-config.xml b/frameworks/projects/Effects/compile-config.xml deleted file mode 100644 index a07b904..0000000 --- a/frameworks/projects/Effects/compile-config.xml +++ /dev/null @@ -1,78 +0,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. - ---> -<flex-config> - - <compiler> - <accessible>false</accessible> - - <external-library-path> - <path-element>${env.AIR_HOME}/frameworks/libs/air/airglobal.swc</path-element> - <path-element>../../libs/Core.swc</path-element> - </external-library-path> - - <mxml> - <children-as-data>true</children-as-data> - </mxml> - <binding-value-change-event>org.apache.flex.events.ValueChangeEvent</binding-value-change-event> - <binding-value-change-event-kind>org.apache.flex.events.ValueChangeEvent</binding-value-change-event-kind> - <binding-value-change-event-type>valueChange</binding-value-change-event-type> - - <keep-as3-metadata> - <name>Bindable</name> - <name>Managed</name> - <name>ChangeEvent</name> - <name>NonCommittingChangeEvent</name> - <name>Transient</name> - </keep-as3-metadata> - - <locale/> - - <library-path/> - - <namespaces> - <namespace> - <uri>library://ns.apache.org/flexjs/basic</uri> - <manifest>basic-manifest.xml</manifest> - </namespace> - </namespaces> - - <source-path> - <path-element>as/src</path-element> - </source-path> - - <warn-no-constructor>false</warn-no-constructor> - </compiler> - - <include-file> - <name>js/out/*</name> - <path>js/out/*</path> - </include-file> - - <include-classes> - <class>EffectsClasses</class> - </include-classes> - - <include-namespaces> - <uri>library://ns.apache.org/flexjs/basic</uri> - </include-namespaces> - - <target-player>${playerglobal.version}</target-player> - - -</flex-config> http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/c99bd398/frameworks/projects/Effects/src/main/flex/EffectsClasses.as ---------------------------------------------------------------------- diff --git a/frameworks/projects/Effects/src/main/flex/EffectsClasses.as b/frameworks/projects/Effects/src/main/flex/EffectsClasses.as new file mode 100644 index 0000000..4b529e8 --- /dev/null +++ b/frameworks/projects/Effects/src/main/flex/EffectsClasses.as @@ -0,0 +1,38 @@ +//////////////////////////////////////////////////////////////////////////////// +// +// 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. +// +//////////////////////////////////////////////////////////////////////////////// +package +{ + +/** + * @private + * This class is used to link additional classes into rpc.swc + * beyond those that are found by dependecy analysis starting + * from the classes specified in manifest.xml. + */ +internal class EffectsClasses +{ + import org.apache.flex.core.StatesWithTransitionsImpl; StatesWithTransitionsImpl; + import org.apache.flex.effects.Fade; Fade; + import org.apache.flex.effects.Move; Move; + import org.apache.flex.effects.PlatformWiper; PlatformWiper; + import org.apache.flex.effects.Tween; Tween; +} + +} + http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/c99bd398/frameworks/projects/Effects/src/main/flex/org/apache/flex/core/StatesWithTransitionsImpl.as ---------------------------------------------------------------------- diff --git a/frameworks/projects/Effects/src/main/flex/org/apache/flex/core/StatesWithTransitionsImpl.as b/frameworks/projects/Effects/src/main/flex/org/apache/flex/core/StatesWithTransitionsImpl.as new file mode 100644 index 0000000..9549bc8 --- /dev/null +++ b/frameworks/projects/Effects/src/main/flex/org/apache/flex/core/StatesWithTransitionsImpl.as @@ -0,0 +1,346 @@ +//////////////////////////////////////////////////////////////////////////////// +// +// 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. +// +//////////////////////////////////////////////////////////////////////////////// +package org.apache.flex.core +{ + + import org.apache.flex.core.IParent; + import org.apache.flex.core.IStatesObject; + import org.apache.flex.effects.Effect; + import org.apache.flex.events.Event; + import org.apache.flex.events.EventDispatcher; + import org.apache.flex.events.IEventDispatcher; + import org.apache.flex.events.ValueChangeEvent; + import org.apache.flex.states.AddItems; + import org.apache.flex.states.SetEventHandler; + import org.apache.flex.states.SetProperty; + import org.apache.flex.states.State; + import org.apache.flex.states.Transition; + import org.apache.flex.utils.MXMLDataInterpreter; + + /** + * The StatesWithTransitionsImpl class implements a set of + * view state functionality that includes transitions between states. + * It only supports AddItems and SetProperty and SetEventHandler + * changes at this time. + * + * @flexjsignoreimport org.apache.flex.core.IStatesObject + * + * @langversion 3.0 + * @playerversion Flash 10.2 + * @playerversion AIR 2.6 + * @productversion FlexJS 0.0 + */ + public class StatesWithTransitionsImpl extends EventDispatcher implements IStatesImpl, IBead + { + /** + * Constructor. + * + * @langversion 3.0 + * @playerversion Flash 10.2 + * @playerversion AIR 2.6 + * @productversion FlexJS 0.0 + */ + public function StatesWithTransitionsImpl() + { + super(); + } + + private var _strand:IStrand; + + private var sawInitComplete:Boolean; + + /** + * @copy org.apache.flex.core.IBead#strand + * + * @langversion 3.0 + * @playerversion Flash 10.2 + * @playerversion AIR 2.6 + * @productversion FlexJS 0.0 + */ + public function set strand(value:IStrand):void + { + _strand = value; + IEventDispatcher(_strand).addEventListener("currentStateChange", stateChangeHandler); + IEventDispatcher(_strand).addEventListener("initComplete", initialStateHandler); + } + + /** + * @private + * @flexjsignorecoercion org.apache.flex.core.IStatesObject + */ + private function initialStateHandler(event:org.apache.flex.events.Event):void + { + sawInitComplete = true; + stateChangeHandler(new ValueChangeEvent("currentStateChange", false, false, null, + IStatesObject(_strand).currentState)); + } + + /** + * @private + * @flexjsignorecoercion org.apache.flex.core.IStatesObject + */ + private function stateChangeHandler(event:ValueChangeEvent):void + { + if (!sawInitComplete) + return; + + var doc:IStatesObject = _strand as IStatesObject; + var transitions:Array = doc.transitions; + if (transitions && transitions.length > 0) + { + for each (var t:Transition in transitions) + { + if (t.fromState == "*" || t.fromState == event.oldValue) + { + if (t.toState == "*" || t.toState == event.newValue) + { + transitionEffects = t.effects.slice(); + for each (var e:Effect in transitionEffects) + { + e.captureStartValues(); + } + break; + } + } + } + } + var arr:Array = doc.states; + var oldState:State; + var newState:State; + for each (var s:State in arr) + { + if (s.name == event.oldValue) + { + oldState = s; + break; + } + } + for each (s in arr) + { + if (s.name == event.newValue) + { + newState = s; + break; + } + } + if (oldState) + revert(oldState, newState); + if (newState) + apply(oldState, newState); + if (transitionEffects && transitionEffects.length > 0) + { + for each (e in transitionEffects) + { + e.captureEndValues(); + } + } + var playingTransition:Boolean; + if (transitionEffects && transitionEffects.length > 0) + { + playingTransition = true; + for each (e in transitionEffects) + { + e.addEventListener(Effect.EFFECT_END, effectEndHandler); + e.play(); + } + } + if (!playingTransition) + doc.dispatchEvent(new Event("stateChangeComplete")); + } + + private var transitionEffects:Array; + + /** + * @private + * @flexjsignorecoercion org.apache.flex.core.IStatesObject + */ + private function effectEndHandler(event:Event):void + { + // in case of extraneous calls to effectEndHandler + if (transitionEffects == null) + return; + + var n:int = transitionEffects.length; + for (var i:int = 0; i < n; i++) + { + event.target.removeEventListener(Effect.EFFECT_END, effectEndHandler); + if (transitionEffects[i] == event.target) + transitionEffects.splice(i, 1); + } + if (transitionEffects.length == 0) + { + transitionEffects = null; + var doc:IStatesObject = _strand as IStatesObject; + doc.dispatchEvent(new Event("stateChangeComplete")); + } + } + + private function isItemInState(child:Object, s:State):Boolean + { + if (s == null) return false; + + var arr:Array = s.overrides; + for each (var o:Object in arr) + { + if (o is AddItems) + { + var ai:AddItems = AddItems(o); + if (ai.items == null) + { + ai.items = ai.itemsDescriptor.items as Array; + if (ai.items == null) + { + ai.items = + MXMLDataInterpreter.generateMXMLArray(ai.document, + null, ai.itemsDescriptor.descriptor); + ai.itemsDescriptor.items = ai.items; + } + } + for each (var item:IChild in ai.items) + { + if (item == child) + return true; + } + } + } + return false; + } + + private function revert(s:State, newState:State):void + { + var arr:Array = s.overrides; + for each (var o:Object in arr) + { + if (o is AddItems) + { + var ai:AddItems = AddItems(o); + var childrenAdded:Boolean = false; + for each (var item:IChild in ai.items) + { + if (!isItemInState(item, newState)) + { + var parent:IParent = item.parent as IParent; + parent.removeElement(item); + childrenAdded = true; + } + } + if (childrenAdded && parent is IContainer) + IContainer(parent).childrenAdded(); + } + else if (o is SetProperty) + { + var sp:SetProperty = SetProperty(o); + if (sp.target != null) + sp.document[sp.target][sp.name] = sp.previousValue; + else + sp.document[sp.name] = sp.previousValue; + } + else if (o is SetEventHandler) + { + var seh:SetEventHandler = SetEventHandler(o); + if (seh.target != null) + { + seh.document[seh.target].removeEventListener(seh.name, seh.handlerFunction); + } + else + { + seh.document.removeEventListener(seh.name, seh.handlerFunction); + } + } + } + } + + private function apply(oldState:State, s:State):void + { + var arr:Array = s.overrides; + for each (var o:Object in arr) + { + if (o is AddItems) + { + var ai:AddItems = AddItems(o); + if (ai.items == null) + { + ai.items = ai.itemsDescriptor.items as Array; + if (ai.items == null) + { + ai.items = + MXMLDataInterpreter.generateMXMLArray(ai.document, + null, ai.itemsDescriptor.descriptor); + ai.itemsDescriptor.items = ai.items; + } + } + var childrenAdded:Boolean = false; + for each (var item:Object in ai.items) + { + if (!isItemInState(item, oldState)) + { + var parent:IParent = ai.document as IParent; + if (ai.destination) + parent = parent[ai.destination] as IParent; + if (ai.relativeTo != null) + { + var child:Object = ai.document[ai.relativeTo]; + if (ai.destination) + parent = IChild(child).parent as IParent; + var index:int = parent.getElementIndex(child); + if (ai.position == "after") + index++; + parent.addElementAt(item, index); + childrenAdded = true; + } + else + { + parent.addElement(item); + childrenAdded = true; + } + } + } + if (childrenAdded && parent is IContainer) + IContainer(parent).childrenAdded(); + } + else if (o is SetProperty) + { + var sp:SetProperty = SetProperty(o); + if (sp.target != null) + { + sp.previousValue = sp.document[sp.target][sp.name]; + sp.document[sp.target][sp.name] = sp.value; + } + else + { + sp.previousValue = sp.document[sp.name]; + sp.document[sp.name] = sp.value; + } + } + else if (o is SetEventHandler) + { + var seh:SetEventHandler = SetEventHandler(o); + if (seh.target != null) + { + seh.document[seh.target].addEventListener(seh.name, seh.handlerFunction); + } + else + { + seh.document.addEventListener(seh.name, seh.handlerFunction); + } + } + } + } + } +} \ No newline at end of file http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/c99bd398/frameworks/projects/Effects/src/main/flex/org/apache/flex/effects/Effect.as ---------------------------------------------------------------------- diff --git a/frameworks/projects/Effects/src/main/flex/org/apache/flex/effects/Effect.as b/frameworks/projects/Effects/src/main/flex/org/apache/flex/effects/Effect.as new file mode 100644 index 0000000..7fabe6a --- /dev/null +++ b/frameworks/projects/Effects/src/main/flex/org/apache/flex/effects/Effect.as @@ -0,0 +1,263 @@ +//////////////////////////////////////////////////////////////////////////////// +// +// 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. +// +//////////////////////////////////////////////////////////////////////////////// + +package org.apache.flex.effects +{ + +import org.apache.flex.events.EventDispatcher; + +/** + * Effect is the base class for effects in FlexJS. + * + * @langversion 3.0 + * @playerversion Flash 10.2 + * @playerversion AIR 2.6 + * @productversion FlexJS 0.0 + */ +public class Effect extends EventDispatcher implements IEffect +{ + //-------------------------------------------------------------------------- + // + // Class constants + // + //-------------------------------------------------------------------------- + + /** + * The <code>Effect.EFFECT_END</code> constant defines the value of the + * event object's <code>type</code> property for a <code>effectEnd</code> event. + * + * <p>The properties of the event object have the following values:</p> + * <table class="innertable"> + * <tr><th>Property</th><th>Value</th></tr> + * <tr><td><code>bubbles</code></td><td>false</td></tr> + * <tr><td><code>cancelable</code></td><td>false</td></tr> + * <tr><td><code>currentTarget</code></td><td>The Object that defines the + * event listener that handles the event. For example, if you use + * <code>myButton.addEventListener()</code> to register an event listener, + * myButton is the value of the <code>currentTarget</code>. </td></tr> + * <tr><td><code>target</code></td><td>The Object that dispatched the event; + * it is not always the Object listening for the event. + * Use the <code>currentTarget</code> property to always access the + * Object listening for the event.</td></tr> + * </table> + * + * @eventType effectEnd + * + * @langversion 3.0 + * @playerversion Flash 9 + * @playerversion AIR 1.1 + * @productversion Flex 3 + */ + public static const EFFECT_END:String = "effectEnd"; + + /** + * The <code>Effect.EFFECT_START</code> constant defines the value of the + * event object's <code>type</code> property for a <code>effectStart</code> event. + * + * <p>The properties of the event object have the following values:</p> + * <table class="innertable"> + * <tr><th>Property</th><th>Value</th></tr> + * <tr><td><code>bubbles</code></td><td>false</td></tr> + * <tr><td><code>cancelable</code></td><td>false</td></tr> + * <tr><td><code>currentTarget</code></td><td>The Object that defines the + * event listener that handles the event. For example, if you use + * <code>myButton.addEventListener()</code> to register an event listener, + * myButton is the value of the <code>currentTarget</code>. </td></tr> + * <tr><td><code>target</code></td><td>The Object that dispatched the event; + * it is not always the Object listening for the event. + * Use the <code>currentTarget</code> property to always access the + * Object listening for the event.</td></tr> + * </table> + * + * @eventType effectStart + * + * @langversion 3.0 + * @playerversion Flash 9 + * @playerversion AIR 1.1 + * @productversion Flex 3 + */ + public static const EFFECT_START:String = "effectStart"; + + /** + * The <code>Effect.EFFECT_STOP</code> constant defines the value of the + * event object's <code>type</code> property for a <code>effectStop</code> event. + * + * <p>The properties of the event object have the following values:</p> + * <table class="innertable"> + * <tr><th>Property</th><th>Value</th></tr> + * <tr><td><code>bubbles</code></td><td>false</td></tr> + * <tr><td><code>cancelable</code></td><td>false</td></tr> + * <tr><td><code>currentTarget</code></td><td>The Object that defines the + * event listener that handles the event. For example, if you use + * <code>myButton.addEventListener()</code> to register an event listener, + * myButton is the value of the <code>currentTarget</code>. </td></tr> + * <tr><td><code>target</code></td><td>The Object that dispatched the event; + * it is not always the Object listening for the event. + * Use the <code>currentTarget</code> property to always access the + * Object listening for the event.</td></tr> + * </table> + * + * @eventType effectStop + * + * @langversion 3.0 + * @playerversion Flash 9 + * @playerversion AIR 1.1 + * @productversion Flex 3 + */ + public static const EFFECT_STOP:String = "effectStop"; + + + + //-------------------------------------------------------------------------- + // + // Constructor + // + //-------------------------------------------------------------------------- + + /** + * Constructor. + * + * @langversion 3.0 + * @playerversion Flash 9 + * @playerversion AIR 1.1 + * @productversion Flex 3 + */ + public function Effect() + { + } + + //-------------------------------------------------------------------------- + // + // Properties + // + //-------------------------------------------------------------------------- + + //---------------------------------- + // duration + //---------------------------------- + + private var _duration:Number = 500; + /** + * Duration of the animation, in milliseconds. + * + * @langversion 3.0 + * @playerversion Flash 9 + * @playerversion AIR 1.1 + * @productversion Flex 3 + */ + public function get duration():Number + { + return _duration; + } + public function set duration(value:Number):void + { + _duration = value; + } + + + /** + * Plays the effect in reverse, + * starting from the current position of the effect. + * + * @langversion 3.0 + * @playerversion Flash 9 + * @playerversion AIR 1.1 + * @productversion Flex 3 + */ + public function reverse():void + { + } + + /** + * Pauses the effect until you call the <code>resume()</code> method. + * + * @langversion 3.0 + * @playerversion Flash 9 + * @playerversion AIR 1.1 + * @productversion Flex 3 + */ + public function pause():void + { + } + + /** + * Stops the tween, ending it without dispatching an event or calling + * the Tween's endFunction or <code>onTweenEnd()</code>. + * + * @langversion 3.0 + * @playerversion Flash 9 + * @playerversion AIR 1.1 + * @productversion Flex 3 + */ + public function play():void + { + } + + /** + * Stops the tween, ending it without dispatching an event or calling + * the Tween's endFunction or <code>onTweenEnd()</code>. + * + * @langversion 3.0 + * @playerversion Flash 9 + * @playerversion AIR 1.1 + * @productversion Flex 3 + */ + public function stop():void + { + } + + /** + * Resumes the effect after it has been paused + * by a call to the <code>pause()</code> method. + * + * @langversion 3.0 + * @playerversion Flash 9 + * @playerversion AIR 1.1 + * @productversion Flex 3 + */ + public function resume():void + { + } + + /** + * @copy org.apache.flex.effects.IEffect#captureStartValues + * + * @langversion 3.0 + * @playerversion Flash 9 + * @playerversion AIR 1.1 + * @productversion Flex 3 + */ + public function captureStartValues():void + { + } + + /** + * @copy org.apache.flex.effects.IEffect#captureEndValues + * + * @langversion 3.0 + * @playerversion Flash 9 + * @playerversion AIR 1.1 + * @productversion Flex 3 + */ + public function captureEndValues():void + { + } +} + +} http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/c99bd398/frameworks/projects/Effects/src/main/flex/org/apache/flex/effects/Fade.as ---------------------------------------------------------------------- diff --git a/frameworks/projects/Effects/src/main/flex/org/apache/flex/effects/Fade.as b/frameworks/projects/Effects/src/main/flex/org/apache/flex/effects/Fade.as new file mode 100644 index 0000000..28f0d16 --- /dev/null +++ b/frameworks/projects/Effects/src/main/flex/org/apache/flex/effects/Fade.as @@ -0,0 +1,165 @@ +//////////////////////////////////////////////////////////////////////////////// +// +// 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. +// +//////////////////////////////////////////////////////////////////////////////// + +package org.apache.flex.effects +{ + +import org.apache.flex.core.IDocument; +import org.apache.flex.core.IUIBase; + +/** + * The Fade effect animates a UI component's alpha or opacity. + * + * @langversion 3.0 + * @playerversion Flash 10.2 + * @playerversion AIR 2.6 + * @productversion FlexJS 0.0 + */ +public class Fade extends Tween implements IDocument +{ + + //-------------------------------------------------------------------------- + // + // Constructor + // + //-------------------------------------------------------------------------- + + /** + * Constructor. + * + * @param target An object that will + * have its x and/or y property animated. + * + * @langversion 3.0 + * @playerversion Flash 9 + * @playerversion AIR 1.1 + * @productversion Flex 3 + */ + public function Fade(target:IUIBase = null) + { + super(); + + this.actualTarget = target; + startValue = 0; + endValue = 1; + + listener = this; + } + + //-------------------------------------------------------------------------- + // + // Variables + // + //-------------------------------------------------------------------------- + + /** + * @private + * The document. + */ + private var document:Object; + + /** + * @private + * The target. + */ + private var actualTarget:IUIBase; + + /** + * The target as the String id + * of a widget in an MXML Document. + */ + public var target:String; + + /** + * @private + * The change in alpha. + */ + private var d:Number; + + /** + * @private + * The starting value. + */ + private var start:Number; + + /** + * Starting alpha value. If NaN, the current alpha value is used + */ + public var alphaFrom:Number; + + /** + * Ending alpha value. If NaN, the current alpha value is not changed + */ + public var alphaTo:Number; + + + + //-------------------------------------------------------------------------- + // + // Properties + // + //-------------------------------------------------------------------------- + + + //-------------------------------------------------------------------------- + // + // Methods + // + //-------------------------------------------------------------------------- + + public function setDocument(document:Object, id:String = null):void + { + this.document = document; + } + + /** + * @private + */ + override public function play():void + { + if (target != null) + actualTarget = document[target]; + + if (isNaN(alphaFrom)) + start = actualTarget.alpha; + else + start = alphaFrom; + + if (isNaN(alphaTo)) + d = 0; + else + d = alphaTo - start; + + super.play(); + } + + public function onTweenUpdate(value:Number):void + { + if (d) + actualTarget.alpha = start + value * d; + } + + public function onTweenEnd(value:Number):void + { + if (d) + actualTarget.alpha = start + d; + } +} + +} http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/c99bd398/frameworks/projects/Effects/src/main/flex/org/apache/flex/effects/IEffect.as ---------------------------------------------------------------------- diff --git a/frameworks/projects/Effects/src/main/flex/org/apache/flex/effects/IEffect.as b/frameworks/projects/Effects/src/main/flex/org/apache/flex/effects/IEffect.as new file mode 100644 index 0000000..f5b940c --- /dev/null +++ b/frameworks/projects/Effects/src/main/flex/org/apache/flex/effects/IEffect.as @@ -0,0 +1,136 @@ +//////////////////////////////////////////////////////////////////////////////// +// +// 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. +// +//////////////////////////////////////////////////////////////////////////////// + +package org.apache.flex.effects +{ + +import org.apache.flex.events.IEventDispatcher; + +/** + * IEffect is the lowest-level interface for effects in FlexJS. + * + * @langversion 3.0 + * @playerversion Flash 10.2 + * @playerversion AIR 2.6 + * @productversion FlexJS 0.0 + */ +public interface IEffect extends IEventDispatcher +{ + + + //-------------------------------------------------------------------------- + // + // Properties + // + //-------------------------------------------------------------------------- + + //---------------------------------- + // duration + //---------------------------------- + + /** + * Duration of the animation, in milliseconds. + * + * @langversion 3.0 + * @playerversion Flash 9 + * @playerversion AIR 1.1 + * @productversion Flex 3 + */ + function get duration():Number; + function set duration(value:Number):void; + + + /** + * Plays the effect in reverse, + * starting from the current position of the effect. + * + * @langversion 3.0 + * @playerversion Flash 9 + * @playerversion AIR 1.1 + * @productversion Flex 3 + */ + function reverse():void; + + /** + * Pauses the effect until you call the <code>resume()</code> method. + * + * @langversion 3.0 + * @playerversion Flash 9 + * @playerversion AIR 1.1 + * @productversion Flex 3 + */ + function pause():void; + + /** + * Stops the tween, ending it without dispatching an event or calling + * the Tween's endFunction or <code>onTweenEnd()</code>. + * + * @langversion 3.0 + * @playerversion Flash 9 + * @playerversion AIR 1.1 + * @productversion Flex 3 + */ + function play():void; + + /** + * Stops the tween, ending it without dispatching an event or calling + * the Tween's endFunction or <code>onTweenEnd()</code>. + * + * @langversion 3.0 + * @playerversion Flash 9 + * @playerversion AIR 1.1 + * @productversion Flex 3 + */ + function stop():void; + + /** + * Resumes the effect after it has been paused + * by a call to the <code>pause()</code> method. + * + * @langversion 3.0 + * @playerversion Flash 9 + * @playerversion AIR 1.1 + * @productversion Flex 3 + */ + function resume():void; + + /** + * Tries to compute initial values + * for effect + * + * @langversion 3.0 + * @playerversion Flash 9 + * @playerversion AIR 1.1 + * @productversion Flex 3 + */ + function captureStartValues():void; + + /** + * Tries to compute final values + * for effect + * + * @langversion 3.0 + * @playerversion Flash 9 + * @playerversion AIR 1.1 + * @productversion Flex 3 + */ + function captureEndValues():void; +} + +} http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/c99bd398/frameworks/projects/Effects/src/main/flex/org/apache/flex/effects/Move.as ---------------------------------------------------------------------- diff --git a/frameworks/projects/Effects/src/main/flex/org/apache/flex/effects/Move.as b/frameworks/projects/Effects/src/main/flex/org/apache/flex/effects/Move.as new file mode 100644 index 0000000..2a42b19 --- /dev/null +++ b/frameworks/projects/Effects/src/main/flex/org/apache/flex/effects/Move.as @@ -0,0 +1,240 @@ +//////////////////////////////////////////////////////////////////////////////// +// +// 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. +// +//////////////////////////////////////////////////////////////////////////////// + +package org.apache.flex.effects +{ + +import org.apache.flex.core.IDocument; +import org.apache.flex.core.IUIBase; + +/** + * The Move effect animates a UI component's x or y position. + * + * @langversion 3.0 + * @playerversion Flash 10.2 + * @playerversion AIR 2.6 + * @productversion FlexJS 0.0 + */ +public class Move extends Tween implements IDocument +{ + + //-------------------------------------------------------------------------- + // + // Constructor + // + //-------------------------------------------------------------------------- + + /** + * Constructor. + * + * @param target Object ID or reference to an object that will + * have its x and/or y property animated. + * + * @langversion 3.0 + * @playerversion Flash 9 + * @playerversion AIR 1.1 + * @productversion Flex 3 + */ + public function Move(target:IUIBase = null) + { + super(); + + this.actualTarget = target; + startValue = 0; + endValue = 1; + + listener = this; + } + + //-------------------------------------------------------------------------- + // + // Variables + // + //-------------------------------------------------------------------------- + + /** + * @private + * The document. + */ + private var document:Object; + + /** + * @private + * The actual target. + */ + private var actualTarget:IUIBase; + + /** + * The target as the String id + * of a widget in an MXML Document. + */ + public var target:String; + + /** + * The change in x. + */ + public var xBy:Number; + + /** + * The change in y. + */ + public var yBy:Number; + + /** + * @private + * The starting x. + */ + private var xStart:Number; + + /** + * @private + * The starting y. + */ + private var yStart:Number; + + /** + * @private + * The total change for x. + */ + private var xMove:Number; + + /** + * @private + * The total change for y. + */ + private var yMove:Number; + + /** + * Starting x value. If NaN, the current x value is used + */ + public var xFrom:Number; + + /** + * Ending x value. If NaN, the current x value is not changed + */ + public var xTo:Number; + + /** + * Starting y value. If NaN, the current y value is used + */ + public var yFrom:Number; + + /** + * Ending y value. If NaN, the current y value is not changed + */ + public var yTo:Number; + + + //-------------------------------------------------------------------------- + // + // Properties + // + //-------------------------------------------------------------------------- + + + //-------------------------------------------------------------------------- + // + // Methods + // + //-------------------------------------------------------------------------- + + public function setDocument(document:Object, id:String = null):void + { + this.document = document; + } + + /** + * @private + */ + override public function play():void + { + if (target != null) + actualTarget = document[target]; + + if (isNaN(xFrom)) + xStart = actualTarget.x; + else + xStart = xFrom; + + if (isNaN(xBy)) + { + if (isNaN(xTo)) + xMove = 0; + else + xMove = xTo - xStart; + } + else + xMove = xBy; + + if (isNaN(yFrom)) + yStart = actualTarget.y; + else + yStart = yFrom; + if (isNaN(yBy)) + { + if (isNaN(yTo)) + yMove = 0; + else + yMove = yTo - yStart; + } + else + yMove = yBy; + + super.play(); + } + + public function onTweenUpdate(value:Number):void + { + if (xMove) + actualTarget.x = xStart + value * xMove; + if (yMove) + actualTarget.y = yStart + value * yMove; + } + + public function onTweenEnd(value:Number):void + { + if (xMove) + actualTarget.x = xStart + xMove; + if (yMove) + actualTarget.y = yStart + yMove; + + } + + override public function captureStartValues():void + { + if (target != null) + { + actualTarget = document[target]; + xFrom = actualTarget.x; + yFrom = actualTarget.y; + } + } + + override public function captureEndValues():void + { + if (target != null) + { + actualTarget = document[target]; + xTo = actualTarget.x; + yTo = actualTarget.y; + } + } +} + +} http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/c99bd398/frameworks/projects/Effects/src/main/flex/org/apache/flex/effects/Parallel.as ---------------------------------------------------------------------- diff --git a/frameworks/projects/Effects/src/main/flex/org/apache/flex/effects/Parallel.as b/frameworks/projects/Effects/src/main/flex/org/apache/flex/effects/Parallel.as new file mode 100644 index 0000000..6d08012 --- /dev/null +++ b/frameworks/projects/Effects/src/main/flex/org/apache/flex/effects/Parallel.as @@ -0,0 +1,152 @@ +//////////////////////////////////////////////////////////////////////////////// +// +// 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. +// +//////////////////////////////////////////////////////////////////////////////// + +package org.apache.flex.effects +{ + +import org.apache.flex.core.IDocument; +import org.apache.flex.core.IUIBase; +import org.apache.flex.events.Event; + +[DefaultProperty("children")] + +/** + * The Parallel effect animates set of effects at the + * same time. + * + * @langversion 3.0 + * @playerversion Flash 10.2 + * @playerversion AIR 2.6 + * @productversion FlexJS 0.0 + */ +public class Parallel extends Effect implements IDocument +{ + + //-------------------------------------------------------------------------- + // + // Constructor + // + //-------------------------------------------------------------------------- + + /** + * Constructor. + * + * @langversion 3.0 + * @playerversion Flash 9 + * @playerversion AIR 1.1 + * @productversion Flex 3 + */ + public function Parallel() + { + super(); + } + + //-------------------------------------------------------------------------- + // + // Variables + // + //-------------------------------------------------------------------------- + + /** + * @private + * The document. + */ + private var document:Object; + + /** + * @private + * The target. + */ + private var target:IUIBase; + + /** + * The children. + */ + public var children:Array; + + + + //-------------------------------------------------------------------------- + // + // Properties + // + //-------------------------------------------------------------------------- + + /** + * @private + */ + override public function set duration(value:Number):void + { + var n:int = children.length; + for (var i:int = 0; i < 0; i++) + { + children[i].duration = value; + } + super.duration = value; + } + + //-------------------------------------------------------------------------- + // + // Methods + // + //-------------------------------------------------------------------------- + + public function setDocument(document:Object, id:String = null):void + { + this.document = document; + } + + public function addChild(child:IEffect):void + { + if (!children) + children = [ child ]; + else + children.push(child); + } + + /** + * @private + */ + override public function play():void + { + dispatchEvent(new Event(Effect.EFFECT_START)); + current = 0; + var n:int = children.length; + for (var i:int = 0; i < n; i++) + playChildEffect(i); + } + + private var current:int; + + private function playChildEffect(index:int):void + { + var child:IEffect = children[index]; + child.addEventListener(Effect.EFFECT_END, effectEndHandler); + child.play(); + } + + private function effectEndHandler(event:Event):void + { + current++; + if (current >= children.length) + dispatchEvent(new Event(Effect.EFFECT_END)); + } +} + +} http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/c99bd398/frameworks/projects/Effects/src/main/flex/org/apache/flex/effects/PlatformWiper.as ---------------------------------------------------------------------- diff --git a/frameworks/projects/Effects/src/main/flex/org/apache/flex/effects/PlatformWiper.as b/frameworks/projects/Effects/src/main/flex/org/apache/flex/effects/PlatformWiper.as new file mode 100644 index 0000000..1e3b412 --- /dev/null +++ b/frameworks/projects/Effects/src/main/flex/org/apache/flex/effects/PlatformWiper.as @@ -0,0 +1,138 @@ +//////////////////////////////////////////////////////////////////////////////// +// +// 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. +// +//////////////////////////////////////////////////////////////////////////////// + +package org.apache.flex.effects +{ + +COMPILE::AS3 +{ + import flash.display.DisplayObject; + import flash.geom.Rectangle; +} +COMPILE::JS +{ + import org.apache.flex.geom.Rectangle; +} + +import org.apache.flex.core.IDocument; +import org.apache.flex.core.IUIBase; + +/** + * Helper class for Wipe effects. + * + * @langversion 3.0 + * @playerversion Flash 10.2 + * @playerversion AIR 2.6 + * @productversion FlexJS 0.0 + */ +public class PlatformWiper +{ + + //-------------------------------------------------------------------------- + // + // Constructor + // + //-------------------------------------------------------------------------- + + /** + * Constructor. + * + * @langversion 3.0 + * @playerversion Flash 9 + * @playerversion AIR 1.1 + * @productversion Flex 3 + */ + public function PlatformWiper() + { + super(); + } + + //-------------------------------------------------------------------------- + // + // Variables + // + //-------------------------------------------------------------------------- + + /** + * @private + * The target. + */ + private var _target:IUIBase; + + /** + * @private + * The old overflow value. + */ + private var _overflow:String; + + /** + * The object that will be clipped. + * + * @langversion 3.0 + * @playerversion Flash 9 + * @playerversion AIR 1.1 + * @productversion Flex 3 + */ + public function set target(value:IUIBase):void + { + COMPILE::AS3 + { + if (value == null) + DisplayObject(_target).scrollRect = null; + _target = value; + } + COMPILE::JS + { + if (value == null) + { + if (_overflow == null) + delete _target.positioner.style["overflow"]; + else + _target.positioner.style.overflow = _overflow; + } + _target = value; + if (value != null) { + _overflow = _target.positioner.style.overflow; + } + } + } + + /** + * The visible rectangle. + * + * @langversion 3.0 + * @playerversion Flash 9 + * @playerversion AIR 1.1 + * @productversion Flex 3 + */ + public function set visibleRect(value:Rectangle):void + { + COMPILE::AS3 + { + DisplayObject(_target).scrollRect = value; + } + COMPILE::JS + { + _target.positioner.style.height = value.height.toString() + 'px'; + _target.positioner.style.overflow = 'hidden'; + } + } +} + +} http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/c99bd398/frameworks/projects/Effects/src/main/flex/org/apache/flex/effects/Resize.as ---------------------------------------------------------------------- diff --git a/frameworks/projects/Effects/src/main/flex/org/apache/flex/effects/Resize.as b/frameworks/projects/Effects/src/main/flex/org/apache/flex/effects/Resize.as new file mode 100644 index 0000000..2ee1e15 --- /dev/null +++ b/frameworks/projects/Effects/src/main/flex/org/apache/flex/effects/Resize.as @@ -0,0 +1,197 @@ +//////////////////////////////////////////////////////////////////////////////// +// +// 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. +// +//////////////////////////////////////////////////////////////////////////////// + +package org.apache.flex.effects +{ + +import org.apache.flex.core.IDocument; +import org.apache.flex.core.IUIBase; + +/** + * The Resize effect animates a UI component's width or height. + * + * @langversion 3.0 + * @playerversion Flash 10.2 + * @playerversion AIR 2.6 + * @productversion FlexJS 0.0 + */ +public class Resize extends Tween implements IDocument +{ + + //-------------------------------------------------------------------------- + // + // Constructor + // + //-------------------------------------------------------------------------- + + /** + * Constructor. + * + * @param target Object ID or reference to an object that will + * have its x and/or y property animated. + * + * @langversion 3.0 + * @playerversion Flash 9 + * @playerversion AIR 1.1 + * @productversion Flex 3 + */ + public function Resize(target:IUIBase = null) + { + super(); + + this.actualTarget = target; + startValue = 0; + endValue = 1; + + listener = this; + } + + //-------------------------------------------------------------------------- + // + // Variables + // + //-------------------------------------------------------------------------- + + /** + * @private + * The document. + */ + private var document:Object; + + /** + * @private + * The target. + */ + private var actualTarget:IUIBase; + + /** + * The target as the String id + * of a widget in an MXML Document. + */ + public var target:String; + + /** + * The change in width. + */ + public var widthBy:Number; + + /** + * The change in height. + */ + public var heightBy:Number; + + /** + * @private + * The starting width. + */ + private var widthStart:Number; + + /** + * @private + * The starting height. + */ + private var heightStart:Number; + + /** + * Starting width value. If NaN, the current width value is used + */ + public var widthFrom:Number; + + /** + * Starting height value. If NaN, the current height value is used + */ + public var heightFrom:Number; + + /** + * Ending width value. + */ + public var widthTo:Number; + + /** + * Ending height value. + */ + public var heightTo:Number; + + + //-------------------------------------------------------------------------- + // + // Properties + // + //-------------------------------------------------------------------------- + + + //-------------------------------------------------------------------------- + // + // Methods + // + //-------------------------------------------------------------------------- + + public function setDocument(document:Object, id:String = null):void + { + this.document = document; + } + + /** + * @private + */ + override public function play():void + { + if (target != null) + actualTarget = document[target]; + + if (isNaN(widthFrom)) + widthStart = actualTarget.width; + if (isNaN(widthBy)) + { + if (isNaN(widthTo)) + widthBy = 0; + else + widthBy = widthTo - widthStart; + } + + if (isNaN(heightFrom)) + heightStart = actualTarget.height; + if (isNaN(heightBy)) + { + if (isNaN(heightTo)) + heightBy = 0; + else + heightBy = heightTo - heightStart; + } + super.play(); + } + + public function onTweenUpdate(value:Number):void + { + if (widthBy) + actualTarget.width = widthStart + value * widthBy; + if (heightBy) + actualTarget.height = heightStart + value * heightBy; + } + + public function onTweenEnd(value:Number):void + { + if (widthBy) + actualTarget.width = widthStart + widthBy; + if (heightBy) + actualTarget.height = heightStart + heightBy; + } +} + +} http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/c99bd398/frameworks/projects/Effects/src/main/flex/org/apache/flex/effects/Sequence.as ---------------------------------------------------------------------- diff --git a/frameworks/projects/Effects/src/main/flex/org/apache/flex/effects/Sequence.as b/frameworks/projects/Effects/src/main/flex/org/apache/flex/effects/Sequence.as new file mode 100644 index 0000000..f6c3343 --- /dev/null +++ b/frameworks/projects/Effects/src/main/flex/org/apache/flex/effects/Sequence.as @@ -0,0 +1,152 @@ +//////////////////////////////////////////////////////////////////////////////// +// +// 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. +// +//////////////////////////////////////////////////////////////////////////////// + +package org.apache.flex.effects +{ + +import org.apache.flex.core.IDocument; +import org.apache.flex.core.IUIBase; +import org.apache.flex.events.Event; + +[DefaultProperty("children")] + +/** + * The Sequence effect animates a set of effects one + * at a time. + * + * @langversion 3.0 + * @playerversion Flash 10.2 + * @playerversion AIR 2.6 + * @productversion FlexJS 0.0 + */ +public class Sequence extends Effect implements IDocument +{ + + //-------------------------------------------------------------------------- + // + // Constructor + // + //-------------------------------------------------------------------------- + + /** + * Constructor. + * + * @langversion 3.0 + * @playerversion Flash 9 + * @playerversion AIR 1.1 + * @productversion Flex 3 + */ + public function Sequence() + { + super(); + } + + //-------------------------------------------------------------------------- + // + // Variables + // + //-------------------------------------------------------------------------- + + /** + * @private + * The document. + */ + private var document:Object; + + /** + * @private + * The target. + */ + private var target:IUIBase; + + /** + * The children. + */ + public var children:Array; + + + + //-------------------------------------------------------------------------- + // + // Properties + // + //-------------------------------------------------------------------------- + + /** + * @private + */ + override public function set duration(value:Number):void + { + var n:int = children.length; + for (var i:int = 0; i < 0; i++) + { + children[i].duration = value; + } + super.duration = value; + } + + //-------------------------------------------------------------------------- + // + // Methods + // + //-------------------------------------------------------------------------- + + public function setDocument(document:Object, id:String = null):void + { + this.document = document; + } + + public function addChild(child:IEffect):void + { + if (!children) + children = [ child ]; + else + children.push(child); + } + + /** + * @private + */ + override public function play():void + { + dispatchEvent(new Event(Effect.EFFECT_START)); + current = 0; + playChildEffect(); + } + + private var current:int; + + private function playChildEffect():void + { + var child:IEffect = children[current]; + child.addEventListener(Effect.EFFECT_END, effectEndHandler); + child.play(); + } + + private function effectEndHandler(event:Event):void + { + current++; + if (current >= children.length) + dispatchEvent(new Event(Effect.EFFECT_END)); + else + playChildEffect(); + } +} + +}