Difference between revisions of "Actionscript-Javascript Interaction"

From Wikicliki
Jump to: navigation, search
 
(7 intermediate revisions by 2 users not shown)
Line 1: Line 1:
http://kb.adobe.com/selfservice/viewContent.do?externalId=tn_15683&sliceId=1#exampleas2
+
== Getting xml from asp and into flash ==
  
if this can work
+
http://www.aspnetflash.com/forum/Default.aspx?g=posts&t=172
 +
http://stackoverflow.com/questions/1371164/actionscript-2-0-email-form-loadvars-with-ashx-net-handler
 +
http://www.nathanbaker.com.au/blog/post/Accessing-Web-Services-in-Flash-AS2.aspx
  
http://thinkerbug.com/teststuff/a-ExternalInterfaceExample.html
+
http://kemmis.info/blog/archive/2010/03/24/how-to-save-a-file-from-flash-10-without-user.aspx
  
then you can do it!!!
+
<pre>VoteGetRankingByCategory.ashx
  
http://kb.adobe.com/selfservice/viewContent.do?externalId=tn_15683&sliceId=1#exampleas2
+
?category=junior
  
FUCKIN DO ITTT!!!!!!!!!!!!!!!
+
?category=senior</pre>
  
== SENDING URL TO AS (WORKS IN FF) ==
+
 
 +
== Islands ==
 +
 
 +
5 sept 2008: [http://kb.adobe.com/selfservice/viewContent.do?externalId=tn_15683&sliceId=1#exampleas2 if this can work]... [http://thinkerbug.com/teststuff/a-ExternalInterfaceExample.html you can do it!!!]
 +
SO JUST FUCKIN DO ITTT!!!!!!!!!!!!!!!
 +
12 sept 2008: AND I'VE DONE IT!
  
 
=== JS ===
 
=== JS ===
 +
<pre>
 +
// get flash movie object
 +
function getFlashMovie(northamerika) {
 +
var isIE = navigator.appName.indexOf("Microsoft") != -1;
 +
        return (isIE) ? window[northamerika] : document[northamerika];
 +
}
 +
 +
// javascript gets url and sends it to flash country
 +
function sendIDtoFlash(id) {
 +
var e = (document.getElementById(id));
 +
var IDhttp = e.href;
 +
getFlashMovie("northamerika").sendIDtoFlash(IDhttp);
 +
}
 +
</pre>
 +
 +
=== Actionscript ===
 +
<pre>
 +
import flash.external.ExternalInterface;
 +
 +
// URLWANG!
 +
 +
function getIDfromJavascript(IDhttp):Void{
 +
var MyIDhttp:String;
 +
MyIDhttp = "";
 +
_root.MyIDhttp = IDhttp;
 +
}
 +
ExternalInterface.addCallback("sendIDtoFlash", this, getIDfromJavascript);
 +
 +
 +
// FUNCTIONWANG!
 +
 +
function countryRelease(id) {
 +
ExternalInterface.call("sendIDtoFlash",id);
 +
}
 +
 +
// COUNTRYFUNCTIONWANG!
 +
 +
AG.onRollOver  = function()  {
 +
countryName(true, "Antigua & Barbuda", this);
 +
countryOver("AG");
 +
countryOverHTML("AG");
 +
this.onRollOut = function() {
 +
countryName(false);
 +
countryOut("AG")
 +
countryOutHTML("AG");
 +
this.onRelease = function() {
 +
countryRelease("AG");
 +
getURL(MyIDhttp,  "_parent");}
 +
};
 +
};
 +
</pre>
 +
 +
=== OLD VERSIONS: stage 2: SENDING URL TO AS ===
 +
 +
at this point i got it to work for one country at a time and i had problems with it working in both FF and IE
 +
 +
==== JS ====
 +
this worked in both FF and IE
 +
<pre>
 +
// get flash movie object
 +
function getFlashMovie(australia) {
 +
var isIE = navigator.appName.indexOf("Microsoft") != -1;
 +
        return (isIE) ? window[australia] : document[australia];
 +
}
 +
 +
function sendAUtoFlash() {
 +
var e = (document.getElementById('AU'));
 +
var AUhttp = e.href;
 +
getFlashMovie("australia").sendAUtoFlash(AUhttp);
 +
}
 +
 +
</pre>
 +
 +
this worked only in FF... FUCKING IE SON OF A BITCH!!!!!!!!!!!!!!!!!!
 
<pre>
 
<pre>
 
// get flash movie object
 
// get flash movie object
Line 27: Line 108:
 
}
 
}
 
// window.onload = sendAUtoFlash;
 
// window.onload = sendAUtoFlash;
 +
</pre>
  
 
+
==== AS ====
</pre>
 
=== AS ===
 
  
 
