Solved

Annoying Music in flash movies.

Posted on 2002-04-19
51
454 Views
Last Modified: 2010-04-03
Can flash be programmed so that when a person clicks a "no sound" or "sound off" button on one flash movie that it knows not to load the music again...

I'm not sure how this would be achieved unless a cookie of some type could be read into the movie.

It would be cool for the movie to remember (last time you were here you turned off the music so don't play it this time)

Trudy
0
Comment
Question by:trudymaresch
  • 28
  • 23
51 Comments
 
LVL 2

Expert Comment

by:thor918
ID: 6957730
Hi Trudy, what version of flash are you developing with?
You could use cookies like this, using javscript ->
Example :
http://hammar.no/users/thor/submit/passcookie.html
Source :
http://hammar.no/users/thor/submit/passcookie.fla
http://hammar.no/users/thor/submit/passcookie.swf

But if you have the new flash mx.. Fetching cookies are builtin :D so you don't need javascript.. you can do it directly with flash using "local Shared Object"..
Read here:
http://www.macromedia.com/support/flash/ts/documents/local_so.htm

Hope this helps you ;)
Best regards
Thor
0
 
LVL 2

Expert Comment

by:thor918
ID: 6957745
one little thing.. The flash needs a little delay to get the cookie from the javascript to flash... my example have a a very small delay.. so that it may not work all the time.. Try adding a longer delay.. or you could make the flash wait for the javascript to pass a "okey" string back..
0
 
LVL 2

Expert Comment

by:thor918
ID: 6959501
0
 
LVL 2

Expert Comment

by:thor918
ID: 6959533
0
 

Author Comment

by:trudymaresch
ID: 6959652
I am using Flash 5.
0
 
LVL 2

Expert Comment

by:thor918
ID: 6959673
0
 
LVL 2

Expert Comment

by:thor918
ID: 6959704
and in the first example.. If you want the sound to stop quickly when you press the stop button.. you can change the action script to set the volum instead :

tellTarget ("music") {
  stop (); //stop playing the movieclip with sound
}

replace with :

tellTarget ("music") {
 musicobj=new Sound(music);
 musicobj.setVolume(0); //sets the volume off
}


and if you are looking on how to implant a sound look at this Tutorial : http://www.flashkit.com/tutorials/Audio/Sound_Vo-Sanjeevi-469/index.shtml
0
 
LVL 2

Expert Comment

by:thor918
ID: 6959723
huh made an error in the post..

The on button action script :
on (release) {
     tellTarget ("music") {
       gotoAndPlay ( 2 ); //start playing the movieclip with sound and jump over the stop action script in first frame
     }
       musicobj=new Sound(music);
       musicobj.setVolume(100); //sets the volume off

  musicstate = "on";//setting dynamic text field
  fscommand ("writesound", musicstate); //sending a command to javascript.. and javascript then writes a cookie
}

the off button action script :
on (release) {
      musicobj=new Sound(music);
      musicobj.setVolume(0); //sets the volume off
  musicstate = "off";//setting dynamic text field
  fscommand ("writesound", musicstate); //sending a command to javascript.. the javascript then writes a cookie
}

0
 

Author Comment

by:trudymaresch
ID: 6959727
This looks really good- I'm going to try to get it to work on my movie now.

I'll let you know how it goes.
0
 

Author Comment

by:trudymaresch
ID: 6959747
Does this need an On & Off button?  The movies loads with the music in a "ON" status. So if they turn it off, reload the page with it off - they need to turn it back on. - How do I only show 1 button for this.
0
 
LVL 2

Expert Comment

by:thor918
ID: 6959752
:D Sorry about the bad sound clip in my example.. hehe I just took one of the sounds that follows the "flash 5"

I'm looking forward to hear how it goes ;)
0
 

Author Comment

by:trudymaresch
ID: 6959757
Forget that last question, I can put "turn music back on" button on the next frame.... with the different actionscript.
0
 

Author Comment

by:trudymaresch
ID: 6959777
For this movie, if the cookie could tell the movie where to start playing from instead of adjusting the volume this would work better for my movie.
0
 
LVL 2

Expert Comment

by:thor918
ID: 6959779
okey.. I will give you the code anyway.. Here is one button with on and off

