ShareObjectテスト
SharedObject ローカル共有オブジェクト
@author Copyright (C) naoto koshikawa, All Rights Reserved.
/**
* Copyright naoto5959 ( http://wonderfl.net/user/naoto5959 )
* MIT License ( http://www.opensource.org/licenses/mit-license.php )
* Downloaded from: http://wonderfl.net/c/l6Hx
*/
package
{
import flash.display.Sprite;
import flash.events.MouseEvent;
import flash.net.SharedObject;
import com.bit101.components.*;
[SWF(width = "465", height = "465", backgroundColor = "0xfefefe", frameRate = "30")]
/**
* SharedObject ローカル共有オブジェクト
* @author Copyright (C) naoto koshikawa, All Rights Reserved.
*/
public class SharedObjectWork extends Sprite
{
//----------------------------------------------------------------------
// methods
//----------------------------------------------------------------------
//------------------------------
// public methods
//------------------------------
/**
* constructor
*/
public function SharedObjectWork()
{
var SO:SharedObject = SharedObject.getLocal("hoge");
var panel:Panel = new Panel(this, stage.stageWidth / 8, stage.stageHeight / 8);
panel.setSize(stage.stageWidth * 3 / 4, stage.stageHeight * 3 / 4);
var label:Label = new Label(panel, 10, 10);
label.text = "Please input text you want to save.";
var inputText:InputText = new InputText(panel, 10, 30);
inputText.setSize(200, 20);
if (SO.data.name) inputText.text = SO.data.name;
var savebutton:PushButton = new PushButton(panel, 10, 55);
savebutton.setSize(98, 20);
savebutton.label = "Save Your Data";
var deletebutton:PushButton = new PushButton(panel, 112, 55);
deletebutton.setSize(98, 20);
deletebutton.label = "Delete Your Data";
savebutton.addEventListener(MouseEvent.CLICK, function(event:MouseEvent):void
{
SO.data.name = inputText.text;
SO.flush();
});
deletebutton.addEventListener(MouseEvent.CLICK, function(event:MouseEvent):void
{
SO.clear();
inputText.text = "";
});
}
}
}