home *** CD-ROM | disk | FTP | other *** search
- package com.Rating
- {
- import flash.events.Event;
- import flash.events.MouseEvent;
- import mx.controls.dataGridClasses.DataGridListData;
- import mx.controls.listClasses.BaseListData;
- import mx.controls.listClasses.IDropInListItemRenderer;
- import mx.controls.listClasses.IListItemRenderer;
- import mx.core.IDataRenderer;
- import mx.core.UIComponent;
- import mx.events.FlexEvent;
- import mx.events.PropertyChangeEvent;
-
- public class Ratings extends UIComponent implements IDataRenderer, IDropInListItemRenderer, IListItemRenderer
- {
- private var _data:Object;
-
- private var _1249874743_innerRadius:Number = 25;
-
- private const itemCount:Number = 5;
-
- private var _1725716994_points:Number = 5;
-
- private var _listData:BaseListData;
-
- private var contentWidth:Number = 0;
-
- private var _892116433_tooltips:Array = null;
-
- [Bindable(event="change")]
- private var _value:int = 0;
-
- private var _1482236972_angle:Number = 90;
-
- private var _1517899566_outerRadius:Number = 50;
-
- public function Ratings()
- {
- super();
- addEventListener(MouseEvent.MOUSE_OUT,this.handleMouseOut);
- addEventListener(MouseEvent.ROLL_OUT,this.handleMouseOut);
- mouseChildren = true;
- }
-
- [Bindable(event="propertyChange")]
- private function get _points() : Number
- {
- return this._1725716994_points;
- }
-
- public function get innerRadius() : Number
- {
- return this._innerRadius;
- }
-
- private function set _points(param1:Number) : void
- {
- var _loc2_:Object = this._1725716994_points;
- if(_loc2_ !== param1)
- {
- this._1725716994_points = param1;
- this.dispatchEvent(PropertyChangeEvent.createUpdateEvent(this,"_points",_loc2_,param1));
- }
- }
-
- public function set innerRadius(param1:Number) : void
- {
- this._innerRadius = param1;
- this.updateChildren("innerRadius",param1);
- }
-
- private function set _innerRadius(param1:Number) : void
- {
- var _loc2_:Object = this._1249874743_innerRadius;
- if(_loc2_ !== param1)
- {
- this._1249874743_innerRadius = param1;
- this.dispatchEvent(PropertyChangeEvent.createUpdateEvent(this,"_innerRadius",_loc2_,param1));
- }
- }
-
- public function set tooltips(param1:Array) : void
- {
- this._tooltips = param1;
- }
-
- private function selectItems(param1:Number) : void
- {
- var _loc2_:RatingItem = null;
- var _loc3_:int = 1;
- while(_loc3_ < this.itemCount + 1)
- {
- _loc2_ = RatingItem(getChildByName(_loc3_.toString()));
- if(_loc2_)
- {
- if(_loc3_ <= param1)
- {
- _loc2_.selected = true;
- }
- else
- {
- _loc2_.selected = false;
- }
- }
- _loc3_++;
- }
- }
-
- public function set angle(param1:Number) : void
- {
- this._angle = param1;
- this.updateChildren("angle",param1);
- }
-
- private function set _angle(param1:Number) : void
- {
- var _loc2_:Object = this._1482236972_angle;
- if(_loc2_ !== param1)
- {
- this._1482236972_angle = param1;
- this.dispatchEvent(PropertyChangeEvent.createUpdateEvent(this,"_angle",_loc2_,param1));
- }
- }
-
- [Bindable("dataChange")]
- public function get data() : Object
- {
- return this._data;
- }
-
- [Bindable(event="propertyChange")]
- private function get _outerRadius() : Number
- {
- return this._1517899566_outerRadius;
- }
-
- [Bindable(event="propertyChange")]
- private function get _tooltips() : Array
- {
- return this._892116433_tooltips;
- }
-
- private function handleMouseOut(param1:MouseEvent) : void
- {
- if(param1.currentTarget is Ratings)
- {
- this.selectItems(this.value);
- }
- }
-
- public function set points(param1:Number) : void
- {
- this._points = param1;
- this.updateChildren("points",param1);
- }
-
- [Bindable(event="propertyChange")]
- private function get _innerRadius() : Number
- {
- return this._1249874743_innerRadius;
- }
-
- public function set listData(param1:BaseListData) : void
- {
- this._listData = param1;
- }
-
- public function get angle() : Number
- {
- return this._angle;
- }
-
- public function set data(param1:Object) : void
- {
- var value:Object = param1;
- this._data = value;
- try
- {
- if(Boolean(this._listData) && this._listData is DataGridListData)
- {
- this.value = this._data[DataGridListData(this._listData).dataField];
- }
- else
- {
- this.value = int(this._listData.label);
- }
- }
- catch(e:Error)
- {
- this.value = 0;
- }
- dispatchEvent(new FlexEvent(FlexEvent.DATA_CHANGE));
- }
-
- public function set outerRadius(param1:Number) : void
- {
- this._outerRadius = param1;
- this.updateChildren("outerRadius",param1);
- }
-
- private function set _outerRadius(param1:Number) : void
- {
- var _loc2_:Object = this._1517899566_outerRadius;
- if(_loc2_ !== param1)
- {
- this._1517899566_outerRadius = param1;
- this.dispatchEvent(PropertyChangeEvent.createUpdateEvent(this,"_outerRadius",_loc2_,param1));
- }
- }
-
- private function set _tooltips(param1:Array) : void
- {
- var _loc2_:Object = this._892116433_tooltips;
- if(_loc2_ !== param1)
- {
- this._892116433_tooltips = param1;
- this.dispatchEvent(PropertyChangeEvent.createUpdateEvent(this,"_tooltips",_loc2_,param1));
- }
- }
-
- public function get tooltips() : Array
- {
- return this._tooltips;
- }
-
- public function set value(param1:int) : void
- {
- var value:int = param1;
- this._value = value;
- this.selectItems(value);
- try
- {
- if(Boolean(this._listData) && this._listData is DataGridListData)
- {
- this._data[DataGridListData(this._listData).dataField] = this._value;
- }
- else
- {
- this._listData.label = this._value.toString();
- }
- }
- catch(e:Error)
- {
- }
- dispatchEvent(new Event("change"));
- }
-
- public function get points() : Number
- {
- return this._points;
- }
-
- private function updateChildren(param1:String, param2:Number) : void
- {
- var _loc3_:int = 1;
- while(_loc3_ < this.itemCount + 1)
- {
- if(getChildByName(_loc3_.toString()))
- {
- RatingItem(getChildByName(_loc3_.toString()))[param1] = param2;
- }
- _loc3_++;
- }
- }
-
- override protected function childrenCreated() : void
- {
- var _loc6_:RatingItem = null;
- var _loc1_:Number = getStyle("horizontalGap");
- var _loc2_:Number = getStyle("paddingLeft");
- var _loc3_:Number = getStyle("paddingTop");
- var _loc4_:Number = 0;
- var _loc5_:int = 1;
- while(_loc5_ < this.itemCount + 1)
- {
- _loc6_ = new RatingItem();
- _loc6_.id = _loc5_.toString();
- _loc6_.name = _loc5_.toString();
- _loc6_.setStyle("borderAlpha",0);
- _loc6_.setStyle("fillEnabled",true);
- _loc6_.setStyle("fillColors",[3355443,13421772]);
- _loc6_.setStyle("fillSelectedColors",[16737792,16777164]);
- _loc6_.setStyle("fillAlphas",[1,1]);
- _loc6_.setStyle("fillRatios",[0,255]);
- _loc6_.setStyle("fillAngle",90);
- if(this.tooltips)
- {
- if(this.tooltips.length > _loc5_ - 1)
- {
- _loc6_.toolTip = this.tooltips[_loc5_ - 1].toString();
- }
- }
- _loc6_.width = 12;
- _loc6_.height = 12;
- addChild(_loc6_);
- if(_loc4_ == 0)
- {
- _loc6_.x = _loc2_;
- }
- else
- {
- _loc6_.x = 12 + _loc1_ + _loc4_;
- }
- _loc4_ = _loc6_.x;
- _loc6_.y = _loc3_;
- if(_loc5_ - 1 < this.value)
- {
- _loc6_.selected = true;
- }
- _loc6_.addEventListener(MouseEvent.CLICK,this.handleItemClick,false,1);
- _loc6_.addEventListener(MouseEvent.ROLL_OVER,this.handleMouseRoll);
- _loc6_.addEventListener(MouseEvent.ROLL_OUT,this.handleMouseRoll);
- _loc5_++;
- }
- width = _loc6_.x + _loc1_;
- height = 12;
- }
-
- [Bindable(event="propertyChange")]
- private function get _angle() : Number
- {
- return this._1482236972_angle;
- }
-
- private function handleItemClick(param1:MouseEvent) : void
- {
- param1.preventDefault();
- param1.stopImmediatePropagation();
- if(param1.currentTarget.id == 1 && this.value == 1)
- {
- this.value = 0;
- }
- else
- {
- this.value = Number(param1.currentTarget.id);
- }
- dispatchEvent(param1);
- }
-
- [Bindable("dataChange")]
- public function get listData() : BaseListData
- {
- return this._listData;
- }
-
- public function get value() : int
- {
- return this._value;
- }
-
- public function get outerRadius() : Number
- {
- return this._outerRadius;
- }
-
- override protected function updateDisplayList(param1:Number, param2:Number) : void
- {
- super.updateDisplayList(param1,param2);
- graphics.lineStyle(0,16777215,0);
- graphics.beginFill(16777215,0);
- graphics.drawRect(0,0,param1,param2);
- graphics.endFill();
- }
-
- private function handleMouseRoll(param1:MouseEvent) : void
- {
- this.selectItems(Number(param1.currentTarget.name));
- }
- }
- }
-
-