on (release) {
if(musicstate == "off"){
//the on code start
     tellTarget ("music") {
       gotoAndPlay ( 2 ); //start playing the movieclip with sound and jump over the stop action script in first frame
     }
       musicobj=new Sound(music);
       musicobj.setVolume(100); //sets the volume off

  musicstate = "on";//setting dynamic text field
  fscommand ("writesound", musicstate); //sending a command to javascript.. and javascript then writes a cookie
//the on code end
}else{
//the off code start
      musicobj=new Sound(music);
      musicobj.setVolume(0); //sets the volume off
  musicstate = "off";//setting dynamic text field
  fscommand ("writesound", musicstate); //sending a command to javascript.. the javascript then writes a cookie
//the off code end
}
}
0
 
LVL 2

Expert Comment

by:thor918
ID: 6959802
okey.. but start playing where.. in the main timeline or in one of the movie clips?
0
 

Author Comment

by:trudymaresch
ID: 6959804
Okay - I hope I can get it to work...

Thanks!
0
 

Author Comment

by:trudymaresch
ID: 6959823
Still back on your previous answer - witht he new code you've shown for a 1 button movie
0
 

Author Comment

by:trudymaresch
ID: 6959830
Which page example should I look at for the javascript?
0
 
LVL 2

Expert Comment

by:thor918
ID: 6959838
http://hammar.no/users/thor/submit/passcookie.html

here is the html&javascript->
<HTML>
<HEAD>
<TITLE>loadtext</TITLE>
<SCRIPT LANGUAGE="JavaScript">
<!-- Begin
//******************************************************************************************
//These are variables you must set. In order to get the FSCommand to work in Flash, YOU MUST
//also add the NAME parameter to the EMBED tag and the ID parameter to the OBJECT tag. These
//two must be the same and match the "moviename" variable. They DO NOT have to match the name
//of your Flash movie. Look at the bottom of this file.
var moviename = "thenameofyourmovie";
var flashInputVar = "Filename";
// Created by Kent Del Castillo - http://www.kentd.com - kent@kentd.com
// Modified by Thor Selnes thor918@online.no
//******************************************************************************************

function thenameofyourmovie_DoFSCommand(command, args){
      if(command == "writesound"){ // writes a cookie from flash
           SetCookie("soundstate", args);//setts the cookie
      }
       if(command == "readsound"){ // read off the sound state and pass it to flash
         var soundstatecookie = GetCookie("soundstate"); //getting the cookie
         if(!soundstatecookie){soundstatecookie="off";}//the cookie is not set and the default value is to have the sound turned off in the flash
         movieobject(moviename).SetVariable("musicstate", soundstatecookie); //pass a variable back to flash
      }

}

function movieobject(moviename)
{
//IE and Netscape refer to the movie object differently.
//This function returns the appropriate syntax depending on the browser.

      if (navigator.appName.indexOf ("Microsoft") !=-1)
      {
      return window[moviename]
      }
      else
      {
      return document[moviename]
      }
}

//COOKIE CODE BELOW
var expDays = 365; // number of days the cookie should last

function GetCookie (name) {  
var arg = name + "=";  
var alen = arg.length;  
var clen = document.cookie.length;
var i = 0;  
while (i < clen) {    
var j = i + alen;    
if (document.cookie.substring(i, j) == arg) {    
return getCookieVal (j);   }
i = document.cookie.indexOf(" ", i) + 1;    
if (i == 0) break;  
}  
return null;
}
function SetCookie (name, value) {  
var argv = SetCookie.arguments;  
var argc = SetCookie.arguments.length;  
var expires = (argc > 2) ? argv[2] : null;  
var path = (argc > 3) ? argv[3] : null;  
var domain = (argc > 4) ? argv[4] : null;  
var secure = (argc > 5) ? argv[5] : false;  
document.cookie = name + "=" + escape (value) +
((expires == null) ? "" : ("; expires=" + expires.toGMTString())) +
((path == null) ? "" : ("; path=" + path)) +  
((domain == null) ? "" : ("; domain=" + domain)) +    
((secure == true) ? "; secure" : "");
}
function DeleteCookie (name) {  
var exp = new Date();  
exp.setTime (exp.getTime() - 1);  
var cval = GetCookie (name);  
document.cookie = name + "=" + cval + "; expires=" + exp.toGMTString();
movieobject(moviename).SetVariable(fullVar, "");
}
var exp = new Date();
exp.setTime(exp.getTime() + (expDays*24*60*60*1000));
function amt(){
var count = GetCookie('count')
if(count == null) {
SetCookie('count','1')
return 1
}
else {
var newcount = parseInt(count) + 1;
DeleteCookie('count')
SetCookie('count',newcount,exp)
return count
   }
}
function getCookieVal(offset) {
var endstr = document.cookie.indexOf (";", offset);
if (endstr == -1)
endstr = document.cookie.length;
return unescape(document.cookie.substring(offset, endstr));
}

