Creating Companion Ads
To differentiate the two elements of a companion ad, we refer to the leaderboard as "firstToLoad" and the cube as "secondToLoad."
Directions for "firstToLoad"- Create your animation - leaving frames 1 through 4 empty.
- Create two layers: one called "actions" and one called "labels."
- In the first frame of the actions layer, place the following ActionScript:
* define functions to be carried out when ready to go */ function setLCMethods() { firstToLoad_lc.checkfirstToLoadLoad = function (num) { random_num = num; secondToLoadName = "secondToLoad" + random_num; firstToLoadName = "firstToLoad" + random_num; firstToLoad_lc.close(); firstToLoad_lc = new LocalConnection (); firstToLoad_lc.connect(firstToLoadName); setLCMethods(); firstToLoad_lc.send(secondToLoadName, "firstToLoadConfirm"); } firstToLoad_lc.go_play = function (frame) { gotoAndPlay (frame); } firstToLoad_lc.go_stop = function (frame) { gotoAndStop (frame); } } /* END define functions */ /* establishment of local connection */ function makeConnection() { firstToLoad_lc = new LocalConnection (); firstToLoad_lc.connect("firstToLoad"); setLCMethods(); } /* END establishment of local connection */ /* preload movies */ function preloadMovies() { var totalBytes = getBytesTotal(); var loadedBytes = getBytesLoaded(); var perLoaded = Math.round((loadedBytes / totalBytes) * 100); if (perLoaded == 100) { clearInterval(preloadMoviesInterval); makeConnection(); } } preloadMoviesInterval = setInterval(preloadMovies, 100); /* END preload movies */ /* looping variable */ var numberOfLoops:Number = 0; /* END looping variable */ stop(); - Create a new keyframe in frame 5 of the labels layer. Highlight this new keyframe and give this frame the label "playfirstToLoad" in the properties panel. Your animation will begin on frame 5.
- Create a new keyframe in frame 5 of the actions layer. This is the point at which your movie will stop looping. To change the point at which your movie stops looping, move this keyframe to a different location between frame 5 and the last frame of your movie. Put the following actions in this keyframe:
if (numberOfLoops == 3) { _root.stop(); } else { null; } - Create a new keyframe in the very last frame of your animation on the actions layer. Place the following actionscript on the last frame:
numberOfLoops = numberOfLoops+1 gotoAndPlay(5);
Directions for "secondToLoad"
- Create your animation - leaving frames 1 through 4 empty.
- Create two layers: one called "actions" and one called "labels."
- In the first frame of the actions layer, place the following ActionScript:
/* establishment of local connection */ function makeConnection() { secondToLoad_lc = new LocalConnection (); secondToLoad_lc.connect(secondToLoadName); setLCMethods(); checkfirstToLoadInterval = setInterval(checkfirstToLoad, 100); } /* END establishment of local connection */ /* preload movies */ function preloadMovies() { var totalBytes = getBytesTotal(); var loadedBytes = getBytesLoaded(); var perLoaded = Math.round((loadedBytes / totalBytes) * 100); if (perLoaded == 100) { clearInterval(preloadMoviesInterval); makeConnection(); } } function checkfirstToLoad() { secondToLoad_lc.send("firstToLoad", "checkfirstToLoadLoad", random_num); } /* END preload movies */ /* define functions to be carried out when ready to go */ function setLCMethods() { secondToLoad_lc.firstToLoadConfirm = function () { clearInterval(checkfirstToLoadInterval); readySteadyGo(); } } /* END define functions to be carried out when ready to go */ /* gives the go ahead to play */ function readySteadyGo() { secondToLoad_lc.send(firstToLoadName, "go_play", "playFirstToLoad"); gotoAndPlay ("playSecondToLoad"); } /* END gives the go ahead to play */ /* variables */ random_num = Math.round(Math.random() * 10000); secondToLoadName = "secondToLoad" + random_num; firstToLoadName = "firstToLoad" + random_num; preloadMoviesInterval = setInterval(preloadMovies, 100); var numberOfLoops:Number = 0; /* END variables */ stop(); - Create a new keyframe in frame 5 of the labels layer. Highlight this new keyframe and give this frame the label "playsecondToLoad" in the properties panel. Your animation will begin on frame 5.
- Create a new keyframe in frame 5 of the actions layer. This is the point at which your movie will end. To change the point at which your movie stops looping, move this segment of actionscript to a different location between frame 5 and the last frame of your movie. Put the following actions on frame 5:
if (numberOfLoops == 3) { _root.stop(); } else { null; } - Create a new keyframe in the very last frame of your animation on the actions layer. Place the following actionscript on the last frame:
numberOfLoops = numberOfLoops+1 gotoAndPlay(5);
For more information about advertising and creative specifications, please contact Thom Smith at 410-464-2886 ext. 251.
