OverflowTest : SharedObject « Development « Flash / Flex / ActionScript






OverflowTest

 
package
{
    import flash.display.Sprite;
    import flash.events.NetStatusEvent;
    import flash.net.SharedObject;
    import flash.net.SharedObjectFlushStatus;

    public class Main extends Sprite
    {
        protected var so:SharedObject = SharedObject.getLocal("storage");

        public function Main(){
            //request 1 MB up front
            if (so.flush(1024 * 1024) == SharedObjectFlushStatus.PENDING)
            {
                so.addEventListener(NetStatusEvent.NET_STATUS, onUserAction);
                trace("User approval pending...");
            }
        }

        public function onUserAction(event:NetStatusEvent):void{
            so.removeEventListener(NetStatusEvent.NET_STATUS, onUserAction);
            switch (event.info.code)
            {
                case "SharedObject.Flush.Success":
                    trace("Accepted");
                    break;

                case "SharedObject.Flush.Failed":
                    trace("Denied");
                    //do error recovery
                    break;
            }
        }
    }
}

        








Related examples in the same category

1.Using SharedObjects