// End -->
</SCRIPT>
<SCRIPT LANGUAGE="VBScript">
<!--
//  Catch FS Commands in IE, and pass them to the corresponding JavaScript function.
Sub thenameofyourmovie_FSCommand(ByVal command, ByVal args)
    call thenameofyourmovie_DoFSCommand(command, args)
end sub
//-->
</SCRIPT>
</HEAD>
<BODY bgcolor="#FFFFFF">
<OBJECT classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000"
 codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=5,0,0,0"
 WIDTH=550 HEIGHT=400 ID="thenameofyourmovie">
 <PARAM NAME=movie VALUE="passcookie.swf"> <PARAM NAME=quality VALUE=high> <PARAM NAME=bgcolor VALUE=#FFFFFF> <EMBED NAME="thenameofyourmovie" src="passcookie.swf" quality=high bgcolor=#FFFFFF  WIDTH=550 HEIGHT=400 TYPE="application/x-shockwave-flash" PLUGINSPAGE="http://www.macromedia.com/shockwave/download/index.cgi?P1_Prod_Version=ShockwaveFlash"></EMBED>
</OBJECT>
</BODY>
</HTML>

0
 
LVL 2

Expert Comment

by:thor918
ID: 6959970
Do you need more help? just ask :D
0
 

Author Comment

by:trudymaresch
ID: 6959975
Javascript working, movie working, however cookie not working - any ideas
0
 
LVL 2

Expert Comment

by:thor918
ID: 6959980
You can by the way remove this from the script..
var flashInputVar = "Filename";

It is not needed;)
0
 
LVL 2

Expert Comment

by:thor918
ID: 6959987
have you changed anything in the html/javascript? if so post it..
0
 

Author Comment

by:trudymaresch
ID: 6960012
The only thing I changed was the moviename variable


<SCRIPT LANGUAGE="JavaScript">
<!-- Begin
//******************************************************************************************
//These are variables you must set. In order to get the FSCommand to work in Flash, YOU MUST
//also add the NAME parameter to the EMBED tag and the ID parameter to the OBJECT tag. These
//two must be the same and match the "moviename" variable. They DO NOT have to match the name
//of your Flash movie. Look at the bottom of this file.
var moviename = "nodiamonds";
var flashInputVar = "Filename";
// Created by Kent Del Castillo - http://www.kentd.com - kent@kentd.com
// Modified by Thor Selnes thor918@online.no
//******************************************************************************************

function nodiamonds_DoFSCommand(command, args){
     if(command == "writesound"){ // writes a cookie from flash
           SetCookie("soundstate", args);//setts the cookie
     }
      if(command == "readsound"){ // read off the sound state and pass it to flash
         var soundstatecookie = GetCookie("soundstate"); //getting the cookie
         if(!soundstatecookie){soundstatecookie="off";}//the cookie is not set and the default value is to have the sound turned off in the flash
         movieobject(moviename).SetVariable("musicstate", soundstatecookie); //pass a variable back to flash
     }

}

function movieobject(moviename)
{
//IE and Netscape refer to the movie object differently.
//This function returns the appropriate syntax depending on the browser.

     if (navigator.appName.indexOf ("Microsoft") !=-1)
     {
     return window[moviename]
     }
     else
     {
     return document[moviename]
     }
}

//COOKIE CODE BELOW
var expDays = 365; // number of days the cookie should last

