Hello few days ago i had to make a components , therefore user can rate a service on guitar learning application , i am attaching the source code hope you will get help with your purpose it is a HBox Components used in main application i am not providing the main application source file :( , but you can use by defining a namespace in Application tag and please replace assets folder
Smin Rana /***************source**********************/ <?xml version="1.0″ encoding="utf-8″?> <mx:HBox xmlns:mx="http://www.adobe.com/2006/mxml" creationComplete="init()" horizontalGap="20″> <mx:Script> <![CDATA[ import mx.controls.Alert; import mx.controls.Image; private var ratingImage:Image; private var imageTrunk:Array; private var loopNumber:int; private var isReverse:Boolean = false; private function init():void { imageTrunk = new Array(); for(var i:int = 0; i < 5; i++) { ratingImage = new Image(); ratingImage.source = "assets/images/start_rating.png"; ratingImage.alpha = 0.3; addChild(ratingImage); imageTrunk.push(ratingImage); imageTrunk[i].addEventListener(MouseEvent.CLICK, selectRate); } } private function selectRate(e:MouseEvent):void { var j:int = imageTrunk.indexOf(e.currentTarget); if(e.currentTarget.alpha != 1) { for(var i:int = 0; i <= j; i++) { imageTrunk[i].alpha = 1; } } else { for(var l:int = 4; l >= j; l) { imageTrunk[l].alpha = 0.3; } } } ]]> </mx:Script> </mx:HBox> /***************source***********************/