0
votes

Here is my problem. I have a script that calls for 3 random images to be generated 3 times in 15 second intervals. Basically it would look like X X X for 15 seconds and then those X's would turn into 0 0 0 after 15 seconds and then 15 seconds later they would turn into Y Y Y and then stop. This is my code:

import flash.utils.*;

var stuffCount:uint = 0;

function randomocity() {
    stuffCount++;

var ImgReq01:URLRequest=new URLRequest("example.jpg");
var ImgReq02:URLRequest=new URLRequest("example.jpg");
var ImgReq03:URLRequest=new URLRequest("example.jpg");
var ImgReq04:URLRequest=new URLRequest("example.jpg");
var ImgReq05:URLRequest=new URLRequest("example.jpg");

var imgList:Array=[ImgReq01,ImgReq02,ImgReq03,ImgReq04, ImgReq05];

var imgRandom = imgList[Math.ceil(Math.random()* imgList.length)];

var imgLoader:Loader = new Loader();
imgLoader.load(imgRandom);

imgLoader.contentLoaderInfo.addEventListener(Event.COMPLETE, onComplete);

function onComplete(event:Event):void 
{
  var randomImage:Bitmap = Bitmap(imgLoader.content);
  randomImage.x=0;
  randomImage.y=0;
  addChild(randomImage);
  event.currentTarget.removeEventListener(Event.COMPLETE, onComplete);
}

stop();

if (stuffCount < 3)
    {
        setTimeout(randomocity, 11000);
    }

}

randomocity();

My Problem however is the error that is being generated.

TypeError: Error #2007: Parameter request must be non-null. at flash.display::Loader/_load() at flash.display::Loader/load() at _300x250_fla::randomimage3_14/frame1()

This is the code from the movieclip Randomimage3 where it is stating the error. I use this same code on 3 movieclips with different lists of photos. Is that the problem? If so how would I solve it? I'm doing this because there are 3 different groups that need to be displayed.

1

1 Answers

3
votes

Did you mean floor?

var imgRandom = imgList[Math.floor(Math.random()* imgList.length)];