function GetCookie (name) {  
var arg = name + "=";  
var alen = arg.length;  
var clen = document.cookie.length;
var i = 0;  
while (i < clen) {    
var j = i + alen;    
if (document.cookie.substring(i, j) == arg) {    
return getCookieVal (j);   }
i = document.cookie.indexOf(" ", i) + 1;    
if (i == 0) break;  
}  
return null;
}
function SetCookie (name, value) {  
var argv = SetCookie.arguments;  
var argc = SetCookie.arguments.length;  
var expires = (argc > 2) ? argv[2] : null;  
var path = (argc > 3) ? argv[3] : null;  
var domain = (argc > 4) ? argv[4] : null;  
var secure = (argc > 5) ? argv[5] : false;  
document.cookie = name + "=" + escape (value) +
((expires == null) ? "" : ("; expires=" + expires.toGMTString())) +
((path == null) ? "" : ("; path=" + path)) +  
((domain == null) ? "" : ("; domain=" + domain)) +    
((secure == true) ? "; secure" : "");
}
function DeleteCookie (name) {  
var exp = new Date();  
exp.setTime (exp.getTime() - 1);  
var cval = GetCookie (name);  
document.cookie = name + "=" + cval + "; expires=" + exp.toGMTString();
movieobject(moviename).SetVariable(fullVar, "");
}
var exp = new Date();
exp.setTime(exp.getTime() + (expDays*24*60*60*1000));
function amt(){
var count = GetCookie('count')
if(count == null) {
SetCookie('count','1')
return 1
}
else {
var newcount = parseInt(count) + 1;
DeleteCookie('count')
SetCookie('count',newcount,exp)
return count
   }
}
function getCookieVal(offset) {
var endstr = document.cookie.indexOf (";", offset);
if (endstr == -1)
endstr = document.cookie.length;
return unescape(document.cookie.substring(offset, endstr));
}

// End -->
</SCRIPT>
<SCRIPT LANGUAGE="VBScript">
<!--
//  Catch FS Commands in IE, and pass them to the corresponding JavaScript function.
Sub nodiamonds_FSCommand(ByVal command, ByVal args)
    call nodiamonds_DoFSCommand(command, args)
end sub
//-->
</SCRIPT>
0
 

Author Comment

by:trudymaresch
ID: 6960023
Now - there is a javascript error??
0
How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

 

Author Comment

by:trudymaresch
ID: 6960070
On page load errors:

line 38
Char 4 expected ';'

then

line 125
Char 4
Error - Type Mismatch 'thenameofyourmovie_doFSCommand'

and same error when I click soundoff


0
 
LVL 2

Expert Comment

by:thor918
ID: 6960075
hmm I can't see why.. but I changed the movie name myself and It worked :
<HTML>
<HEAD>
<TITLE>loadtext</TITLE>
<SCRIPT LANGUAGE="JavaScript">
<!-- Begin
//******************************************************************************************
//These are variables you must set. In order to get the FSCommand to work in Flash, YOU MUST
//also add the NAME parameter to the EMBED tag and the ID parameter to the OBJECT tag. These
//two must be the same and match the "moviename" variable. They DO NOT have to match the name
//of your Flash movie. Look at the bottom of this file.
var moviename = "nodiamonds";
// Created by Kent Del Castillo - http://www.kentd.com - kent@kentd.com
// Modified by Thor Selnes thor918@online.no
//******************************************************************************************

function nodiamonds_DoFSCommand(command, args){
      if(command == "writesound"){ // writes a cookie from flash
           SetCookie("soundstate", args);//setts the cookie
      }
       if(command == "readsound"){ // read off the sound state and pass it to flash
         var soundstatecookie = GetCookie("soundstate"); //getting the cookie
         if(!soundstatecookie){soundstatecookie="off";}//the cookie is not set and the default value is to have the sound turned off in the flash
         movieobject(moviename).SetVariable("musicstate", soundstatecookie); //pass a variable back to flash
      }

}

function movieobject(moviename)
{
//IE and Netscape refer to the movie object differently.
//This function returns the appropriate syntax depending on the browser.

      if (navigator.appName.indexOf ("Microsoft") !=-1)
      {
      return window[moviename]
      }
      else
      {
      return document[moviename]
      }
}

//COOKIE CODE BELOW
var expDays = 365; // number of days the cookie should last

