AS 2
I need help streamlining some of my button code, I have buttons that need to perform multiple functions: On rollover, they send their link to the browser's status bar. On roll out they clear the status bar. On press they send tracking code to the html. And on release they send getURL with the link. I've put in some variables so that I don't need to copy the links over and over, but I'd really like to streamline button functions so that I don't need to make a whole new set of onRollover onRollout onPress onRelease functions for each and every link. I'd love any ideas about how to simplify button functions so that they can work for any button. Thanks!
Here's what I'm working with:
Code://IMPORT THE JAVASCRIPT EXTERNAL import flash.external.*; //THE FUNCTION THAT WILL CALL THE JAVASCRIPT FUNCTION IN THE HEAD OF THE HTML DOC function jsStatus(link) { // The name of a JavaScript function to call //IN QUOTES, IN THIS CASE callStatusBar var callJasFunction:String = "callStatusBar"; //parameter //TEMPORARY VAR STORES THE PASSED VARIABLE, EXTERNAL INTERFACE SENDS THE VARIABLE AND THE FUNCTION NAME var msg:String = link; var returnValue:String = ExternalInterface.call(callJasFunction, msg).toString(); } //LINKS LIST //A VARIABLE MUST BE DECLARED FOR EACH LINK, AND THEN THE ADDRESS STORED IN THAT VAR var firstLink:String; var secondLink:String; firstLink = "http://www.me.com/1"; secondLink = "http://www.me.com/2"; //BUTTON FUNCTIONS //1 //FIRST LINKS //CALLS THE STATUS BAR ON ROLLOVER WITH THE LINK STORED ABOVE this.btn_first.onRollOver = function() { jsStatus(nowLink); } //LINKS TO SEND THE TRACKING FUNCTIONS this.btn_first.onPress = function() { getURL("javascript:cmCreateManualLinkClickTag(\"" + nowLink + ",\"FlashTest\")"); trace("javascript:cmCreateManualLinkClickTag(\"" + nowLink + "\",\"FlashTest\")"); } //LINKS TO THE LINK STORED IN THE VARIABLE this.btn_first.onRelease = function() { getURL(firstLink, "_self"); } //CLEARS THE LINK IN THE STATUS BAR, JSSTATUS CALLED WITH AND EMPTY STRING this.btn_first.onRollOut = function() { jsStatus(" "); } //END FIRST LINKS //2 //SECOND LINKS //CALLS THE STATUS BAR ON ROLLOVER WITH THE LINK STORED ABOVE this.btn_second.onRollOver = function() { jsStatus(secondLink); } //LINKS TO SEND THE TRACKING FUNCTIONS this.btn_second.onPress = function() { getURL("javascript:cmCreateManualLinkClickTag(\"" + secondLink + ",\"FlashTest\")"); trace("javascript:cmCreateManualLinkClickTag(\"" + secondLink + "\",\"FlashTest\")"); } //LINKS TO THE LINK STORED IN THE VARIABLE this.btn_second.onRelease = function() { getURL(secondLink, "_self"); } //CLEARS THE LINK IN THE STATUS BAR, JSSTATUS CALLED WITH AND EMPTY STRING this.btn_second.onRollOut = function() { jsStatus(" "); } //END SECOND LINKS




Reply With Quote
