OK, here goes. Ive posted on another forum without any solution. I am somewhat of a noob in actionscript 3. I am creating a swf player from a parent swf that is navigated by the photoflow component at flashloaded. So the loader plays swfs based off of selections in the component. it also detects if a swf is done playing and starts the next. The following is my code to accomplish this:
import com.flashloaded.as3.PhotoFlowEvent;
myPhotoFlow.autoFlipDelay = 4;
myPhotoFlow.photoAngle = 10;
myPhotoFlow.selectedReflectionAlpha = 65;
myPhotoFlow.reflectionDepth = 40;
myPhotoFlow.selectedReflectionDepth = 45;
myPhotoFlow.selectedY = 15;
myPhotoFlow.motionSpeed = 4;
myPhotoFlow.distance = 5;
myPhotoFlow.spacing = 100;
var swiffIds = new Array();
var swiffThumbs = new Array();
var swiffPaths = new Array();
var index:Number = new Number(0);
var temp:Number = new Number();
var closeVid:Number = new Number(1);
var loader:Loader = new Loader();
LoadSwiffys(closeVid);
function swiffysLoaded()
{
var url:URLRequest = new URLRequest(swiffPaths[index]);
//var loader:Loader = new Loader();
loader.load(url);
addChildAt(addChild(loader), 1);
//start loading.swf
var loadingurl:URLRequest = new URLRequest("loading.swf");
var loading:Loader = new Loader();
loading.load(loadingurl);
addChildAt(addChild(loading), 1);
loader.contentLoaderInfo.addEventListener(ProgressEvent.PROGRESS, loadProgress);
loader.contentLoaderInfo.addEventListener(Event.COMPLETE, loadComplete);
function loadProgress(event:ProgressEvent):void {
var percentLoaded:Number = event.bytesLoaded/event.bytesTotal;
percentLoaded = Math.round(percentLoaded * 100);
//trace("Loading: "+percentLoaded+"%");
}
function loadComplete(event:Event):void {
loading.unload();
//trace("Complete");
var i:Number = new Number((MovieClip(loader.content)).totalFrames);
//trace(i);
(MovieClip(loader.content)).addEventListener(Event.ENTER_FRAME, nextVideo);
}
//event listener for click on a thumbnail
myPhotoFlow.addEventListener(PhotoFlowEvent.CLICK_SELECTED, photoClick);
//myPhotoFlow.addEventListener(PhotoFlowEvent.SELECT, photoClick);
function nextVideo(event:Event):void {
if ((MovieClip(loader.content)).totalFrames == (MovieClip(loader.content)).currentFrame) {
(MovieClip(loader.content)).removeEventListener(Event.ENTER_FRAME, nextVideo);
loader.unload();
temp = index + 1;
if (temp == swiffPaths.length) {
index = 0;
myPhotoFlow.setSelection(0);
} else {
index++;
myPhotoFlow.next();
closeVid = 0;
}
swiffysLoaded();
}
}
function photoClick(eo:PhotoFlowEvent):void {
var len:Number = swiffThumbs.length;
for(var t=0; t<len; t++){
myPhotoFlow.removePhoto(0);
}
index = 0;
var vidNum:Number = (eo.data.desc);
//trace(vidNum);
(MovieClip(loader.content)).removeEventListener(Event.ENTER_FRAME, nextVideo);
loader.unload();
LoadSwiffys(vidNum);
}
}
function addPhotos() {
var len:Number = swiffThumbs.length;
for(var r=0; r<len; r++){
myPhotoFlow.removePhoto(0);
}
//var len:Number = swiffThumbs.length;
for(var t=0; t<len; t++){
var obj1:Object = {name:swiffIds[t], desc:swiffIds[t], url:swiffThumbs[t]};
myPhotoFlow.addPhoto({name:swiffIds[t], desc:swiffIds[t], url:swiffThumbs[t]}, t);
//trace(swiffIds[t]);
}
//myPhotoFlow.addEventListener(PhotoFlowEvent.CLICK_SELECTED, photoClick);
}
//////////////////////////Functions to load swiffys///////////////////////////////////
function LoadSwiffys(closeVid)//eventually,pass the IP and refer in here
{
var request:URLRequest = new URLRequest("http://192.168.1.172/newsite/loadswfs.php?click=" + closeVid);//and send ip and refer here too
var variables:URLLoader = new URLLoader();
variables.dataFormat = URLLoaderDataFormat.VARIABLES;
variables.addEventListener(Event.COMPLETE, completeHandler);
try
{
variables.load(request);
}
catch (error:Error)
{
trace("Unable to load URL: " + error);
}
}
function completeHandler(event:Event):void
{
var loader:URLLoader = URLLoader(event.target);
var variables:URLVariables = new URLVariables(loader.data);
swiffIds = variables.swiffId.split(",");
swiffPaths = variables.swiffPath.split(",");
swiffThumbs = variables.swiffThumb.split(",");
swiffysLoaded();
addPhotos();
}
When i run it in the output window I get an error:
TypeError: Error #1009: Cannot access a property or method of a null object reference.
at MethodInfo-394()
I have been told that it might have something to do with this line:
(MovieClip(loader.content)).totalFrames == (MovieClip(loader.content)).currentFrame
but im not sure. Its not a huge deal because it still functions correctly, except most browsers throw an error and stops the play. Does anyone know what might be wrong? or if you dont know, is there a way to supress the output so this error does not come up on browsers? Thanks for the help.