function GetCookie (name) {  
var arg = name + "=";  
var alen = arg.length;  
var clen = document.cookie.length;
var i = 0;  
while (i < clen) {    
var j = i + alen;    
if (document.cookie.substring(i, j) == arg) {    
return getCookieVal (j);   }
i = document.cookie.indexOf(" ", i) + 1;    
if (i == 0) break;  
}  
return null;
}
function SetCookie (name, value) {  
var argv = SetCookie.arguments;  
var argc = SetCookie.arguments.length;  
var expires = (argc > 2) ? argv[2] : null;  
var path = (argc > 3) ? argv[3] : null;  
var domain = (argc > 4) ? argv[4] : null;  
var secure = (argc > 5) ? argv[5] : false;  
document.cookie = name + "=" + escape (value) +
((expires == null) ? "" : ("; expires=" + expires.toGMTString())) +
((path == null) ? "" : ("; path=" + path)) +  
((domain == null) ? "" : ("; domain=" + domain)) +    
((secure == true) ? "; secure" : "");
}
function DeleteCookie (name) {  
var exp = new Date();  
exp.setTime (exp.getTime() - 1);  
var cval = GetCookie (name);  
document.cookie = name + "=" + cval + "; expires=" + exp.toGMTString();
movieobject(moviename).SetVariable(fullVar, "");
}
var exp = new Date();
exp.setTime(exp.getTime() + (expDays*24*60*60*1000));
function amt(){
var count = GetCookie('count')
if(count == null) {
SetCookie('count','1')
return 1
}
else {
var newcount = parseInt(count) + 1;
DeleteCookie('count')
SetCookie('count',newcount,exp)
return count
   }
}
function getCookieVal(offset) {
var endstr = document.cookie.indexOf (";", offset);
if (endstr == -1)
endstr = document.cookie.length;
return unescape(document.cookie.substring(offset, endstr));
}

// End -->
</SCRIPT>
<SCRIPT LANGUAGE="VBScript">
<!--
//  Catch FS Commands in IE, and pass them to the corresponding JavaScript function.
Sub nodiamonds_FSCommand(ByVal command, ByVal args)
    call nodiamonds_DoFSCommand(command, args)
end sub
//-->
</SCRIPT>
</HEAD>
<BODY bgcolor="#FFFFFF">
<OBJECT classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000"
 codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=5,0,0,0"
 WIDTH=550 HEIGHT=400 ID="nodiamonds">
 <PARAM NAME=movie VALUE="passcookie.swf"> <PARAM NAME=quality VALUE=high> <PARAM NAME=bgcolor VALUE=#FFFFFF> <EMBED NAME="nodiamonds" src="passcookie.swf" quality=high bgcolor=#FFFFFF  WIDTH=550 HEIGHT=400 TYPE="application/x-shockwave-flash" PLUGINSPAGE="http://www.macromedia.com/shockwave/download/index.cgi?P1_Prod_Version=ShockwaveFlash"></EMBED>
</OBJECT>
</BODY>
</HTML>
0
 

Author Comment

by:trudymaresch
ID: 6960088
I changed it back to "thenameofyourmovie" and got the same errors, are you using the "one button" actionscript?
0
 
LVL 2

Expert Comment

by:thor918
ID: 6960092
have you changed the embed name and the object id to nodiamonds? try my last post instead..
0
 

Author Comment

by:trudymaresch
ID: 6960100
I will cut and past your last post see what happens.
0
 

Author Comment

by:trudymaresch
ID: 6960112
I still get the javascript errors.... I'm surprised your aren't?!?
0
 

Author Comment

by:trudymaresch
ID: 6960123
I'm going to try the javascript from this

http://hammar.no/users/thor/submit/passcookie.html

I didn't get the error on this one.

0
 

Author Comment

by:trudymaresch
ID: 6960139
Okay did that now the first script error is gone, but I now get

line 37
Char 10
undefined is null or not an object.
0
 
LVL 2

Expert Comment

by:thor918
ID: 6960166
Hmm..wait.. I will try to rewrite the code
0
 

Author Comment

by:trudymaresch
ID: 6960237
I'm going to try and use the code I found in the passcookie.fla

At least I know this one works...

I will have to reverse the code in this as the file loads with the music on.

Trudy
0
 
LVL 2

Expert Comment

by:thor918
ID: 6960241
0
 
LVL 2

Expert Comment

by:thor918
ID: 6960277
have you tested out the new files?
0
 

Author Comment

by:trudymaresch
ID: 6960339
Hey its cool - I have to revise my movie because I have only allowed for 2 frames in the main scene and the text only shows up when you mouseover the music icon.

It might take me a few hours to revise the entire file.  I'll let you know.
0
 
LVL 2

Expert Comment

by:thor918
ID: 6960366
okeydoki..
0
 
LVL 2

Expert Comment

