Repository: flex-asjs Updated Branches: refs/heads/develop c2105e383 -> da16efbee
Added DisabledAlphaBead Project: http://git-wip-us.apache.org/repos/asf/flex-asjs/repo Commit: http://git-wip-us.apache.org/repos/asf/flex-asjs/commit/da16efbe Tree: http://git-wip-us.apache.org/repos/asf/flex-asjs/tree/da16efbe Diff: http://git-wip-us.apache.org/repos/asf/flex-asjs/diff/da16efbe Branch: refs/heads/develop Commit: da16efbee84cb06a84342843542bf6920254a2e1 Parents: c2105e3 Author: Harbs <ha...@in-tools.com> Authored: Wed Jul 12 16:18:15 2017 +0300 Committer: Harbs <ha...@in-tools.com> Committed: Wed Jul 12 16:18:15 2017 +0300 ---------------------------------------------------------------------- .../apache/flex/html/beads/DisabledAlphaBead.as | 130 +++++++++++++++++++ .../Basic/src/main/resources/basic-manifest.xml | 1 + 2 files changed, 131 insertions(+) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/da16efbe/frameworks/projects/Basic/src/main/flex/org/apache/flex/html/beads/DisabledAlphaBead.as ---------------------------------------------------------------------- diff --git a/frameworks/projects/Basic/src/main/flex/org/apache/flex/html/beads/DisabledAlphaBead.as b/frameworks/projects/Basic/src/main/flex/org/apache/flex/html/beads/DisabledAlphaBead.as new file mode 100644 index 0000000..6c5fe9d --- /dev/null +++ b/frameworks/projects/Basic/src/main/flex/org/apache/flex/html/beads/DisabledAlphaBead.as @@ -0,0 +1,130 @@ +//////////////////////////////////////////////////////////////////////////////// +// +// 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.html.beads +{ + COMPILE::SWF + { + import flash.display.InteractiveObject; + } + + import org.apache.flex.core.IBead; + import org.apache.flex.core.IStrand; + import org.apache.flex.core.IUIBase; + import org.apache.flex.core.UIHTMLElementWrapper; + import org.apache.flex.events.Event; + import org.apache.flex.events.IEventDispatcher; + import org.apache.flex.events.ValueEvent; + import org.apache.flex.html.beads.DisableBead; + + COMPILE::JS + { + import org.apache.flex.core.WrappedHTMLElement; + } + /** + * The DisabledAlphaBead class is a specialty bead that can be used with + * any UIBase control which has a DisableBead attached. + * The bead takes properties for enabledAplha and disabledAlpha. + * + * @langversion 3.0 + * @playerversion Flash 10.2 + * @playerversion AIR 2.6 + * @productversion FlexJS 0.9 + */ + public class DisabledAlphaBead implements IBead + { + /** + * constructor. + * + * @langversion 3.0 + * @playerversion Flash 10.2 + * @playerversion AIR 2.6 + * @productversion FlexJS 0.9 + */ + public function DisabledAlphaBead() + { + } + + private var _strand:IStrand; + + /** + * The alpha of the element when enabled. Defaults to 1.0; + * @langversion 3.0 + * @playerversion Flash 10.2 + * @playerversion AIR 2.6 + * @productversion FlexJS 0.9 + */ + public var enabledAplha:Number = 1.0; + + /** + * The alpha of the element when disabled. Defaults to 0.5; + * @langversion 3.0 + * @playerversion Flash 10.2 + * @playerversion AIR 2.6 + * @productversion FlexJS 0.9 + */ + public var disabledAlpha:Number = 0.5; + + /** + * @copy org.apache.flex.core.IBead#strand + * + * @langversion 3.0 + * @playerversion Flash 10.2 + * @playerversion AIR 2.6 + * @productversion FlexJS 0.9 + */ + public function set strand(value:IStrand):void + { + _strand = value; + host.addEventListener("disabledChange", disabledChangeHandler); + updateHost(null); + } + + + private function disabledChangeHandler(e:ValueEvent):void + { + updateHost(e.value); + } + + /** + * @flexjsignorecoercion org.apache.flex.core.IUIBase + */ + private function get host():IUIBase + { + return _strand as IUIBase; + } + private function updateHost(value:Object):void + { + if(!_strand)//bail out + return; + + var disabled:Boolean; + if(value == null) + { + var disableBead:DisableBead = _strand.getBeadByType(DisableBead) as DisableBead; + if(!disableBead)// The DisableBead was not added yet. We'll set this when the event is dispatched. + return; + disabled = disableBead.disabled; + } else { + disabled = value; + } + host.alpha = disabled ? disabledAlpha : enabledAplha; + } + + } +} http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/da16efbe/frameworks/projects/Basic/src/main/resources/basic-manifest.xml ---------------------------------------------------------------------- diff --git a/frameworks/projects/Basic/src/main/resources/basic-manifest.xml b/frameworks/projects/Basic/src/main/resources/basic-manifest.xml index 625f9bc..b391ee0 100644 --- a/frameworks/projects/Basic/src/main/resources/basic-manifest.xml +++ b/frameworks/projects/Basic/src/main/resources/basic-manifest.xml @@ -108,6 +108,7 @@ --> <component id="UnselectableElementBead" class="org.apache.flex.html.beads.UnselectableElementBead"/> <component id="DisableBead" class="org.apache.flex.html.beads.DisableBead" /> + <component id="DisabledAlphaBead" class="org.apache.flex.html.beads.DisabledAlphaBead" /> <component id="NumericOnlyTextInputBead" class="org.apache.flex.html.accessories.NumericOnlyTextInputBead" /> <component id="PasswordInputBead" class="org.apache.flex.html.accessories.PasswordInputBead" /> <component id="PasswordInputRemovableBead" class="org.apache.flex.html.accessories.PasswordInputRemovableBead" />