Doesn't Autoplay + Bugs
I have embedded a swf inside my html file, but it doesn't seem to play once it has loaded. Instead, you have to click on it to start up the movie. I am wondering if there is a way to fix this? Does it have something to do with the HTML code?
In addition, I've noticed that sometimes the .swf will freeze up or stutter. For instance, sometimes the tweens do not finish completely. Could this be because of my AS3 coding?
Link to website:
http://www.sfu.ca/~jca41/stuph/ny/template.html
Link to .swf
http://www.sfu.ca/~jca41/stuph/ny/slideShow07.swf
HTML CODE:
<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=9,0,0,0" width="360" height="730" id="slideShow07" align="middle">
<param name="allowScriptAccess" value="sameDomain" />
<param name="allowFullScreen" value="false" />
<param name="movie" value="slideShow07.swf" /><param name="quality" value="best" /><param name="bgcolor" value="#ffffff" />
<embed src="slideShow07.swf" quality="best" bgcolor="#ffffff" width="360" height="730" name="slideShow07" align="middle" allowScriptAccess="sameDomain" allowFullScreen="false" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" />
AS3 CODE:
import fl.transitions.Tween;
import fl.transitions.easing.*;
////////////////////////////
/// Variables to Change ///
var imgArray:Array = new Array("img01", "img02", "img03", "img04", "img05");
var txtArray:Array = new Array("txt01", "txt02", "txt03", "txt04", "txt05");
var tween1Speed:Number = 1; //1
var tween2Speed:Number = 20; //20
/// End of Variables ///
///////////////////////
var imgDefArray:Array = new Array();
var txtDefArray:Array = new Array();
var iSlideShow:int = 0;
var iLoadChild:int = 0;
var tempI:int;
var newYellowBar:yellowBar = new yellowBar();
addChild(newYellowBar);
newYellowBar.x = -50;
var timer1Delay:Number = tween2Speed * 0.70 * 1000;
var timer1:Timer = new Timer(0, 0);
timer1.addEventListener(TimerEvent.TIMER, slideShow1);
var timer2Delay:Number = tween1Speed * 1000;
var timer2:Timer = new Timer(timer2Delay, 0);
timer2.addEventListener(TimerEvent.TIMER, slideShow2);
mc.addEventListener(Event.ACTIVATE, loadChild);
function loadChild(e:Event){
timer1.start();
for (iLoadChild = 0; iLoadChild < imgArray.length; iLoadChild++) {
var imgDef:Class = getDefinitionByName(imgArray[iLoadChild]) as Class;
var txtDef:Class = getDefinitionByName(txtArray[iLoadChild]) as Class;
var img:MovieClip = new imgDef();
var txt:MovieClip = new txtDef();
imgDefArray[iLoadChild] = img;
txtDefArray[iLoadChild] = txt;
addChild(imgDefArray[iLoadChild]);
addChild(txtDefArray[iLoadChild]);
imgDefArray[iLoadChild].x = 800;
imgDefArray[iLoadChild].y = 800;
txtDefArray[iLoadChild].x = 800;
txtDefArray[iLoadChild].y = 800;
}
}
function slideShow1(e:TimerEvent):void {
timer1.delay = timer1Delay;
timer1.stop();
timer2.start();
setChildIndex(imgDefArray[iSlideShow], numChildren - 1);
setChildIndex(txtDefArray[iSlideShow], numChildren - 1);
setChildIndex(newYellowBar, numChildren - 1);
imgDefArray[iSlideShow].x = 600;
imgDefArray[iSlideShow].y = 320;
txtDefArray[iSlideShow].x = 600;
txtDefArray[iSlideShow].y = 600;
newYellowBar.x = 600;
newYellowBar.y = 320;
new Tween(imgDefArray[iSlideShow], "x", None.easeInOut, 360, 0, tween1Speed, true);
new Tween(txtDefArray[iSlideShow], "x", None.easeInOut, 720, 360, tween1Speed, true);
new Tween(newYellowBar, "x", None.easeInOut, 360, 0, tween1Speed, true);
tempI = iSlideShow - 1;
if (tempI == -1){
tempI = txtDefArray.length - 1;
}
setChildIndex(txtDefArray[tempI], numChildren - 1);
txtDefArray[tempI].x = 360;
txtDefArray[tempI].y = 600;
new Tween(txtDefArray[tempI], "x", None.easeInOut, 360, 0, tween1Speed, true);
}
function slideShow2(e:TimerEvent):void {
timer1.start();
timer2.stop();
setChildIndex(imgDefArray[iSlideShow], numChildren - 1);
setChildIndex(txtDefArray[iSlideShow], numChildren - 1);
imgDefArray[iSlideShow].x = 0;
imgDefArray[iSlideShow].y = 320;
new Tween(imgDefArray[iSlideShow], "x", None.easeInOut, 0, -1000, tween2Speed, true);
if (iSlideShow == imgArray.length -1) {
iSlideShow = -1;
}
iSlideShow++;
}