SharedObejctテスト2
Wonderfl内で別のコードのSharedObjectが読めるかどうかのテストの読む側
先に http://wonderfl.net/c/zRRa を実行して、データ作ります。
【実験結果】
書き込む側で '/' 等を指定すれば共有できるのは確認できたものの、
getLocalの第2匹数のlocalpath未指定なswfで作られたsoへのアクセスは無理っぽいかも。
ActionScript3 source code
/**
* Copyright fernet ( http://wonderfl.net/user/fernet )
* MIT License ( http://www.opensource.org/licenses/mit-license.php )
* Downloaded from: http://wonderfl.net/c/qmFf
*/
package {
import flash.text.TextField;
import flash.net.SharedObject;
import flash.display.Sprite;
public class FlashTest extends Sprite {
public function FlashTest() {
// write as3 code here..
var x:int = 10, y:int = 10, dy:int = 35;
_read(x, y+=dy, null);
_read(x, y+=dy, '/');
_read(x, y+=dy, '/swf/usercode/f/fb/fb62/fb62a1b0e27b4f92d98c467e299bf613929afe01.swf');
_read(x, y+=dy, '/swf/usercode/f/fb/fb62/fb62a1b0e27b4f92d98c467e299bf613929afe01.swf/');
_read(x, y+=dy, '/swf/usercode/f/fb/fb62/');
_read(x, y+=dy, 'http://swf.wonderfl.net/swf/usercode/f/fb/fb62/fb62a1b0e27b4f92d98c467e299bf613929afe01.swf');
_read(x, y+=dy, 'http://swf.wonderfl.net/swf/usercode/f/fb/fb62/fb62a1b0e27b4f92d98c467e299bf613929afe01.swf/');
_read(x, y+=dy, 'http://swf.wonderfl.net/swf/usercode/f/fb/fb62/');
}
private function _read(x:int, y:int, localpath:String):void
{
var tf:TextField = new TextField;
tf.x = x;
tf.y = y;
tf.width = 500;
tf.text = "path: " + localpath + "\nvalue: ";
addChild(tf);
var so:SharedObject;
try {
so = SharedObject.getLocal('zRRa_test',localpath);
tf.text = tf.text + "<" + so.data.hoge + ">";
} catch (e:Error) {
tf.text = tf.text + "throw " + e.message;
}
}
}
}
/* http://swf.wonderfl.net/swf/usercode/b/b8/b8c8/b8c86aafcd5597fe5b5360668f6779bf8691fdf3.swf */