Skip to main content
Known Participant
March 17, 2011
Question

Disable swf bsed on cookie

  • March 17, 2011
  • 1 reply
  • 357 views

Hi:

  I have js all set up and tested to check for cookie. If cookie set I ant to disable the swf.

The code in my AS is as follows::

import fl.video.*;
import fl.video.MetadataEvent;
import flash.external.ExternalInterface;
import flash.system.fscommand;
//-----------------------------------------
function checkSpokesman() {
   trace("execution in CheckSpokesman");   
   var Play:int = ExternalInterface.call("checkCookie");
   if (Play == 0) {
   fscommand("quit");
   }
}

the rest of the AS is unrelated to this process.

The Js reutrns 0 if the cookie set or 1 of not.

I really don't want to use a cue on the time line to call this function. Is there some other way to get the function ot execute before the swf is run?

I have also tried to use js to checkCookie and do get the return with:

<script type="text/javascript">
document.write(checkCookie());
</script>

The doc write is for testing and the call works fine.

First of all if I try this:

<script type="text/javascript">

var play:int;

play = checkCookie());
</script>

and have this in the init() called by page load it does not work. I was going to use the play variable to kill the loading of the swf

but can't figure out how best to make that work.

So,  my questions:

Best way to facilitate this action:

1. In AS by calling the function by:

   a. Timeline

   b. AS callback from <body onLoad

2. Using js to call the fucntion in the external js and then blocking loading of the swf  in the html page.

I don't want to spend anymore time exploring alternatives as this is very frustrating.  I am assuming that 1.b is the best route.

Rhanks and best regards.

This topic has been closed for replies.

1 reply

tultalkAuthor
Known Participant
March 17, 2011

Well, adding checkSpokesman(); on the AS seems to execute the function (as evidenced by setting cookie and flashing the trace.

The problem now is the video plays anyway. I asumed that fscommand("quit") would kick out of the function without executing the rest.

import fl.video.*;
import fl.video.MetadataEvent;
import flash.external.ExternalInterface;
import flash.system.fscommand;
//-----------------------------------------
function checkSpokesman() {
   trace("execution in CheckSpokesman");   
   var Play:int = ExternalInterface.call("checkCookie");
   if (Play == 0) {
   fscommand("quit");
   }
}

checkSpokesman();

tultalkAuthor
Known Participant
March 17, 2011

function checkSpokesman() {
   trace("execution in CheckSpokesman");   
   var Play:int = ExternalInterface.call("checkCookie");
//   if (Play == 0) {
   fscommand("quit");
//   }
}

I tested with the if commented out so it had to execute the fscommand("quit"); and it did not quit. The video played.

So, how do you abort this process so no video plays???

THanks

tultalkAuthor
Known Participant
March 18, 2011

Disregard this post. I have this working not but a new issue in new thread entitled "button Visibility"