I am pulling my hair out here… What I’d like to do is modify the script of an ad banner I was sent. Currently it plays through once and then stops but I need to make it loop 3 times and stop. If it was AS3 i’d be laughing, but I am stumped with AS2.
stop();
/* Functions for banners*/
import mx.transitions.Tween;
import mx.transitions.easing.*;
import TextField.StyleSheet;
createEmptyMovieClip("headline", 0);
createEmptyMovieClip("text1", 1);
createEmptyMovieClip("text2", 2);
createEmptyMovieClip("callToAction", 5);
createEmptyMovieClip("logos", 6);
var myCSS:StyleSheet = new StyleSheet();
myCSS.setStyle("prices1", {fontSize:'46px', letterSpacing:'-2px', fontFamily:'bodyMedium', color:'#ffffff'});
myCSS.setStyle("mytaxes1", {fontSize:'10px', fontFamily:'bodyMedium', textIndent:'10px', color:'#ffffff'});
myCSS.setStyle("prices2", {fontSize:'46px', letterSpacing:'-2px', fontFamily:'bodyMedium', color:'#ffffff'});
myCSS.setStyle("mytaxes2", {fontSize:'10px', fontFamily:'bodyMedium', textIndent:'10px', color:'#ffffff'});
function logoPlace(){
logos.lineStyle(1,0x830000,0);
logos.moveTo(0,497);
logos.lineTo(0,119);
logos.lineTo(599,119);
logos.lineTo(599,497);
logos.lineTo(0,497);
logos.attachMovie("wviLogo", "wvi_logo", logos.getNextHighestDepth());
if(coop == 0) {
logos.wvi_logo._x = (Stage.width - logos.wvi_logo._width) / 2;
logos.wvi_logo._y = ((Stage.height + 497) - logos.wvi_logo._height) / 2;
} else {
logos.attachMovie("coopLogo", "logo", logos.getNextHighestDepth());
logos.logo._x = (Stage.width - logos.logo._width) / 2;
logos.wvi_logo._x = (Stage.width - logos.wvi_logo._width) / 2;
logos.logo._y = (Stage.height - logos.logo._height) / 2 + ((497 + (51 / 2)) - (Stage.height / 2));
logos.wvi_logo._y = (Stage.height - logos.wvi_logo._height) / 2 + (497 + logos.wvi_logo._height - (Stage.height / 2)) + 51;
}
}
/* This function creates the header text and slides the header in */
function headerSlide() {
headline.lineStyle(1,0xffffff,0);
headline.moveTo(0,0);
headline.lineTo(0,497);
headline.lineTo(119,497);
headline.lineTo(119,0);
headline.lineTo(0,0);
headline.createTextField("headline", headline.getNextHighestDepth(), 0, 0, 103, 109);
//headline.headline.border = true;
headline.headline.wordWrap = true;
headline.headline.multiline = true;
headline.headline.autoSize = true;
headline.headline.selectable = false;
headline.headline.selectable = false;
headline.headline.html = true;
headline.headline.embedFonts = true;
headline.headline.htmlText = "<textformat leading='-3'><p align='center'><font face='body' size='16' color='#ffffff'>";
headline.headline.htmlText += header;
headline.headline.htmlText += "</font></br>";
headline.headline._y = (headline._height - headline.headline._height) / 2;
headline.headline._x = (Stage.width - headline.headline._width) / 2;
}
function text1Slide() {
text1.lineStyle(1,0xffffff,0);
text1.moveTo(0,0);
text1.lineTo(0,480);
text1.lineTo(119,480);
text1.lineTo(119,0);
text1.lineTo(0,0);
text1.createTextField("text1", text1.getNextHighestDepth(), 0, 0, 140, 109);
//headline.headline.border = true;
text1.text1.wordWrap = true;
text1.text1.multiline = true;
text1.text1.autoSize = true;
text1.text1.selectable = false;
text1.text1.selectable = false;
text1.text1.html = true;
text1.text1.embedFonts = true;
text1.text1.htmlText = "<textformat leading='-3'><p align='center'><font face='body' size='16' color='#ffffff'>";
text1.text1.htmlText += text_1;
text1.text1.htmlText += "</font></br>";
text1.text1._y = ((text1._height - text1.text1._height) / 2) + 130;
text1.text1._x = (Stage.width - text1.text1._width) / 2;
}
function text2Slide() {
text2.lineStyle(1,0xffffff,0);
text2.moveTo(0,0);
text2.lineTo(0,497);
text2.lineTo(119,497);
text2.lineTo(119,0);
text2.lineTo(0,0);
text2.createTextField("text2", text2.getNextHighestDepth(), 0, 0, 120, 109);
//headline.headline.border = true;
text2.text2.wordWrap = true;
text2.text2.multiline = true;
text2.text2.autoSize = true;
text2.text2.selectable = false;
text2.text2.selectable = false;
text2.text2.html = true;
text2.text2.embedFonts = true;
text2.text2.htmlText = "<textformat leading='-3'><p align='center'><font face='body' size='16' color='#ffffff'>";
text2.text2.htmlText += text_2;
text2.text2.htmlText += "</font></br>";
text2.text2._y = ((text2._height - text2.text2._height) / 2) + 89;
text2.text2._x = (Stage.width - text2.text2._width) / 2;
}
function callToActionSlide() {
callToAction.lineStyle(1,0xffffff,0);
callToAction.moveTo(0,0);
callToAction.lineTo(0,497);
callToAction.lineTo(119,497);
callToAction.lineTo(119,0);
callToAction.lineTo(0,0);
callToAction.createTextField("callToAction", callToAction.getNextHighestDepth(), 0, 0, 140, 109);
//headline.headline.border = true;
callToAction.callToAction.wordWrap = true;
callToAction.callToAction.multiline = true;
callToAction.callToAction.autoSize = true;
callToAction.callToAction.selectable = false;
callToAction.callToAction.selectable = false;
callToAction.callToAction.html = true;
callToAction.callToAction.embedFonts = true;
callToAction.callToAction.htmlText = "<textformat leading='-3'><p align='center'><font face='body' size='15' color='#ffffff'>";
callToAction.callToAction.htmlText += cta;
callToAction.callToAction.htmlText += "</font></br>";
callToAction.callToAction._y = ((callToAction._height - callToAction.callToAction._height) / 2) + 89;
callToAction.callToAction._x = (Stage.width - callToAction.callToAction._width) / 2;
}
/* runtime1 */
function runFirstSlideIn() {
headerSlide();
var myalphaHeader:Tween = new Tween(headline, "_alpha", Strong.easeOut, 0, 100, 1, true);
}
function runFirstSlideOut() {
var myalphaHeader:Tween = new Tween(headline, "_alpha", Strong.easeOut, 100, 0, 1, true);
}
function imageSlide() {
text1Slide();
var myfirstPrice:Tween = new Tween(text1, "_alpha", Strong.easeOut, 0, 100, 1, true);
}
function slideOneOut(){
var myfirstPrice:Tween = new Tween(text1, "_alpha", Strong.easeOut, 100, 0, 1, true);
}
function slideImageIn(){
var myTween1:Tween = new Tween(imagebloc, "_y", Strong.easeOut, 0, 194, 1, true);
}
function slideTwoIn(){
text2Slide();
var myfirstPrice:Tween = new Tween(text2, "_alpha", Strong.easeOut, 0, 100, 1, true);
}
function slideTwoOut(){
var mysecondPrice:Tween = new Tween(text2, "_alpha", Strong.easeOut, 100, 0, 1, true);
}
function slideCallToAction(){
callToActionSlide();
var mylastSlide:Tween = new Tween(callToAction, "_alpha", Strong.easeOut, 0, 100, 1, true);
}
/* timer function */
var xy = 0;
var duration = 1000;
logoPlace();
function runBanner(){
switch (noSlides) {
case 3: switch (xy) {
case 0: runFirstSlideIn();
break;
case 4: runFirstSlideOut();
slideImageIn();
imageSlide();
break;
case 15:slideOneOut();
slideCallToAction();
clearInterval(myInterval);
break;
}
break;
case 4: switch (xy) {
case 0: runFirstSlideIn();
break;
case 5: runFirstSlideOut();
slideImageIn();
imageSlide();
break;
case 10: slideOneOut();
slideTwoIn();
break;
case 15:slideTwoOut();
slideCallToAction();
clearInterval(myInterval);
break;
}
break;
}
//trace (xy);
xy++;
}
myInterval = setInterval(runBanner, duration);