by:thor918
ID: 6962066
A good idea is to clear the cach when you are try to make a new swf.. When I tested with the new flash.. the old swf was displayed instead..I had to clear the cach first.

In internet explorer ->
"Goto tools"_"temporary Internet files"_"Delete files"_"Delete offline content"

Have you made it work now?
0
 
LVL 2

Expert Comment

by:thor918
ID: 6962177
There is a errror in the javascript.. The cookies are not written.. sorry.I will post a fix when I get back home.
0
 
LVL 2

Accepted Solution

by:
thor918 earned 145 total points
ID: 6962295
I have uploaded a fix now.. I forgot something with the expire date.. so the cookie expiered at once the browser was restarted..

Here is the html/javascript fixed:
<HTML>
<HEAD>
<TITLE>loadtext</TITLE>
<SCRIPT LANGUAGE="JavaScript">
<!-- Begin
//******************************************************************************************
//These are variables you must set. In order to get the FSCommand to work in Flash, YOU MUST
//also add the NAME parameter to the EMBED tag and the ID parameter to the OBJECT tag. These
//two must be the same and match the "moviename" variable. They DO NOT have to match the name
//of your Flash movie. Look at the bottom of this file.
var moviename = "nodiamonds";
// Created by Kent Del Castillo - http://www.kentd.com - kent@kentd.com
// Modified by Thor Selnes thor918@online.no
//******************************************************************************************
function nodiamonds_DoFSCommand(command, args){
      if(command == "writesound"){ // writes a cookie from flash
           var exp = new Date(); //getting date
           exp.setTime(exp.getTime() + (expDays*24*60*60*1000));//setting expire date
           SetCookie("soundstate", args,exp);//setts the cookie
      }
       if(command == "readsound"){ // read off the sound state and pass it to flash
         var soundstatecookie = GetCookie("soundstate"); //getting the cookie
         if(!soundstatecookie){soundstatecookie="off";}//the cookie is not set and the default value is to have the sound turned off in the flash
         movieobject(moviename).SetVariable("soundstatecookie", soundstatecookie); //pass a variable back to flash
      }

}

function movieobject(moviename)
{
//IE and Netscape refer to the movie object differently.
//This function returns the appropriate syntax depending on the browser.

      if (navigator.appName.indexOf ("Microsoft") !=-1)
      {
      return window[moviename]
      }
      else
      {
      return document[moviename]
      }
}

//COOKIE CODE BELOW
var expDays = 365; // number of days the cookie should last

function GetCookie (name) {  
var arg = name + "=";  
var alen = arg.length;  
var clen = document.cookie.length;
var i = 0;  
while (i < clen) {    
var j = i + alen;    
if (document.cookie.substring(i, j) == arg) {    
return getCookieVal (j);   }
i = document.cookie.indexOf(" ", i) + 1;    
if (i == 0) break;  
}  
return null;
}

function SetCookie (name, value) {  
var argv = SetCookie.arguments;  
var argc = SetCookie.arguments.length;  
var expires = (argc > 2) ? argv[2] : null;  
var path = (argc > 3) ? argv[3] : null;  
var domain = (argc > 4) ? argv[4] : null;  
var secure = (argc > 5) ? argv[5] : false;  
document.cookie = name + "=" + escape (value) +
((expires == null) ? "" : ("; expires=" + expires.toGMTString())) +
((path == null) ? "" : ("; path=" + path)) +  
((domain == null) ? "" : ("; domain=" + domain)) +    
((secure == true) ? "; secure" : "");
}

function getCookieVal(offset) {
var endstr = document.cookie.indexOf (";", offset);
if (endstr == -1)
endstr = document.cookie.length;
return unescape(document.cookie.substring(offset, endstr));
}

// End -->
</SCRIPT>
<SCRIPT LANGUAGE="VBScript">
<!--
//  Catch FS Commands in IE, and pass them to the corresponding JavaScript function.
Sub nodiamonds_FSCommand(ByVal command, ByVal args)
    call nodiamonds_DoFSCommand(command, args)
