PDA

View Full Version : Doesn't Autoplay + Bugs



icu222much
July 14th, 2009, 02:29 AM
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:

<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:

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++;
}

m90
July 14th, 2009, 09:54 AM
This sounds alot like an "Active Content" issue to me (the browser wants the user to "verify" the SWF so it won't do any harm to the computer, maybe also the user or whatever).
Have you tried embedding the swf via something like swfobject?

See: http://code.google.com/p/swfobject/

A simple <object><embed/></object> sometimes does REALLY weird things. Especially in IE.

icu222much
July 14th, 2009, 05:27 PM
I have used SWFObject, but it doesn't seem to work as the user still needs to click on the .swf to make it play. Furthermore, when you scroll up and down on the Window, sometimes the .swf will freeze mid frame and stop panning the image. Since the images are placed on a 20 second timer, the user will have to wait for 20 seconds before the next image begins to appear. I am not sure if I have used SWFObject correctly, but here is the HTML code that I have. I also downloaded the swfobject.js and placed it in the same directory as my other files.

Updated website: http://www.sfu.ca/~jca41/stuph/ny/template.html

HTML Head:

<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<script type="text/javascript" src="swfobject.js"></script>
<script type="text/javascript">
var flashvars = {};
var params = {};
params.play = "true";
params.loop = "true";
params.quality = "autohigh";
var attributes = {};
swfobject.embedSWF("slideShow08.swf", "myAlternativeContent", "360", "730", "9.0.0", false, flashvars, params, attributes);
</script>



HTML Body:

<div id="myAlternativeContent">
<a href="http://www.adobe.com/go/getflashplayer">
<img src="http://www.adobe.com/images/shared/download_buttons/get_flash_player.gif" alt="Get Adobe Flash player" />
</a>
</div>