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 progra开发者_JS百科m 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
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!
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.
精彩评论