end sub
//-->
</SCRIPT>
</HEAD>
<BODY bgcolor="#FFFFFF">
<OBJECT classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000"
 codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=5,0,0,0"
 WIDTH=550 HEIGHT=400 ID="nodiamonds">
 <PARAM NAME=movie VALUE="new_passcookie.swf"> <PARAM NAME=quality VALUE=high> <PARAM NAME=bgcolor VALUE=#FFFFFF> <EMBED NAME="nodiamonds" src="new_passcookie.swf" quality=high bgcolor=#FFFFFF  WIDTH=550 HEIGHT=400 TYPE="application/x-shockwave-flash" PLUGINSPAGE="http://www.macromedia.com/shockwave/download/index.cgi?P1_Prod_Version=ShockwaveFlash"></EMBED>
</OBJECT>
</BODY>
</HTML>
0
 

Author Comment

by:trudymaresch
ID: 6962846
Hi thor918,
I've run into a little problem with my flash and I am trying to reinstall... I haven't been able to try the new javascript yet, my .swf file somehow became corrupt so I couldn't even use it. I am working on it, I'll let you know hopefully later today.

Trudy
0
 
LVL 2

Expert Comment

by:thor918
ID: 6964165
Hei again..
I have upload the fla with a modification..
I added a delay before the fscommand is sent..
The reason is that the javascript sometimes doesn't get the command.. Now it gets the cookie all the time :D

Sorry for all the fixes.I hope you can get it to work now..

http://hammar.no/users/thor/submit/new_passcookie.html
http://hammar.no/users/thor/submit/new_passcookie.fla
http://hammar.no/users/thor/submit/new_passcookie.swf
0
 

Author Comment

by:trudymaresch
ID: 6964372
Thanks, I'll have a look, I was just able (now) to get flash back up and running without errors.

Hopefully I will be able to get back to this tomorrow...
again many thanks for your help.

Trudy
0
 
LVL 2

Expert Comment

by:thor918
ID: 6965391
:D at least now I'm pretty sure that the cookie thing is working.. at least in Internet exploerer.. I haven't got it working with netscape..but it should work
0
 

Author Comment

by:trudymaresch
ID: 6965407
I wish everyone would stop using Netscape - it's a pain for people like us!  Still working out the frames.
0
 
LVL 2

Expert Comment

by:thor918
ID: 6965662
All this standards and browsers(own standards) makes all webthings a bit complicated.. I wished all could use the same standard.. it would make all much easier ;)

Do you have some kind of server side scripting feature on you server?
0
 
LVL 2

Expert Comment

by:thor918
ID: 6966372
http://www.macromedia.com/support/flash/ts/documents/mozilla_fscommand.htm

it seems that netscape6 and mozilla dosen't even support fscommand.. the fscommand is a must for communicating out of the flash..

But the code shold be able to run on older versions of netscape... I havent made it work on my netscape4.08.. perhaps it's to old.. I don't know

I recomend if your visitors uses varies of browsers,, the best thing to do is to upgrade to flash mx..where you don't need javascript to write cookies.
0
 

Author Comment

by:trudymaresch
ID: 6969625
If they have netscape and the cookie isn't working, as long as an error isn't generated in Netscape, I don't care.  Most visitors are still using Internet Explorer.  

Upgrading to Flash mx is not an option at this time (unless its free), but I will keep it in mind for future fscommand problems.

I still haven't been able to get my code to work only because I have run out of time today.  I will hopefully get back to it tomorrow.  I am accepting your answer at this point in any event, but I hope I can count on you if I run into any more problems (ie if netscape produces an error)
0
 
LVL 2

Expert Comment

by:thor918
ID: 6970599
You can count on me :D
Thanks for the points and the grade A :D
0

Featured Post

Find Ransomware Secrets With All-Source Analysis

Ransomware has become a major concern for organizations; its prevalence has grown due to past successes achieved by threat actors. While each ransomware variant is different, we’ve seen some common tactics and trends used among the authors of the malware.

Join & Write a Comment

I come across a lot of question about how to access things in the document class from a movieclip, or accessing something from a movieclip in the document class. It took me a while to figure this out but once I did it makes life so much easier. …
Sometimes you know that one object has a specific child in it, but you can't find the child. This happened to me when I was trying to code some actionScript to make a toolbar work with its embedded buttons.  My partner had created the toolbar usi…
In this tutorial viewers will learn how to create a basic motion tween animation in Flash Open a new document in Flash: Draw/import an image: Press CTRL + F8 to convert it into a graphic symbol: Select a frame (how long you want the tween to last): …
The goal of the tutorial is to teach the user what frame rate is, how to control it and what effect it has on the video.

707 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

15 Experts available now in Live!

Get 1:1 Help Now