Google Answers Logo
View Question
 
Q: Passing Variables in Flash for an Affiliate Program ( Answered,   0 Comments )
Question  
Subject: Passing Variables in Flash for an Affiliate Program
Category: Computers > Programming
Asked by: jr1734-ga
List Price: $26.00
Posted: 01 Nov 2002 22:07 PST
Expires: 01 Dec 2002 22:07 PST
Question ID: 96173
My website publishes on-line video content and is putting together an
affiliate program.  Our billing solution needs a variable to track who
the affiliate is.

We need to assign a tracking variable, give it to our partners, have
it persist through our flash based website and terminate at the URL
for our order path.

Here are the specifics:

Our billing partner uses "rsrc=affiliate" as the variable and expects
an order path URL in the following format -
"http://www.blank.com/blankpass/index.html?pcode={pcode}&rsrc=affiliate"

My site is done entirely in Flash MX, published in Flash Player
Version 4 and only uses the Actions-BrowserNetwork-GetURL command in
our movies.

I assume I give our partners our URL in the following form -
http://www.mywebsite.com?rsrc=affiliate.

How do I code my flash movies/HTML so that the "rsrc=affiliate"
persists throughout potential customers tour through my website?

Request for Question Clarification by studboy-ga on 02 Nov 2002 23:47 PST
Hi,

Is your client using Netscape?

Please take a look at:

http://www.michael-thomas.com/flash/examples/

Got to the bottom of the page and download the HtmlToFlash (wrapper) example.
Basically, the trick is to use a dynamic text object inside the Flash
and then calling the your swf file like this:

flash.swf?var=value

I test it in both Netscape and IExplorer, and like what they mention inside
the comments within the example, IExplorer does not seem to work.
Perhaps you have better luck.  In either case, let me know if this works
for you and I can turn this into a formal answer.  Thanks.

Clarification of Question by jr1734-ga on 03 Nov 2002 01:04 PST
Three clarifications:

1. This solution needs to work for both IE and Netscape on PCs and
MACs.

2. There will be multiple affiliate codes (one for each partner) so
the solution must support passing dynamic variables.

3. On the partners website, they will have a link to my website with
(I believe) the following form -
http://www.thehawaiinetwork.com?rsrc=affiliatecode
The affiliate code would then need to persist throughtout the user's
stay on my site util they clicked to sign up
(http://www.real.com/openpass/openpass.html?pcode=hawaii&rsrc=affiliatecode)


Studboy, I hope this helps.  As for you suggestion, I do not know if
it will work or not as your explanation went over my head.  Given my
clarification, please advise.  If your current solution does meet this
paramaters, please elaborate on the solution so I can implement.

Thank you very much.

Request for Question Clarification by studboy-ga on 03 Nov 2002 12:51 PST
Hi,

What I meant was the only way to pass a dynamic variable in Flash Player 4
is through a Javascript method which extracts your rsrc=affiliatecode
from the URL and then invoking your flash.swf wath flash.swf?rsrc=affiliatecode.

ie, see Macromedia website:

http://www.macromedia.com/support/flash/ts/documents/set_variables.htm#querystring

This page specifically mentions that it will NOT work for Internet Explorer
on MAC.

If you want it to work you must upgrade to Flash 6, where you can use Flashvars
to pass the parameters after you extract it with the Javascript:

http://www.macromedia.com/support/flash/ts/documents/flashvars.htm

I hope I answer your question clearly this time.  Please let me know if
my answer answers your question--I will post a formal answer then.

Thanks

Request for Question Clarification by studboy-ga on 05 Nov 2002 15:49 PST
Dear jr1734-ga

Were you able to upgrade to Flash 6?  Or are you still
looking for me to find a Flash 4 answer for you?

Thanks
Answer  
Subject: Re: Passing Variables in Flash for an Affiliate Program
Answered By: skorba-ga on 13 Nov 2002 02:40 PST
 
Dear jr1734


Your question seems straight forward to me. Let me try to break it
down - and supply snippets of code where that is pertinent.

1)

<<
I give our partners our URL in the following form:
http://www.mywebsite.com?rsrc=affiliate
>>

The customer finds your affiliate's site, sees a banner for your
service, and clicks the above mentioned link. Then the customer arrive
at your server.

2)
Your setup: You did not mention anything about your server, or the
kind of server side script options you have available, so I will
assume that you want this done without resorting to anything more than
the scripting available in Explorer / Netscape.

The Buyer downloads a HTML document with this URL from your server.
http://www.mywebsite.com?rsrc=affiliate

First you need to extract the part after the question mark from the
URL. This part is called the "query string", and if the query string
consist of any non-ascii letters, they are URL-encoded.  Extracting
the query string can be very eaily done with Javascript. Here are some
lines of code for extracting the query string and making sure that :

Javascript Code:

function getQueryString()
{
     str = document.location.search;
     return str;
}

(Note: If you use the Apache web server, this can be very easily done
with something called SSI - server side includes. And other servers
have other options. But as I said, it can be done perfectly well with
Javascript, so if you don't know about server side scripting, you do
not have to worry.)


3)
Now you have the query string. All that remains is to get that string
into you flash movie. To do that you need to ADD the query string to
the path pointing to your flash movie:

Let us say that your movie is named "mymovie.swf". You need to embed
"mymovie.swf?rsrc=affiliate" in the HTML code. Let us further say that
the movie has background color #000000 (black), it is 600 pixels wide
and 400 pixels tall. Then the final embedded code should look like
this:

<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="600" height="400">
  <param name="movie" value="mymovie.swf?rsrc=affiliate">
  <param name="quality" value="best">
  <param name="menu" value="false">
  <param name="align" value="lt">
  <param name="scale" value="exactfit">
  <param name="bgcolor" value="#000000">
<embed
  src="mymovie.swf?rsrc=affiliate"
  quality="best" scale="exactfit" salign="lt" menu="false"
  bgcolor="#000000"
  width="600"
  height="400"
  type="application/x-shockwave-flash"
  pluginspage="http://www.macromedia.com/shockwave/download/index.cgi?p1_prod_version=shockwaveflash">
</embed></object>


Are you with me so far? This is the way Macromedia recommends solving
the problems of using flash in banner campaigns etc.
Here is a link to the Macromedia Training Center for rich media
banners:
http://www.macromedia.com/resources/richmedia/tracking/

4)
You need to generate the code above on the fly, and that too can be
done with Javascript:

Javascript Code:

function flash4EmbedCode (mov_src, mov_wdt, mov_hgt, mov_col)
{
   embed_code  = '<object \n';
   embed_code += '  classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000"
\n';
   embed_code += '  codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=5,0,0,0"\n';
   embed_code += '  width="' + mov_wdt + '" height="' + mov_hgt +
'">\n';
   embed_code += '  <param name="movie" value="' + mov_src + '">\n';
   embed_code += '  <param name="quality" value="best">\n';
   embed_code += '  <param name="menu" value="false">\n';
   embed_code += '  <param name="align" value="lt">\n';
   embed_code += '  <param name="scale" value="exactfit" \n';
   embed_code += '  <param name="bgcolor" value="' + mov_col + '">\n';
   embed_code += '<embed \n';
   embed_code += '  src="' + mov_src + '" \n';
   embed_code += '  quality="best" scale="exactfit" salign="lt"
menu="false" \n';
   embed_code += '  bgcolor=' + mov_col + ' \n';
   embed_code += '  width="' + mov_wdt + '" \n';
   embed_code += '  height="' + mov_hgt + '" \n';
   embed_code += '  type="application/x-shockwave-flash" \n';
   embed_code += '  pluginspage="http://www.macromedia.com/shockwave/download/index.cgi?p1_prod_version=shockwaveflash">\n';
   embed_code += '</embed></object>';
   return embed_code;
}

5)
Bringing the javascript together. 

All you need to do is to embed this chunk of code in an HTML document
wher you want the movie to appear:

<script type="text/javascript><!--

// this you have to set
var src = "mymovie.swf";
var wdt = "600";
var hgt = "400";
var col = "#000000";

function getQueryString()
{
     str = document.location.search;
     return str;
}
// gets the query information
src = src + getQueryString();


function flash4EmbedCode (mov_src, mov_wdt, mov_hgt, mov_col)
{
   embed_code  = '<object \n';
   embed_code += '  classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000"
\n';
   embed_code += '  codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=5,0,0,0"\n';
   embed_code += '  width="' + mov_wdt + '" height="' + mov_hgt +
'">\n';
   embed_code += '  <param name="movie" value="' + mov_src + '">\n';
   embed_code += '  <param name="quality" value="best">\n';
   embed_code += '  <param name="menu" value="false">\n';
   embed_code += '  <param name="align" value="lt">\n';
   embed_code += '  <param name="scale" value="exactfit" \n';
   embed_code += '  <param name="bgcolor" value="' + mov_col + '">\n';
   embed_code += '<embed \n';
   embed_code += '  src="' + mov_src + '" \n';
   embed_code += '  quality="best" scale="exactfit" salign="lt"
menu="false" \n';
   embed_code += '  bgcolor=' + mov_col + ' \n';
   embed_code += '  width="' + mov_wdt + '" \n';
   embed_code += '  height="' + mov_hgt + '" \n';
   embed_code += '  type="application/x-shockwave-flash" \n';
   embed_code += '  pluginspage="http://www.macromedia.com/shockwave/download/index.cgi?p1_prod_version=shockwaveflash">\n';
   embed_code += '</embed></object>';
   return embed_code;
}

// generates the embed code
var embed_code = flash4EmbedCode (src, wdt, hgt, col);

// actally embeds the movie
document.write (embed_code);

//--></script>


Phew! Are you with me so far ?

6)

At this moment the information we need actually resides on the main
timeline (what you would call '_level0' in action script terminology).

I assume that you have some kind of actionscripting to keep track of
what the customers order (that would be the pcode part below).
Actually opening the URL that confirms the order is the easy part. All
you need is to append the 'affiliate code' (that resides in level 0)
to the other information generated by the flash movie. The
actionscript command would look like this:

Flash actinscript (on a button)

on (release) 
{
  getURL ("http://www.blank.com/blankpass/index.html?" add
"pcode=pcode&" add "rsrc=" add _level0:rsrc);
}


7)
You are done!

This solution works in Flash 4 movies, in Netscape and Explorer and
Mozilla and Opera, on a Mac and on a PC.

Good luck!
Comments  
There are no comments at this time.

Important Disclaimer: Answers and comments provided on Google Answers are general information, and are not intended to substitute for informed professional medical, psychiatric, psychological, tax, legal, investment, accounting, or other professional advice. Google does not endorse, and expressly disclaims liability for any product, manufacturer, distributor, service or service provider mentioned or any opinion expressed in answers or comments. Please read carefully the Google Answers Terms of Service.

If you feel that you have found inappropriate content, please let us know by emailing us at answers-support@google.com with the question ID listed above. Thank you.
Search Google Answers for
Google Answers  


Google Home - Answers FAQ - Terms of Service - Privacy Policy