On http://cookbooks.adobe.com/post_Create_a_star_rating_component-561.html , you can see how to do a rating component with star, who is fashion now. The only problem is this componant is static, means,u can't rate yourself. So i did a little change to the component :
<?xml version="1.0" encoding="iso-8859-1"?>
<mx:Canvas xmlns:mx="http://www.adobe.com/2006/mxml"
horizontalScrollPolicy="off" verticalScrollPolicy="off">
<mx:Script>
<![CDATA[
[Bindable]
public var rating:Number = 0;
public var i:int = 0;
protected function starIcon_clickHandler(event:MouseEvent):void
{
rating=int(event.currentTarget.name);
}
]]>
</mx:Script>
<mx:HBox horizontalGap="1" verticalCenter="0">
<mx:Spacer width="4" />
<mx:Repeater id="stars" dataProvider="{[1,2,3,4,5]}" count="5" >
<mx:Image id="starIcon" name="{i++}" click="starIcon_clickHandler(event)" width="13" alpha="{(rating >= stars.currentIndex) ? 1 : .35}" source="@Embed('StarIcon.swf')" />
</mx:Repeater>
<mx:Spacer width="4" />
</mx:HBox>
</mx:Canvas>
As u can see,i use a strange tips: i stock the value in the name! this look ugly but that's save my life many time yet ^^
(for StarIcon.swf or sample of use,it is exactly the same as Adobe website, so i don't copy it here).
Create a star rating component in Flex
Lire les cookies en Flex
Une lib pas de moi ( http://myflex.wordpress.com/2008/11/12/actionscript-cookie-util/),qui est tres utile a l'usage : (je copie le source car la fonction de download est pas tres pratique)
package
{
import flash.external.ExternalInterface;
public class CookieUtil
{
public function CookieUtil()
{
}
private static const FUNCTION_SETCOOKIE:String =
"document.insertScript = function ()" +
"{ " +
"if (document.snw_setCookie==null)" +
"{" +
"snw_setCookie = function (name, value, days)" +
"{" +
"if (days) {"+
"var date = new Date();"+
"date.setTime(date.getTime()+(days*24*60*60*1000));"+
"var expires = '; expires='+date.toGMTString();"+
"}" +
"else var expires = '';"+
"document.cookie = name+'='+value+expires+'; path=/';" +
"}" +
"}" +
"}";
private static const FUNCTION_GETCOOKIE:String =
"document.insertScript = function ()" +
"{ " +
"if (document.snw_getCookie==null)" +
"{" +
"snw_getCookie = function (name)" +
"{" +
"var nameEQ = name + '=';"+
"var ca = document.cookie.split(';');"+
"for(var i=0;i < ca.length;i++) {"+
"var c = ca[i];"+
"while (c.charAt(0)==' ') c = c.substring(1,c.length);"+
"if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length,c.length);"+
"}"+
"return null;" +
"}" +
"}" +
"}";
private static var INITIALIZED:Boolean = false;
private static function init():void{
ExternalInterface.call(FUNCTION_GETCOOKIE);
ExternalInterface.call(FUNCTION_SETCOOKIE);
INITIALIZED = true;
}
public static function setCookie(name:String, value:Object, days:int):void{
if(!INITIALIZED)
init();
ExternalInterface.call("snw_setCookie", name, value, days);
}
public static function getCookie(name:String):Object{
if(!INITIALIZED)
init();
return ExternalInterface.call("snw_getCookie", name);
}
public static function deleteCookie(name:String):void{
if(!INITIALIZED)
init();
ExternalInterface.call("snw_setCookie", name, "", -1);
}
}
}