Repository: flex-asjs Updated Branches: refs/heads/develop 1be529393 -> fd4ffd905
Renamed getByType and added documentation Project: http://git-wip-us.apache.org/repos/asf/flex-asjs/repo Commit: http://git-wip-us.apache.org/repos/asf/flex-asjs/commit/fd4ffd90 Tree: http://git-wip-us.apache.org/repos/asf/flex-asjs/tree/fd4ffd90 Diff: http://git-wip-us.apache.org/repos/asf/flex-asjs/diff/fd4ffd90 Branch: refs/heads/develop Commit: fd4ffd90579864b13153ab84d6f228d534d1ff96 Parents: 1be5293 Author: DESKTOP-RH4S838\Yishay <yishayj...@hotmail.com> Authored: Wed Sep 27 16:49:00 2017 +0300 Committer: DESKTOP-RH4S838\Yishay <yishayj...@hotmail.com> Committed: Wed Sep 27 17:08:25 2017 +0300 ---------------------------------------------------------------------- .../projects/Core/src/main/flex/CoreClasses.as | 2 +- .../flex/org/apache/flex/utils/getByType.as | 39 ---------------- .../apache/flex/utils/getParentOrSelfByType.as | 47 ++++++++++++++++++++ .../html/beads/SingleSelectionDragImageBead.as | 4 +- .../html/beads/SingleSelectionDragSourceBead.as | 4 +- 5 files changed, 52 insertions(+), 44 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/fd4ffd90/frameworks/projects/Core/src/main/flex/CoreClasses.as ---------------------------------------------------------------------- diff --git a/frameworks/projects/Core/src/main/flex/CoreClasses.as b/frameworks/projects/Core/src/main/flex/CoreClasses.as index 8654fb5..52cdef7 100644 --- a/frameworks/projects/Core/src/main/flex/CoreClasses.as +++ b/frameworks/projects/Core/src/main/flex/CoreClasses.as @@ -175,7 +175,7 @@ internal class CoreClasses } import org.apache.flex.utils.BrowserUtils; BrowserUtils; import org.apache.flex.utils.callLater; callLater; - import org.apache.flex.utils.getByType; getByType; + import org.apache.flex.utils.getParentOrSelfByType; getParentOrSelfByType; import org.apache.flex.utils.CompressionUtils; CompressionUtils; import org.apache.flex.utils.Endian; Endian; import org.apache.flex.utils.JXON; JXON; http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/fd4ffd90/frameworks/projects/Core/src/main/flex/org/apache/flex/utils/getByType.as ---------------------------------------------------------------------- diff --git a/frameworks/projects/Core/src/main/flex/org/apache/flex/utils/getByType.as b/frameworks/projects/Core/src/main/flex/org/apache/flex/utils/getByType.as deleted file mode 100644 index 6d9f9d6..0000000 --- a/frameworks/projects/Core/src/main/flex/org/apache/flex/utils/getByType.as +++ /dev/null @@ -1,39 +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.utils -{ - import org.apache.flex.core.IChild; - - public function getByType(startChild:IChild, classOrInterface:Class):Object - { - while (startChild) - { - if (startChild is classOrInterface) - { - return startChild; - } - if (startChild.parent is classOrInterface) - { - return startChild.parent; - } - startChild = startChild.parent as IChild; - } - return null; - } -} \ No newline at end of file http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/fd4ffd90/frameworks/projects/Core/src/main/flex/org/apache/flex/utils/getParentOrSelfByType.as ---------------------------------------------------------------------- diff --git a/frameworks/projects/Core/src/main/flex/org/apache/flex/utils/getParentOrSelfByType.as b/frameworks/projects/Core/src/main/flex/org/apache/flex/utils/getParentOrSelfByType.as new file mode 100644 index 0000000..2010a3a --- /dev/null +++ b/frameworks/projects/Core/src/main/flex/org/apache/flex/utils/getParentOrSelfByType.as @@ -0,0 +1,47 @@ +//////////////////////////////////////////////////////////////////////////////// +// +// 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.utils +{ + import org.apache.flex.core.IChild; + + + /** + * Traverses the display list up until it finds an object of the given type. + * @langversion 3.0 + * @playerversion Flash 10.2 + * @playerversion AIR 2.6 + * @productversion FlexJS 0.9 + */ + public function getParentOrSelfByType(startChild:IChild, classOrInterface:Class):Object + { + while (startChild) + { + if (startChild is classOrInterface) + { + return startChild; + } + if (startChild.parent is classOrInterface) + { + return startChild.parent; + } + startChild = startChild.parent as IChild; + } + return null; + } +} \ No newline at end of file http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/fd4ffd90/frameworks/projects/DragDrop/src/main/flex/org/apache/flex/html/beads/SingleSelectionDragImageBead.as ---------------------------------------------------------------------- diff --git a/frameworks/projects/DragDrop/src/main/flex/org/apache/flex/html/beads/SingleSelectionDragImageBead.as b/frameworks/projects/DragDrop/src/main/flex/org/apache/flex/html/beads/SingleSelectionDragImageBead.as index 91b704e..5eca009 100644 --- a/frameworks/projects/DragDrop/src/main/flex/org/apache/flex/html/beads/SingleSelectionDragImageBead.as +++ b/frameworks/projects/DragDrop/src/main/flex/org/apache/flex/html/beads/SingleSelectionDragImageBead.as @@ -43,7 +43,7 @@ package org.apache.flex.html.beads import org.apache.flex.html.Label; import org.apache.flex.html.beads.controllers.DragMouseController; import org.apache.flex.utils.PointUtils; - import org.apache.flex.utils.getByType; + import org.apache.flex.utils.getParentOrSelfByType; COMPILE::JS { @@ -146,7 +146,7 @@ package org.apache.flex.html.beads { trace("SingleSelectionDragImageBead received the DragStart via: "+event.target.toString()); - var renderer:IItemRenderer = getByType(event.target as IChild, IItemRenderer) as IItemRenderer; + var renderer:IItemRenderer = getParentOrSelfByType(event.target as IChild, IItemRenderer) as IItemRenderer; if (renderer) { DragMouseController.dragImage = createDragImage(renderer); } http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/fd4ffd90/frameworks/projects/DragDrop/src/main/flex/org/apache/flex/html/beads/SingleSelectionDragSourceBead.as ---------------------------------------------------------------------- diff --git a/frameworks/projects/DragDrop/src/main/flex/org/apache/flex/html/beads/SingleSelectionDragSourceBead.as b/frameworks/projects/DragDrop/src/main/flex/org/apache/flex/html/beads/SingleSelectionDragSourceBead.as index b38111f..d23e7d4 100644 --- a/frameworks/projects/DragDrop/src/main/flex/org/apache/flex/html/beads/SingleSelectionDragSourceBead.as +++ b/frameworks/projects/DragDrop/src/main/flex/org/apache/flex/html/beads/SingleSelectionDragSourceBead.as @@ -42,7 +42,7 @@ package org.apache.flex.html.beads import org.apache.flex.html.supportClasses.DataItemRenderer; import org.apache.flex.utils.PointUtils; import org.apache.flex.utils.UIUtils; - import org.apache.flex.utils.getByType; + import org.apache.flex.utils.getParentOrSelfByType; /** @@ -126,7 +126,7 @@ package org.apache.flex.html.beads DragMouseController.dragImageOffsetX = 0; DragMouseController.dragImageOffsetY = -30; - var itemRenderer:IItemRenderer = getByType(event.target as IChild, IItemRenderer) as IItemRenderer; + var itemRenderer:IItemRenderer = getParentOrSelfByType(event.target as IChild, IItemRenderer) as IItemRenderer; if (itemRenderer) { var p:UIBase = itemRenderer.itemRendererParent as UIBase;