How to read HTML cookie in Flash?

I hope this will be pointed in the right direction. The problem I am facing is trying to figure out how to read the generated HTML cookie in Flash. I have a video player that should automatically start once in 24 hours, and the next day it should automatically start for the end user.

Here's what the script page looks like on an HTML page that displays a Flash player and cookie:

<script type="text/javascript">
var so = new SWFObject("flvplayer.swf", "mymovie", "640", "394", "8", "#90ab69");
var x = readCookie('homepageIntro') // <- The Cookie (How do I read this in Flash?)
so.addParam("quality", "high");
so.addParam("wmode", "transparent");
so.useExpressInstall('expressinstall.swf');
so.addVariable("autostart", "false");
so.addVariable("file", "video.flv");
so.addVariable("key", "");
so.addVariable("showfsbutton", "false");
so.addVariable("noControls", "false");
so.addVariable("home", "true");
so.write("flashcontent");
</script>

Not knowing how to read this var xinside Flash, I tried to get around using it using a Flash cookie, however now the video player will only ever automatically start and will never start again (it cannot clear the Flash cookie).

public function sharedObjectCheck():void
{
    if (mySharedObject.data.flashCookie == "true"){
        //Code to NOT autoplay video
    } else if (mySharedObject.data.flashCookie == null){
        mySharedObject.data.flashCookie = "true"; //if first time, set the cookie value
        mySharedObject.flush(); //add the cookie
    }
}

HTML- Flash- ( ...), Flash, .

, -- - , var x (cookie) Flash?

+3
3

ExternalInterface

import flash.external.*

try {
  var cookie : String = ExternalInterface.call("readCookie", "homepageIntro") as String;
} catch (error : SecurityError) {
  trace("SecurityError:", e.message);
} catch (error : Error) {
  trace("Error:", e.message);
}

, allowScriptAccess, .

LSO, , x FlashVar.

+3

x flashvars?

so.addVariable("cookie", x);

Flash, :

var params:Object = this.loaderInfo.parameters;
var cookie:Object = params.cookie;
+1

Do this with a flash cookie, but actually save the last time the autoplay, not a simple flag.

0
source

Source: https://habr.com/ru/post/1778745/


All Articles