| //////////////////////////////////////////////////////////////////////////////// |
| // |
| // 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 flash.display.DisplayObjectContainer; |
| import flash.display.Sprite; |
| import flash.events.Event; |
| |
| public class UIBase extends Sprite implements IInitModel, IStrand |
| { |
| public function UIBase() |
| { |
| super(); |
| } |
| |
| private var _width:Number; |
| override public function get width():Number |
| { |
| return _width; |
| } |
| override public function set width(value:Number):void |
| { |
| if (_width != value) |
| { |
| _width = value; |
| dispatchEvent(new Event("widthChanged")); |
| } |
| } |
| protected function get $width():Number |
| { |
| return super.width; |
| } |
| |
| private var _height:Number; |
| override public function get height():Number |
| { |
| return _height; |
| } |
| override public function set height(value:Number):void |
| { |
| if (_height != value) |
| { |
| _height = value; |
| dispatchEvent(new Event("heightChanged")); |
| } |
| } |
| protected function get $height():Number |
| { |
| return super.height; |
| } |
| |
| private var _model:IBeadModel; |
| protected function get model():IBeadModel |
| { |
| return _model; |
| } |
| |
| private var strand:Vector.<IBead>; |
| public function addBead(bead:IBead):void |
| { |
| if (!strand) |
| strand = new Vector.<IBead>; |
| strand.push(bead); |
| if (bead is IBeadModel) |
| _model = bead as IBeadModel; |
| bead.strand = this; |
| } |
| |
| public function getBeadByType(classOrInterface:Class):IBead |
| { |
| for each (var bead:IBead in strand) |
| { |
| if (bead is classOrInterface) |
| return bead; |
| } |
| return null; |
| } |
| |
| public function removeBead(value:IBead):IBead |
| { |
| var n:int = strand.length; |
| for (var i:int = 0; i < n; i++) |
| { |
| var bead:IBead = strand[i]; |
| if (bead == value) |
| { |
| strand.splice(i, 1); |
| return bead; |
| } |
| } |
| return null; |
| } |
| |
| public function initModel():void |
| { |
| |
| } |
| |
| public function addToParent(p:DisplayObjectContainer):void |
| { |
| p.addChild(this); |
| } |
| } |
| } |