Docstoc

Advanced ActionScript for Flash Banner Ads

Document Sample
Advanced ActionScript for Flash Banner Ads Powered By Docstoc
					Advanced ActionScript for Flash Banner Ads
In this document, you will find code for:
    •      Standard Flash Ads
    •      Multiple URL Ads
    •      Additional File Loading
    •      Form Fields
    •      Local connection objects


Standard Flash Ads

       Use getURL () and clickTAG as an expression.

on (release)
{
   if((_root.clickTAG.indexOf("http://") == 0) || (_root.clickTAG.indexOf("https://") == 0))
   {
       getURL(_root.clickTAG, "_blank");
   }
}

Multiple URL Ads
       Use clickTAG2, clickTAG3, clickTAG4, and clickTAG5 for up
       to a maximum of five unique URLs.

on (release)
{
   if((_root.clickTAG2.indexOf("http://") == 0) || (_root.clickTAG2.indexOf("https://") == 0))
   {
       getURL(_root.clickTAG2, "_blank");
   }
}

       Linking URL #1: clickTAG
       Linking URL #2: clickTAG2
       Linking URL #3: clickTAG3
       Linking URL #4: clickTAG4
       Linking URL #5: clickTAG5


Additional File Loading
       Additional files must be referenced using full paths on Akamai servers. For this reason,
       use loadMovie() or loadMovieNum() with movie1 as an expression. This variable will
       be used to pass in the full path of the addition file. Up to three other movies (movie2,
       movie3, movie4) may be loaded separately on click (one movie per click). Loaded files
       may be any compatible loadMovie() format and be up to 100K in file size.
       on (release)
       {
             loadMovie(movie1, "target_movieclip");
       }
Form Fields
        Forms must use a GET method, and the query string is constructed manually. Here is an
        example. form_fname and form_lname are the input fields. flash_fname and
        flash_lname are the Flash input text fields.
on (release)
{
    if((_root.clickTAG.indexOf("http://") == 0) || (_root.clickTAG.indexOf("https://") == 0))
   {
       qs = "form_fname=" + escape(flash_fname)
              + "&form_lname=" + escape(flash_lname);
        getURL(_root.clickTAG + qs , "_blank");
        // clickTAG will hold the script location including the '?'
        // for example, http://search.yahoo.com/search?
   }
 }
 Local Connection Objects

 The Yahoo!7 front page provides the perfect environment in which an advertiser can engage
 users with their brand through its two main ad units: the E (say east, dim 350x200 px) and MNTL
 (say mantle, dim 420x80 px). Sometimes it is desirable for these two ad units to synchronise their
 animation sequence and the easiest way to achieve this synchronisation is to use local
 connection objects in Flash Actionscript. Flash creative that make use of local connection objects
 need to follow this template.

 To be inserted into the first frame of the main stage in the Flash file for E (350x200):
     function setLocalConnect() {
        east_lc = new LocalConnection ();
        east_lc.connect("east");
        setLCMethods();
     }
     function setLCMethods() {
        east_lc.checkEastLoad = function (num) {
            random_num = num;
            westName = "west" + random_num;
            eastName = "east" + random_num;
            east_lc.close();
            east_lc = new LocalConnection ();
            east_lc.connect(eastName);
            setLCMethods();
            east_lc.send(westName, "eastConfirm");
        };
        east_lc.go_play = function (frame) {
            gotoAndPlay (frame);
        };
        east_lc.go_stop = function (frame) {
            gotoAndStop (frame);
        };
     }
     function preloader() {
        var T = getBytesTotal();
        var L = getBytesLoaded();
        var P = Math.round((L / T) * 100);
        if (P == 100) {
            setLocalConnect();
            clearInterval(preloaderInterval);
        }
     }
     preloaderInterval = setInterval(preloader, 100);
     stop();
To be inserted into the first frame of the main stage in the Flash file for MNTL
(420X80):

   function preloader() {
      var T = getBytesTotal();
      var L = getBytesLoaded();
      var P = Math.round((L / T) * 100);
      if (P == 100) {
          clearInterval(preloaderInterval);
          setLocalConnect();
      }
   }
   function setLocalConnect() {
      west_lc = new LocalConnection ();
      west_lc.connect(westName);
      setLCMethods();
      checkEastInterval = setInterval(checkEast, 100);
   }
   function checkEast() {
      west_lc.send("east", "checkEastLoad", random_num);
   }
   function setLCMethods() {
      west_lc.eastConfirm = function () {
          clearInterval(checkEastInterval);
          initFunction();
      };
   }
   function initFunction() {
      west_lc.send(eastName, "go_play", "START_EAST");
      gotoAndPlay ("START_WEST");
   }
   random_num = Math.round(Math.random() * 10000);
   westName = "west" + random_num;
   eastName = "east" + random_num;
   preloaderInterval = setInterval(preloader, 100);
   stop();

START_EAST is to be replaced by the frame name from where the animation (on the main stage) of E starts.
START_WEST is to be replaced by the frame name from where the animation (on the main stage) of MNTL starts.




For basic Flash instructions, see
http://au.solutions.yahoo.com/nz/docs/flash_instructions_nz.pdf

				
DOCUMENT INFO
Shared By:
Categories:
Stats:
views:44
posted:4/25/2010
language:English
pages:4
Description: Advanced ActionScript for Flash Banner Ads