<pre>AU.onRollOver  = function()  {
 
<pre>AU.onRollOver  = function()  {
Line 51: Line 131:
  
  
== SENDING URL AS VARIABLE FROM JS TO AS (WORKING!!!!!!) ==
+
=== OLD VERSION stage 1: SENDING URL AS VARIABLE FROM JS TO AS (WORKING!!!!!!) ===
  
=== JS ===
+
this worked in putting the url into the receiver. but it only worked in FF.
 +
 
 +
==== JS ====
 
<pre>// get flash movie object
 
<pre>// get flash movie object
 
function getFlashMovie(australia) {
 
function getFlashMovie(australia) {
Line 67: Line 149:
 
window.onload = sendAUtoFlash;
 
window.onload = sendAUtoFlash;
 
</pre>
 
</pre>
=== AS2 ===
+
==== AS2 ====
 
<pre>
 
<pre>
 
import flash.external.ExternalInterface;
 
import flash.external.ExternalInterface;
Line 77: Line 159:
 
</pre>
 
</pre>
  
== MAKING FLASH LINK AND JAVASCRIPT LINK LIGHT EACH OTHER UP ==
+
=== OLD VERSION MAKING FLASH LINK AND JAVASCRIPT LINK LIGHT EACH OTHER UP ====
  
 
I needed to make a html file with embedded flash that had the javascript on the html page triggering events in the flash and vice versa. This is an example of the final solution which was used after some coding help from a colleague in cleaning up the terrible mess I made.... (it was cut down from 1100 lines to about 400 lines)
 
I needed to make a html file with embedded flash that had the javascript on the html page triggering events in the flash and vice versa. This is an example of the final solution which was used after some coding help from a colleague in cleaning up the terrible mess I made.... (it was cut down from 1100 lines to about 400 lines)
  
=== HTML & CSS ===
+
==== HTML & CSS ====
  
 
<pre><a id="BM" href="bermuda.html" onMouseover="asMouseOver(this.id)" onMouseout="asMouseOut(this.id)">Bermuda</A></pre>
 
<pre><a id="BM" href="bermuda.html" onMouseover="asMouseOver(this.id)" onMouseout="asMouseOut(this.id)">Bermuda</A></pre>
Line 88: Line 170:
 
[[jQuery]] could be used to create this effect as well...
 
[[jQuery]] could be used to create this effect as well...
  
=== Actionscript ===
+
==== Actionscript ====
  
 
<pre>import flash.external.ExternalInterface;
 
<pre>import flash.external.ExternalInterface;
Line 165: Line 247:
 
</pre>
 
</pre>
  
=== Javascript ===
+
==== Javascript ====
  
 
<pre>// get flash movie object
 
<pre>// get flash movie object
Line 229: Line 311:
  
 
http://blog.deconcept.com/swfobject/forum/discussion/928/movie-not-loaded-in-ie/
 
http://blog.deconcept.com/swfobject/forum/discussion/928/movie-not-loaded-in-ie/
 
+
[[Category:Programming]]
== Scripts for storage ==
 
 
 
'''AC_RunActiveContent.js'''
 
 
 
<pre>
 
//v1.7
 
// Flash Player Version Detection
 
// Detect Client Browser type
 
// Copyright 2005-2007 Adobe Systems Incorporated.  All rights reserved.
 
var isIE  = (navigator.appVersion.indexOf("MSIE") != -1) ? true : false;
 
var isWin = (navigator.appVersion.toLowerCase().indexOf("win") != -1) ? true : false;
 
var isOpera = (navigator.userAgent.indexOf("Opera") != -1) ? true : false;
 
 
 
function ControlVersion()
 
{
 
var version;
 
var axo;
 
var e;
 
 
 
// NOTE : new ActiveXObject(strFoo) throws an exception if strFoo isn't in the registry
 
 
 
try {
 
// version will be set for 7.X or greater players
 
axo = new ActiveXObject("ShockwaveFlash.ShockwaveFlash.7");
 
version = axo.GetVariable("$version");
 
} catch (e) {
 
}
 
 
 
if (!version)
 
{
 
try {
 
// version will be set for 6.X players only
 
axo = new ActiveXObject("ShockwaveFlash.ShockwaveFlash.6");
 
 
// installed player is some revision of 6.0
 
// GetVariable("$version") crashes for versions 6.0.22 through 6.0.29,
 
// so we have to be careful.
 
 
// default to the first public version
 
version = "WIN 6,0,21,0";
 
 
 
// throws if AllowScripAccess does not exist (introduced in 6.0r47)
 
axo.AllowScriptAccess = "always";
 
 
 
// safe to call for 6.0r47 or greater
 
version = axo.GetVariable("$version");
 
 
 
} catch (e) {
 
}
 
}
 
 
 
if (!version)
 
{
 
try {
 
// version will be set for 4.X or 5.X player
 
axo = new ActiveXObject("ShockwaveFlash.ShockwaveFlash.3");
 
version = axo.GetVariable("$version");
 
} catch (e) {
 
}
 
}
 
 
 
if (!version)
 
{
 
try {
 
// version will be set for 3.X player
 
axo = new ActiveXObject("ShockwaveFlash.ShockwaveFlash.3");
 
version = "WIN 3,0,18,0";
 
} catch (e) {
 
}
 
}
 
 
 
if (!version)
 
{
 
try {
 
// version will be set for 2.X player
 
axo = new ActiveXObject("ShockwaveFlash.ShockwaveFlash");
 
version = "WIN 2,0,0,11";
 
} catch (e) {
 
version = -1;
 
}
 
}
 
 
return version;
 
}
 
 
 
// JavaScript helper required to detect Flash Player PlugIn version information
 
function GetSwfVer(){
 
// NS/Opera version >= 3 check for Flash plugin in plugin array
 
var flashVer = -1;
 
 
if (navigator.plugins != null && navigator.plugins.length > 0) {
 
if (navigator.plugins["Shockwave Flash 2.0"] || navigator.plugins["Shockwave Flash"]) {
 
var swVer2 = navigator.plugins["Shockwave Flash 2.0"] ? " 2.0" : "";
 
var flashDescription = navigator.plugins["Shockwave Flash" + swVer2].description;
 
var descArray = flashDescription.split(" ");
 
var tempArrayMajor = descArray[2].split(".");
 
var versionMajor = tempArrayMajor[0];
 
var versionMinor = tempArrayMajor[1];
 
var versionRevision = descArray[3];
 
if (versionRevision == "") {
 
versionRevision = descArray[4];
 
}
 
if (versionRevision[0] == "d") {
 
versionRevision = versionRevision.substring(1);
 
} else if (versionRevision[0] == "r") {
 
versionRevision = versionRevision.substring(1);
 
if (versionRevision.indexOf("d") > 0) {
 
versionRevision = versionRevision.substring(0, versionRevision.indexOf("d"));
 
}
 
}
 
var flashVer = versionMajor + "." + versionMinor + "." + versionRevision;
 
}
 
}
 
// MSN/WebTV 2.6 supports Flash 4
 
else if (navigator.userAgent.toLowerCase().indexOf("webtv/2.6") != -1) flashVer = 4;
 
// WebTV 2.5 supports Flash 3
 
else if (navigator.userAgent.toLowerCase().indexOf("webtv/2.5") != -1) flashVer = 3;
 
// older WebTV supports Flash 2
 
else if (navigator.userAgent.toLowerCase().indexOf("webtv") != -1) flashVer = 2;
 
else if ( isIE && isWin && !isOpera ) {
 
flashVer = ControlVersion();
 
}
 
return flashVer;
 
}
 
 
 
// When called with reqMajorVer, reqMinorVer, reqRevision returns true if that version or greater is available
 
function DetectFlashVer(reqMajorVer, reqMinorVer, reqRevision)
 
{
 
versionStr = GetSwfVer();
 
if (versionStr == -1 ) {
 
return false;
 
} else if (versionStr != 0) {
 
if(isIE && isWin && !isOpera) {
 
// Given "WIN 2,0,0,11"
 
tempArray        = versionStr.split(" "); // ["WIN", "2,0,0,11"]
 
tempString        = tempArray[1]; // "2,0,0,11"
 
versionArray      = tempString.split(","); // ['2', '0', '0', '11']
 
} else {
 
versionArray      = versionStr.split(".");
 
}
 
var versionMajor      = versionArray[0];
 
var versionMinor      = versionArray[1];
 
var versionRevision  = versionArray[2];
 
 
 
        // is the major.revision >= requested major.revision AND the minor version >= requested minor
 
if (versionMajor > parseFloat(reqMajorVer)) {
 
return true;
 
} else if (versionMajor == parseFloat(reqMajorVer)) {
 
if (versionMinor > parseFloat(reqMinorVer))
 
return true;
 
else if (versionMinor == parseFloat(reqMinorVer)) {
 
if (versionRevision >= parseFloat(reqRevision))
 
return true;
 
}
 
}
 
return false;
 
}
 
}
 
 
 
function AC_AddExtension(src, ext)
 
{
 
  if (src.indexOf('?') != -1)
 
    return src.replace(/\?/, ext+'?');
 
  else
 
    return src + ext;
 
}
 
 
 
function AC_Generateobj(objAttrs, params, embedAttrs)
 
{
 
  var str = '';
 
  if (isIE && isWin && !isOpera)
 
  {
 
    str += '<object ';
 
    for (var i in objAttrs)
 
    {
 
      str += i + '="' + objAttrs[i] + '" ';
 
    }
 
    str += '>';
 
    for (var i in params)
 
    {
 
      str += '<param name="' + i + '" value="' + params[i] + '" /> ';
 
    }
 
    str += '</object>';
 
  }
 
  else
 
  {
 
    str += '<embed ';
 
    for (var i in embedAttrs)
 
    {
 
      str += i + '="' + embedAttrs[i] + '" ';
 
    }
 
    str += '> </embed>';
 
  }
 
 
 
  document.write(str);
 
}
 
 
 
function AC_FL_RunContent(){
 
  var ret =
 
    AC_GetArgs
 
    (  arguments, ".swf", "movie", "clsid:d27cdb6e-ae6d-11cf-96b8-444553540000"
 
    , "application/x-shockwave-flash"
 
    );
 
  AC_Generateobj(ret.objAttrs, ret.params, ret.embedAttrs);
 
}
 
 
 
function AC_SW_RunContent(){
 
  var ret =
 
    AC_GetArgs
 
    (  arguments, ".dcr", "src", "clsid:166B1BCA-3F9C-11CF-8075-444553540000"
 
    , null
 
    );
 
  AC_Generateobj(ret.objAttrs, ret.params, ret.embedAttrs);
 
}
 
 
 
function AC_GetArgs(args, ext, srcParamName, classid, mimeType){
 
  var ret = new Object();
 
  ret.embedAttrs = new Object();
 
  ret.params = new Object();
 
  ret.objAttrs = new Object();
 
  for (var i=0; i < args.length; i=i+2){
 
    var currArg = args[i].toLowerCase();   
 
 
 
    switch (currArg){
 
      case "classid":
 
        break;
 
      case "pluginspage":
 
        ret.embedAttrs[args[i]] = args[i+1];
 
        break;
 
      case "src":
 
      case "movie":
 
        args[i+1] = AC_AddExtension(args[i+1], ext);
 
        ret.embedAttrs["src"] = args[i+1];
 
        ret.params[srcParamName] = args[i+1];
 
        break;
 
      case "onafterupdate":
 
      case "onbeforeupdate":
 
      case "onblur":
 
      case "oncellchange":
 
      case "onclick":
 
      case "ondblclick":
 
      case "ondrag":
 
      case "ondragend":
 
      case "ondragenter":
 
      case "ondragleave":
 
      case "ondragover":
 
      case "ondrop":
 
      case "onfinish":
 
      case "onfocus":
 
      case "onhelp":
 
      case "onmousedown":
 
      case "onmouseup":
 
      case "onmouseover":
 
      case "onmousemove":
 
      case "onmouseout":
 
      case "onkeypress":
 
      case "onkeydown":
 
      case "onkeyup":
 
      case "onload":
 
      case "onlosecapture":
 
      case "onpropertychange":
 
      case "onreadystatechange":
 
      case "onrowsdelete":
 
      case "onrowenter":
 
      case "onrowexit":
 
      case "onrowsinserted":
 
      case "onstart":
 
      case "onscroll":
 
      case "onbeforeeditfocus":
 
      case "onactivate":
 
      case "onbeforedeactivate":
 
      case "ondeactivate":
 
      case "type":
 
      case "codebase":
 
      case "id":
 
        ret.objAttrs[args[i]] = args[i+1];
 
        break;
 
      case "width":
 
      case "height":
 
      case "align":
 
      case "vspace":
 
      case "hspace":
 
      case "class":
 
      case "title":
 
      case "accesskey":
 
      case "name":
 
      case "tabindex":
 
        ret.embedAttrs[args[i]] = ret.objAttrs[args[i]] = args[i+1];
 
        break;
 
      default:
 
        ret.embedAttrs[args[i]] = ret.params[args[i]] = args[i+1];
 
    }
 
  }
 
  ret.objAttrs["classid"] = classid;
 
  if (mimeType) ret.embedAttrs["type"] = mimeType;
 
  return ret;
 
}
 
</pre>
 
 
 
afrika.js
 
 
 
<pre>
 
// get flash movie object
 
function getFlashMovie(afrika) {
 
var isIE = navigator.appName.indexOf("Microsoft") != -1;
 
        return (isIE) ? window[afrika] : document[afrika];
 
}
 
 
 
// html link lights up the flash country
 
function asMouseOver(id){
 
  try{
 
    getFlashMovie("afrika").textMouseOver(id);
 
  }catch(e){
 
 
 
  }
 
}
 
function asMouseOut(id){
 
  try{
 
    getFlashMovie("afrika").textMouseOut(id);
 
  }catch(e){
 
 
 
  }
 
}
 
 
 
// flash country lights up html link
 
function countryMouseOver(id){
 
addClass(document.getElementById(id),'flashOver');
 
}
 
 
 
function countryMouseOut(id){
 
removeClass(document.getElementById(id),'flashOver');
 
}
 
 
 
function addClass(element, value) {
 
if (!element.className) {
 
element.className = value;
 
} else {
 
var newClassName = element.className;
 
newClassName += " ";
 
newClassName += value;
 
element.className = newClassName;
 
}
 
}
 
 
 
function removeClass(element, value){
 
element.className = element.className.replace(eval('/'+value+'/'),'');
 
}
 
</pre>
 
 
 
northamerika.js
 
 
 
<pre>
 
// get flash movie object
 
function getFlashMovie(northamerika) {
 
var isIE = navigator.appName.indexOf("Microsoft") != -1;
 
        return (isIE) ? window[northamerika] : document[northamerika];
 
}
 
 
 
// html link lights up the flash country
 
function asMouseOver(id){
 
    getFlashMovie("northamerika").textMouseOver(id);
 
}
 
function asMouseOut(id){
 
    getFlashMovie("northamerika").textMouseOut(id);
 
}
 
 
 
// flash country lights up html link
 
function countryMouseOver(id){
 
addClass(document.getElementById(id),'flashOver');
 
}
 
 
 
function countryMouseOut(id){
 
removeClass(document.getElementById(id),'flashOver');
 
}
 
 
 
function addClass(element, value) {
 
if (!element.className) {
 
element.className = value;
 
} else {
 
var newClassName = element.className;
 
newClassName += " ";
 
newClassName += value;
 
element.className = newClassName;
 
}
 
}
 
 
 
function removeClass(element, value){
 
element.className = element.className.replace(eval('/'+value+'/'),'');
 
}
 
</pre>
 
 
 
africaswfobject.html
 
 
 
<pre>
 
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
 
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
 
<head>
 
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
 
  <title>Afrika</title>
 
  <link rel="stylesheet" href="style.css" type="text/css" />
 
 
  <script type="text/javascript" src="swfobject.js"></script>
 
<script type="text/javascript">
 
swfobject.registerObject("afrika", "9", "expressInstall.swf");
 
</script>
 
  <script src="afrikabackup.js" language="javascript"></script>
 
</head>
 
<body bgcolor="#ffffff">
 
  <div id="wrapper">
 
    <div id="container">
 
      <DIV id=map>
 
        <SPAN class=other-continents>
 
          <P>Other continents:&nbsp;</P>
 
          <SELECT onchange="document.location.href = this.options[this.selectedIndex].value" name="">
 
            <OPTION value=africa.html selected>Africa</OPTION>
 
            <OPTION value=asia.html>Asia</OPTION>
 
            <OPTION value=australasia-and-pacific.html>Australasia &amp; Pacific</OPTION>
 
            <OPTION value=caribbean.html>Caribbean</OPTION>
 
            <OPTION value=central-america.html>Central America</OPTION>
 
            <OPTION value=europe-and-russia.html>Europe &amp; Russia</OPTION>
 
            <OPTION value=middle-east.html>Middle East</OPTION>
 
            <OPTION value=north-america.html>North America</OPTION>
 
            <OPTION value=south-america.html>South America</OPTION>
 
          </SELECT>
 
        </SPAN>
 
        <H1>AFRICA: Vaccinations for travellers</H1>
 
        <BR class=clear><BR>
 
        <DIV id=map-links>
 
          <IMG class=map_top src="PageImages/map_top_border.gif">
 
          <IMG class=map_bottom src="PageImages/map_bottom_border.gif">
 
<!-- africa flash map begins-->
 
          <div id="flash_content">
 
 
 
<object id="afrika" classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" width="339" height="377" style="position: absolute; left: 0px; top: 0px;z-index:1000">
 
<param name="movie" value="afrika.swf" />
 
<param name="allowScriptAccess" value="always" />
 
                <param name="allowFullScreen" value="false" />
 
                <param name="bgcolor" value="#ffffff" />
 
        <!--[if !IE]>-->
 
<object type="application/x-shockwave-flash" data="afrika.swf" width="339" height="377">
 
<!--<![endif]-->
 
<div>
 
<h1>Alternative content</h1>
 
<p><a href="http://www.adobe.com/go/getflashplayer"><img src="http://www.adobe.com/images/shared/download_buttons/get_flash_player.gif" alt="Get Adobe Flash player" /></a></p>
 
</div>
 
<!--[if !IE]>-->
 
</object>
 
<!--<![endif]-->
 
</object>
 
 
 
          </div>
 
          <table class=listed-countries cellSpacing=0 cellPadding=2 width=516 border=0>
 
            <tbody>
 
              <tr>
 
                <TD width=172><a id="DZ" href="http://mvdev.staging.moodia.co.za/travel-vaccinations/Algeria.aspx?PageID=207&amp;CountryCode=DZ" onMouseover="asMouseOver(this.id)" onMouseout="asMouseOut(this.id)">Algeria</A></td>
 
                <TD width=172><a id="GA" href="http://mvdev.staging.moodia.co.za/travel-vaccinations/Gabon.aspx?PageID=207&amp;CountryCode=GA" onMouseover="asMouseOver(this.id)" onMouseout="asMouseOut(this.id)">Gabon</A></TD>
 
                <TD width=172><a id="NG" href="http://mvdev.staging.moodia.co.za/travel-vaccinations/Nigeria.aspx?PageID=207&amp;CountryCode=NG" onMouseover="asMouseOver(this.id)" onMouseout="asMouseOut(this.id)">Nigeria</A></TD>
 
              </TR>
 
              <TR>
 
                <TD><a id="AO" href="http://mvdev.staging.moodia.co.za/travel-vaccinations/Angola.aspx?PageID=207&amp;CountryCode=AO" onMouseover="asMouseOver(this.id)" onMouseout="asMouseOut(this.id)">Angola</A></TD>
 
                <TD><a id="GM" href="http://mvdev.staging.moodia.co.za/travel-vaccinations/Gambia.aspx?PageID=207&amp;CountryCode=GM" onMouseover="asMouseOver(this.id)" onMouseout="asMouseOut(this.id)">Gambia</A></TD>
 
                <TD><a id="CG" href="http://mvdev.staging.moodia.co.za/travel-vaccinations/RepublicofCongo.aspx?PageID=207&amp;CountryCode=CG" onMouseover="asMouseOver(this.id)" onMouseout="asMouseOut(this.id)">Republic of Congo</A></TD>
 
              </TR>
 
              <TR>
 
                <TD><A id="BJ" href="http://mvdev.staging.moodia.co.za/travel-vaccinations/Benin.aspx?PageID=207&amp;CountryCode=BJ" onMouseover="asMouseOver(this.id)" onMouseout="asMouseOut(this.id)">Benin</A></TD>
 
                <TD><A id="GH" href="http://mvdev.staging.moodia.co.za/travel-vaccinations/Ghana.aspx?PageID=207&amp;CountryCode=GH" onMouseover="asMouseOver(this.id)" onMouseout="asMouseOut(this.id)">Ghana</A></TD>
 
                <TD><A id="RE" href="http://mvdev.staging.moodia.co.za/travel-vaccinations/Reunion.aspx?PageID=207&amp;CountryCode=RE" onMouseover="asMouseOver(this.id)" onMouseout="asMouseOut(this.id)">Reunion</A></TD>
 
              </TR>
 
              <TR>
 
                <TD><A id="BW" href="http://mvdev.staging.moodia.co.za/travel-vaccinations/Botswana.aspx?PageID=207&amp;CountryCode=BW" onMouseover="asMouseOver(this.id)" onMouseout="asMouseOut(this.id)">Botswana</A></TD>
 
                <TD><A id="GN" href="http://mvdev.staging.moodia.co.za/travel-vaccinations/Guinea.aspx?PageID=207&amp;CountryCode=GN" onMouseover="asMouseOver(this.id)" onMouseout="asMouseOut(this.id)">Guinea</A></TD>
 
                <TD><A id="RW" href="http://mvdev.staging.moodia.co.za/travel-vaccinations/Rwanda.aspx?PageID=207&amp;CountryCode=RW" onMouseover="asMouseOver(this.id)" onMouseout="asMouseOut(this.id)">Rwanda</A></TD>
 
              </TR>
 
              <TR>
 
                <TD><A id="BF" href="http://mvdev.staging.moodia.co.za/travel-vaccinations/BurkinaFaso.aspx?PageID=207&amp;CountryCode=BF" onMouseover="asMouseOver(this.id)" onMouseout="asMouseOut(this.id)">Burkina Faso</A></TD>
 
                <TD><A id="GW" href="http://mvdev.staging.moodia.co.za/travel-vaccinations/GuineaBissau.aspx?PageID=207&amp;CountryCode=GW" onMouseover="asMouseOver(this.id)" onMouseout="asMouseOut(this.id)">Guinea-Bissau</A></TD>
 
                <TD><A id="ST" href="http://mvdev.staging.moodia.co.za/travel-vaccinations/SaoTome.aspx?PageID=207&amp;CountryCode=ST" onMouseover="asMouseOver(this.id)" onMouseout="asMouseOut(this.id)">Sao Tome &amp; Principe</A></TD>
 
              </TR>
 
              <TR>
 
                <TD><A id="BI" href="http://mvdev.staging.moodia.co.za/travel-vaccinations/Burundi.aspx?PageID=207&amp;CountryCode=BI" onMouseover="asMouseOver(this.id)" onMouseout="asMouseOut(this.id)">Burundi</A></TD>
 
                <TD><A id="KE" href="http://mvdev.staging.moodia.co.za/travel-vaccinations/Kenya.aspx?PageID=207&amp;CountryCode=KE" onMouseover="asMouseOver(this.id)" onMouseout="asMouseOut(this.id)">Kenya</A></TD>
 
                <TD><A id="SN" href="http://mvdev.staging.moodia.co.za/travel-vaccinations/Senegal.aspx?PageID=207&amp;CountryCode=SN" onMouseover="asMouseOver(this.id)" onMouseout="asMouseOut(this.id)">Senegal</A></TD>
 
              </TR>
 
              <TR>
 
                <TD><A id="CM" href="http://mvdev.staging.moodia.co.za/travel-vaccinations/Cameroon.aspx?PageID=207&amp;CountryCode=CM" onMouseover="asMouseOver(this.id)" onMouseout="asMouseOut(this.id)">Cameroon</A></TD>
 
                <TD><A id="LS" href="http://mvdev.staging.moodia.co.za/travel-vaccinations/Lesotho.aspx?PageID=207&amp;CountryCode=LS" onMouseover="asMouseOver(this.id)" onMouseout="asMouseOut(this.id)">Lesotho</A></TD>
 
                <TD><A id="SC" href="http://mvdev.staging.moodia.co.za/travel-vaccinations/Seychelles.aspx?PageID=207&amp;CountryCode=SC" onMouseover="asMouseOver(this.id)" onMouseout="asMouseOut(this.id)">Seychelles</A></TD>
 
              </TR>
 
              <TR>
 
                <TD><A id="CV" href="http://mvdev.staging.moodia.co.za/travel-vaccinations/CapeVerde.aspx?PageID=207&amp;CountryCode=CV" onMouseover="asMouseOver(this.id)" onMouseout="asMouseOut(this.id)">Cape Verde Islands</A></TD>
 
                <TD><A id="LR" href="http://mvdev.staging.moodia.co.za/travel-vaccinations/Liberia.aspx?PageID=207&amp;CountryCode=LR" onMouseover="asMouseOver(this.id)" onMouseout="asMouseOut(this.id)">Liberia</A></TD>
 
                <TD><A id="SL" href="http://mvdev.staging.moodia.co.za/travel-vaccinations/SierraLeone.aspx?PageID=207&amp;CountryCode=SL" onMouseover="asMouseOver(this.id)" onMouseout="asMouseOut(this.id)">Sierra Leone</A></TD>
 
              </TR>
 
              <TR>
 
                <TD><A id="CF" href="http://mvdev.staging.moodia.co.za/travel-vaccinations/CentralAfricanRepublic.aspx?PageID=207&amp;CountryCode=CF" onMouseover="asMouseOver(this.id)" onMouseout="asMouseOut(this.id)">Central African Republic</A></TD>
 
                <TD><A id="LY" href="http://mvdev.staging.moodia.co.za/travel-vaccinations/Libya.aspx?PageID=207&amp;CountryCode=LY" onMouseover="asMouseOver(this.id)" onMouseout="asMouseOut(this.id)">Libya</A></TD>
 
                <TD><A id="SO" href="http://mvdev.staging.moodia.co.za/travel-vaccinations/Somalia.aspx?PageID=207&amp;CountryCode=SO" onMouseover="asMouseOver(this.id)" onMouseout="asMouseOut(this.id)">Somalia</A></TD>
 
              </TR>
 
              <TR>
 
                <TD><A id="TD" href="http://mvdev.staging.moodia.co.za/travel-vaccinations/Chad.aspx?PageID=207&amp;CountryCode=TD" onMouseover="asMouseOver(this.id)" onMouseout="asMouseOut(this.id)">Chad</A></TD>
 
                <TD><A id="MG" href="http://mvdev.staging.moodia.co.za/travel-vaccinations/Madagascar.aspx?PageID=207&amp;CountryCode=MG" onMouseover="asMouseOver(this.id)" onMouseout="asMouseOut(this.id)">Madagascar</A></TD>
 
                <TD><A id="ZA" href="http://mvdev.staging.moodia.co.za/travel-vaccinations/SouthAfrica.aspx?PageID=207&amp;CountryCode=ZA" onMouseover="asMouseOver(this.id)" onMouseout="asMouseOut(this.id)">South Africa</A></TD>
 
              </TR>
 
              <TR>
 
                <TD><A id="KM" href="http://mvdev.staging.moodia.co.za/travel-vaccinations/ComorosMayotte.aspx?PageID=207&amp;CountryCode=KM" onMouseover="asMouseOver(this.id)" onMouseout="asMouseOut(this.id)">Comoros &amp; Mayotte</A></TD>
 
                <TD><A id="MW" href="http://mvdev.staging.moodia.co.za/travel-vaccinations/Malawi.aspx?PageID=207&amp;CountryCode=MW" onMouseover="asMouseOver(this.id)" onMouseout="asMouseOut(this.id)">Malawi</A></TD>
 
                <TD><A id="SD" href="http://mvdev.staging.moodia.co.za/travel-vaccinations/Sudan.aspx?PageID=207&amp;CountryCode=SD" onMouseover="asMouseOver(this.id)" onMouseout="asMouseOut(this.id)">Sudan</A></TD>
 
              </TR>
 
              <TR>
 
                <TD><A id="CI" href="http://mvdev.staging.moodia.co.za/travel-vaccinations/CotedIvoire.aspx?PageID=207&amp;CountryCode=CI" onMouseover="asMouseOver(this.id)" onMouseout="asMouseOut(this.id)">Cote d'Ivoire</A></TD>
 
                <TD><A id="ML" href="http://mvdev.staging.moodia.co.za/travel-vaccinations/Mali.aspx?PageID=207&amp;CountryCode=ML" onMouseover="asMouseOver(this.id)" onMouseout="asMouseOut(this.id)">Mali</A></TD>
 
                <TD><A id="SZ" href="http://mvdev.staging.moodia.co.za/travel-vaccinations/Swaziland.aspx?PageID=207&amp;CountryCode=SZ" onMouseover="asMouseOver(this.id)" onMouseout="asMouseOut(this.id)">Swaziland</A></TD>
 
              </TR>
 
              <TR>
 
                <TD><A id="CD" href="http://mvdev.staging.moodia.co.za/travel-vaccinations/DemocraticRepublicofCongo.aspx?PageID=207&amp;CountryCode=CD" onMouseover="asMouseOver(this.id)" onMouseout="asMouseOut(this.id)">Democratic Republic of Congo</A></TD>
 
                <TD><A id="MR" href="http://mvdev.staging.moodia.co.za/travel-vaccinations/Mauritania.aspx?PageID=207&amp;CountryCode=MR" onMouseover="asMouseOver(this.id)" onMouseout="asMouseOut(this.id)">Mauritania</A></TD>
 
                <TD><A id="TZ" href="http://mvdev.staging.moodia.co.za/travel-vaccinations/Tanzania.aspx?PageID=207&amp;CountryCode=TZ" onMouseover="asMouseOver(this.id)" onMouseout="asMouseOut(this.id)">Tanzania</A></TD>
 
              </TR>
 
              <TR>
 
                <TD><A id="DJ" href="http://mvdev.staging.moodia.co.za/travel-vaccinations/Djibouti.aspx?PageID=207&amp;CountryCode=DJ" onMouseover="asMouseOver(this.id)" onMouseout="asMouseOut(this.id)">Djibouti</A></TD>
 
                <TD><A id="MU" href="http://mvdev.staging.moodia.co.za/travel-vaccinations/Mauritius.aspx?PageID=207&amp;CountryCode=MU" onMouseover="asMouseOver(this.id)" onMouseout="asMouseOut(this.id)">Mauritius</A></TD>
 
                <TD><A id="TG" href="http://mvdev.staging.moodia.co.za/travel-vaccinations/Togo.aspx?PageID=207&amp;CountryCode=TG" onMouseover="asMouseOver(this.id)" onMouseout="asMouseOut(this.id)">Togo</A></TD>
 
              </TR>
 
              <TR>
 
                <TD><A id="EG" href="http://mvdev.staging.moodia.co.za/travel-vaccinations/Egypt.aspx?PageID=207&amp;CountryCode=EG" onMouseover="asMouseOver(this.id)" onMouseout="asMouseOut(this.id)">Egypt</A></TD>
 
                <TD><A id="MA" href="http://mvdev.staging.moodia.co.za/travel-vaccinations/Morocco.aspx?PageID=207&amp;CountryCode=MA" onMouseover="asMouseOver(this.id)" onMouseout="asMouseOut(this.id)">Morocco</A></TD>
 
                <TD><A id="TN" href="http://mvdev.staging.moodia.co.za/travel-vaccinations/Tunisia.aspx?PageID=207&amp;CountryCode=TN" onMouseover="asMouseOver(this.id)" onMouseout="asMouseOut(this.id)">Tunisia</A></TD>
 
              </TR>
 
              <TR>
 
                <TD><A id="GQ" href="http://mvdev.staging.moodia.co.za/travel-vaccinations/EquatorialGuinea.aspx?PageID=207&amp;CountryCode=GQ" onMouseover="asMouseOver(this.id)" onMouseout="asMouseOut(this.id)">Equatorial Guinea</A></TD>
 
                <TD><A id="MZ" href="http://mvdev.staging.moodia.co.za/travel-vaccinations/Mozambique.aspx?PageID=207&amp;CountryCode=MZ" onMouseover="asMouseOver(this.id)" onMouseout="asMouseOut(this.id)">Mozambique</A></TD>
 
                <TD><A id="UG" href="http://mvdev.staging.moodia.co.za/travel-vaccinations/Uganda.aspx?PageID=207&amp;CountryCode=UG" onMouseover="asMouseOver(this.id)" onMouseout="asMouseOut(this.id)">Uganda</A></TD>
 
              </TR>
 
              <TR>
 
                <TD><A id="ER" href="http://mvdev.staging.moodia.co.za/travel-vaccinations/Eritrea.aspx?PageID=207&amp;CountryCode=ER" onMouseover="asMouseOver(this.id)" onMouseout="asMouseOut(this.id)">Eritrea</A></TD>
 
                <TD><A id="NA" href="http://mvdev.staging.moodia.co.za/travel-vaccinations/Namibia.aspx?PageID=207&amp;CountryCode=NA" onMouseover="asMouseOver(this.id)" onMouseout="asMouseOut(this.id)">Namibia</A></TD>
 
                <TD><A id="ZM" href="http://mvdev.staging.moodia.co.za/travel-vaccinations/Zambia.aspx?PageID=207&amp;CountryCode=ZM" onMouseover="asMouseOver(this.id)" onMouseout="asMouseOut(this.id)">Zambia</A></TD>
 
              </TR>
 
              <TR>
 
                <TD><A id="ET" href="http://mvdev.staging.moodia.co.za/travel-vaccinations/Ethiopia.aspx?PageID=207&amp;CountryCode=ET" onMouseover="asMouseOver(this.id)" onMouseout="asMouseOut(this.id)">Ethiopia</A></TD>
 
                <TD><A id="NE" href="http://mvdev.staging.moodia.co.za/travel-vaccinations/Niger.aspx?PageID=207&amp;CountryCode=NE" onMouseover="asMouseOver(this.id)" onMouseout="asMouseOut(this.id)">Niger</A></TD>
 
                <TD><A id="ZW" href="http://mvdev.staging.moodia.co.za/travel-vaccinations/Zimbabwe.aspx?PageID=207&amp;CountryCode=ZW" onMouseover="asMouseOver(this.id)" onMouseout="asMouseOut(this.id)">Zimbabwe</A></TD>
 
              </TR>
 
            </tbody>
 
          </table>
 
        </div>
 
      </div>
 
    </div>
 
  </div>
 
</body>
 
</html>
 
</pre>
 

Latest revision as of 09:48, 21 July 2010

Getting xml from asp and into flash

http://www.aspnetflash.com/forum/Default.aspx?g=posts&t=172 http://stackoverflow.com/questions/1371164/actionscript-2-0-email-form-loadvars-with-ashx-net-handler http://www.nathanbaker.com.au/blog/post/Accessing-Web-Services-in-Flash-AS2.aspx

http://kemmis.info/blog/archive/2010/03/24/how-to-save-a-file-from-flash-10-without-user.aspx

VoteGetRankingByCategory.ashx

?category=junior

?category=senior


Islands

5 sept 2008: if this can work... you can do it!!! SO JUST FUCKIN DO ITTT!!!!!!!!!!!!!!! 12 sept 2008: AND I'VE DONE IT!

JS

// get flash movie object
function getFlashMovie(northamerika) {
var isIE = navigator.appName.indexOf("Microsoft") != -1;
        return (isIE) ? window[northamerika] : document[northamerika];
}

// javascript gets url and sends it to flash country
function sendIDtoFlash(id) {
var e = (document.getElementById(id));
var IDhttp = e.href;
getFlashMovie("northamerika").sendIDtoFlash(IDhttp);
}

Actionscript

import flash.external.ExternalInterface;

// URLWANG!

function getIDfromJavascript(IDhttp):Void{
	var MyIDhttp:String;
	MyIDhttp = "";
	_root.MyIDhttp = IDhttp;
}
ExternalInterface.addCallback("sendIDtoFlash", this, getIDfromJavascript);


// FUNCTIONWANG!

function countryRelease(id) {
	ExternalInterface.call("sendIDtoFlash",id);
}

// COUNTRYFUNCTIONWANG!

AG.onRollOver  = function()  {
	countryName(true, "Antigua & Barbuda", this);
	countryOver("AG");
	countryOverHTML("AG");
	this.onRollOut = function() {
		countryName(false);
		countryOut("AG")
		countryOutHTML("AG");
	this.onRelease = function() {
	countryRelease("AG");
	getURL(MyIDhttp,  "_parent");}
	};
}; 

OLD VERSIONS: stage 2: SENDING URL TO AS

at this point i got it to work for one country at a time and i had problems with it working in both FF and IE

JS

this worked in both FF and IE

// get flash movie object
function getFlashMovie(australia) {
var isIE = navigator.appName.indexOf("Microsoft") != -1;
        return (isIE) ? window[australia] : document[australia];
}

function sendAUtoFlash() {
var e = (document.getElementById('AU'));
var AUhttp = e.href;
getFlashMovie("australia").sendAUtoFlash(AUhttp);
}

this worked only in FF... FUCKING IE SON OF A BITCH!!!!!!!!!!!!!!!!!!

// get flash movie object
function getFlashMovie(australia) {
var isIE = navigator.appName.indexOf("Microsoft") != -1;
        return (isIE) ? window[australia] : document[australia];
}

function sendAUtoFlash() {
var AUhttp = document.links["AU"].href;
//alert(AUhttp);
getFlashMovie("australia").sendAUtoFlash(AUhttp);
}
// window.onload = sendAUtoFlash;

AS

AU.onRollOver  = function()  {
	countryName(true, "Australia", this);
	countryOver("AU");
	countryOverHTML("AU");
		this.onRollOut = function() {
		countryName(false);
		countryOut("AU")
		countryOutHTML("AU");
		receiver.text="bye";
	};
	getURL("javascript:sendAUtoFlash();");
	this.onRelease = function() {
	receiver.text=_root.MyAUhttp;
	var loadAU = "BUMS";
	getURL(MyAUhttp,  "_parent");
};
}; 


OLD VERSION stage 1: SENDING URL AS VARIABLE FROM JS TO AS (WORKING!!!!!!)

this worked in putting the url into the receiver. but it only worked in FF.

JS

// get flash movie object
function getFlashMovie(australia) {
var isIE = navigator.appName.indexOf("Microsoft") != -1;
        return (isIE) ? window[australia] : document[australia];
}

function sendAUtoFlash() {
var AUhttp = document.links["AU"].href;
alert(AUhttp);
getFlashMovie("australia").sendAUtoFlash(AUhttp);
}
window.onload = sendAUtoFlash;

AS2

import flash.external.ExternalInterface;

function getAUfromJavascript(AUhttp):Void{
receiver.text = "received: " + AUhttp;
}
ExternalInterface.addCallback("sendAUtoFlash", this, getAUfromJavascript);

OLD VERSION MAKING FLASH LINK AND JAVASCRIPT LINK LIGHT EACH OTHER UP =

I needed to make a html file with embedded flash that had the javascript on the html page triggering events in the flash and vice versa. This is an example of the final solution which was used after some coding help from a colleague in cleaning up the terrible mess I made.... (it was cut down from 1100 lines to about 400 lines)

HTML & CSS

<a id="BM" href="bermuda.html" onMouseover="asMouseOver(this.id)" onMouseout="asMouseOut(this.id)">Bermuda</A>

i also defined the class flashOver in the CSS as it would be inserted in using the javascript only when the links were moused over. jQuery could be used to create this effect as well...

Actionscript

import flash.external.ExternalInterface;

// COLOURWANG! -- using prototype to define the clearRGB function for the mouseOut

Color.prototype.clearRGB = function(){
     this.setTransform({ra:100, rb:0,ga:100,gb:0,ba:100,bb:0,aa:100,ab:0});
}

// FUNCTIONWANG! -- defines the mouseovers and mouseouts colour changes

function countryOver(id) {
	var newColor = new Color(eval(id));
	newColor.setRGB(0x2A87AC);
}
function countryOut(id) {
	var newColor = new Color(eval(id));
	newColor.clearRGB();
}
function countryOverHTML(id){
	ExternalInterface.call("countryMouseOver",id);
}
function countryOutHTML(id){
	ExternalInterface.call("countryMouseOut",id);
}

// COUNTRYFUNCTIONWANG! -- defines the rollovrs and rollouts for 
// the mouseovers and mouseouts hover captions functions (for each specific movieclip)

BM.onRollOver  = function()  {
	countryName(true, "Bermuda", this);
	countryOver("BM");
	countryOverHTML("BM");
	this.onRollOut = function() {
		countryName(false);
		countryOut("BM")
		countryOutHTML("BM");
	};
}; 

// WORDWANG! -- defines the hover caption function

countryName =  function (showCaption, captionText, bName)  {
if (showCaption) {
	_root.createEmptyMovieClip("hoverCaption", this.getNextHighestDepth());
	cap.desc.text = captionText;
	cap._width = 8*cap.desc.text.length;
	cap._alpha = 75;
	hoverCaption.onEnterFrame = function() {
		cap._x = _root._xmouse;
		if ((cap._x-(cap._width/2))<0) {
			cap._x = cap._width/2;
		}else if((cap._x + (cap._width/2))>330){
			cap._x = 330 - (cap._width/2);
		}else{
		}
		cap._y = _root._ymouse-15;
		cap._visible = true;
	};
} else {
	delete hoverCaption.onEnterFrame;
	cap._visible = false;
}
};

// EXTERNALINTERFACEWANG! -- externalinterface callback that 
// allows Actionscript to access the Javascript functions 
// (by declaring them in advance)

var method1:Function = countryOver;
var method2:Function = countryOut;
var instance:Object = null;
ExternalInterface.addCallback("textMouseOver", instance, method1);
ExternalInterface.addCallback("textMouseOut", instance, method2);

Javascript

// get flash movie object

function getFlashMovie(nameofflashfile) {
var isIE = navigator.appName.indexOf("Microsoft") != -1;
        return (isIE) ? window[nameofflashfile] : document[nameofflashfile];
}

// html link lights up the flash country

function asMouseOver(id){
  try{
    getFlashMovie("nameofflashfile").textMouseOver(id);
  }catch(e){
  
  }
}
function asMouseOut(id){
  try{
    getFlashMovie("nameofflashfile").textMouseOut(id);
  }catch(e){
  
  }
}

// flash country lights up html link

function countryMouseOver(id){
	addClass(document.getElementById(id),'flashOver');
}

function countryMouseOut(id){
	removeClass(document.getElementById(id),'flashOver');
}

function addClass(element, value) {
	if (!element.className) {
		element.className = value;
	} else {
		var newClassName = element.className;
		newClassName += " ";
		newClassName += value;
		element.className = newClassName;
	}
}

function removeClass(element, value){
	element.className = element.className.replace(eval('/'+value+'/'),'');
}


Troubleshooting

BECAUSE I HAVE BEEN GOING MAD REPLICATING THIS SCRIPT FOR OVER A THOUSAND MOVIECLIPS...

  • check if the INSTANCE NAME of the movieclip has been defined in flash
  • if you saved the js or css seperately make sure you insert them in!!!!
  • when you embed the flash file (however the hell you do it, make sure you define the ID and NAME in both OBJECT and EMBED, for good measure)

Links

http://blog.deconcept.com/swfobject/forum/discussion/928/movie-not-loaded-in-ie/