SharedObject between 2 movies

So lets create 2 files:

setCookies.fla

setCookies.fla flash env with component names

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
var date:Date = new Date();
val_ti.text = ">> " +date.time;

setCookie_btn.addEventListener(MouseEvent.CLICK, clickHandler);
show_btn.addEventListener(MouseEvent.CLICK, showHandler);


function clickHandler(info:MouseEvent):void {
    var local_data:SharedObject = SharedObject.getLocal("VSh", "/");
    local_data.data.key = val_ti.text;
    status_txt.text = local_data.flush();
}

function showHandler(info:MouseEvent):void {
    var local_data:SharedObject = SharedObject.getLocal("VSh", "/");
    read_ti.text = local_data.data.key;
}

getCookies.fla

getCookies.fla flash evn with component names

getCookies.fla flash evn with component names

1
2
3
4
5
6
7
8
9
10
11
var timer:Timer = new Timer(500, 0);
timer.addEventListener(TimerEvent.TIMER, checkForCookieHandker);
timer.start();


info_ta.text = "check for cookies every 0.5 sec ... ";
function checkForCookieHandker(info:TimerEvent):void {
    var local_data:SharedObject = SharedObject.getLocal("VSh", "/");
    local_data.flush();
    info_ta.text = "[" + timer.currentCount + "] key: " + local_data.data.key + ", size: " + local_data.size + "\n" + info_ta.text;
}

Demo

Set cookie

This movie requires Flash Player 10

Get cookie

This movie requires Flash Player 10

see also:
where is .sol files in windows 7

source files in flash-cookie.zip

Creative Commons License
This work, unless otherwise expressly stated, is licensed under a Creative Commons Attribution 2.5 Bulgaria License.
  1. dimitar says:

    хмм, доста интересно, не бях се сещал да ползвам по този начин споделени обекти. Можеби дори ще може да се направи семпла мултиплеър игра на този принцип … ще експериментирам малко :)

  1. There are no trackbacks for this post yet.

Leave a Reply