1

I am a c# asp.net developer and need to implement a number of flash website banners. Previously for static image banners I have implemented on_click code behind or javascript to log the banner has been clicked back to a database and process the re-direction.

I don't have much knowledge of flash other than I know that a flash program can handle on-click events of the program.

Therefore, can somebody suggest the best solution for capturing and processing on-click events of a flash object on a webpage.

Many thanks,

Adam

Adam Jenkin
  • 4,142
  • 6
  • 25
  • 31
  • I would take those guys code. But still would make a wrapper in flash for banners. So that you reference its functions by _root / root and from this wrapper you communicate with javascript. Its just easier to maintain... – mAm Feb 11 '10 at 14:28

2 Answers2

1

You can talk to Flash objects with JavaScript via Mootools' Swiff component: http://mootools.net/blog/2008/02/12/whats-new-in-12-swiff/ http://mootools.net/docs/core/Utilities/Swiff

However, for simple things like clickable banners, all you may need is swfobject: http://code.google.com/p/swfobject/

A decent but simple XML driven Flash banner rotator can be had for free here: http://www.weberdesignlabs.com/blog/2008/06/open-source-xml-free-flash-banner/

Hope that helps!

purefusion
  • 943
  • 1
  • 15
  • 23
  • Thanks purefusion, I think a combination of swfobject and ExternalInterface.Call() actionscript method appears to be the way forward, that way I can get the flash program to pass the click event up to my own defined js function. Testing still in progress! :) – Adam Jenkin Feb 15 '10 at 21:53
0

You can communicate in multiple ways with Flash and your Server Side Code.

1.) Use JavaScript to communicate to/from your SWF file and the page it is embedded in. http://kb2.adobe.com/cps/156/tn_15683.html

This can be combined with AJAX to send data to the server.

2.) Directly send variables to a Server Side File (using GET or POST) within Flash http://livedocs.adobe.com/flash/9.0/main/wwhelp/wwhimpl/common/html/wwhelp.htm?context=LiveDocs_Parts&file=00001790.html

var submitListener:Object = new Object();
submitListener.click = function(evt:Object) {
    var result_lv:LoadVars = new LoadVars();
    result_lv.onLoad = function(success:Boolean) {
    if (success) {
        result_ta.text = result_lv.welcomeMessage;
    } else {
        result_ta.text = "Error connecting to server.";
    }
    };
    var send_lv:LoadVars = new LoadVars();
    send_lv.name = name_ti.text;
    send_lv.sendAndLoad("http://www.flash-mx.com/mm/greeting.cfm", result_lv, "POST");
};
submit_button.addEventListener("click", submitListener);

You can have a Server Side Page (ASP.NET, PHP, etc...) to increment the Database hit count.

Todd Moses
  • 10,969
  • 10
  • 47
  • 65