Download: AS 2.0 star rating class
April 19, 2006
Just wanted to quickly post an as 2.0 class. It’s a rating component which can display any number of customizable labels and rating items. In the example below I’ve used the common stars as rating items but you could use any other graphics (just go into the fla, modify the ObjectRaterItem symbol and put in your own graphics).
The ObjectRater class has an init method that accepts the labels as an array and a setRating method that accepts two parameters: totalRating and numRatings (e.g. if you got the totalRating and numRatings via the getter methods and stored it somewhere you can initialize the ObjectRater later with those two values). If you click on a star the rating is automatically added but you could also provide another button, combo box or whatever and call the rate method manually.
The class fires a few events and has some getter methods to display all rating infos (rating, roundedRating, totalRating, numRatings…). Just look at the demo file. You can download it in the download section.
[Additional Note: It’s currently compiled for Flash Player 8 as there’s a DropShadowFilter in the ObjectRaterItem class. If you want to compile it for Flash Player 7 just remove the DropShadowFilter in the init method…]
Filed under: Flex/AS3