To avoid importing loads of images into a Flash file and putting them on the timeline, i should like to simulate a movie clip by using an image-sequence, that is, by sequentially loading a series of still images, to& then, to "activate" - or view the sequence upon mouse-click, .
i figure this involves a loop and array, but i can't figure out the code.
Plz help.
thanks.
To sequentially load anything you need to use a functional loop (and the array and a counter variable). The basics of it are outlined below, but not in actual coding syntax, mainly descriptive...
var array:Array = new Array(your array of images); (if these are numerically named, then you may not need the array, just a count value so you know when to stop)
var count:int = 0;
function loadCurrentI mage(){
loader.load(array[count])
loader.contentLoaderInfo.addEventListener(COMPLETE,loadComplete)
}
function loadComplete(evt...){
// first process loaded image, then...
count++;
if(count < array.length){
loadCurrent(); // load the next image
} else {
// sequencial loading complete, carry on to next activity
}
}
hi Ned. Have built it up to proper syntax but getting an error:
| Scene 1, Layer 'Layer 1', Frame 1, Line 5 | 1067: Implicit coercion of a value of type Array to an unrelated type String. |
This happens when the jpg images are in the same directory as the FLA file.
On the other hand, when the images are in a folder on their own, also in the same file as the FLA file, using the path in AS URL request (var req:URLRequest = new URLRequest("../twirl_test"+imageArray); i get a security error that i've experienced in the past as relating to improper path: SecurityError: Error #2000: No active security context.
import flash.net.URLRequest;
import flash.display.Loader;
import flash.events.Event;
var count:int = 0;
var imageArray:Array=["image1.jpg","image2.jpg","image3.jpg","image4.jpg" ,"image5.jpg","image6.jpg","image7.jpg",
"image8.jpg","image9.jpg","image10.jpg"];
var url:String = "D:/flash cs5.5/image_sequence/twirl_test/"+imageArray;//TypeError: Error #2007: Parameter url must be non-null.
//var req:URLRequest = new URLRequest("../twirl_test/"+imageArray);
var request:URLRequest = new URLRequest(url);//SecurityError: Error #2000: No active security context.
var loader:Loader = new Loader();
//this is if u dont want the loader on the stage BETTER PRACTICE
function imageLoaded(event:Event):void
{
addChild(loader);
}
loader.contentLoaderInfo.addEventListener(Event.COMPLETE, imageLoaded);
loader.load(request);
function loadCurrentImage(){
loader.load(imageArray[count])
loader.contentLoaderInfo.addEventListener(Event.COMPLETE, loadComplete)
}
function loadComplete(event:Event){
// first process loaded image, then...
count++;
if(count < imageArray.length){
loadCurrentImage(); // load the next image
} else {
// sequencial loading complete, carry on to next activity
}
}
one element added at a time.
any help, from anyone, would be appreciated.
Ned, i am wondering if this - adding images sequentially to have a moving-image effect may be done using indexing - by adding one image to one loader on one frame? if so, can u help with the code for index? i cant remember how it's done. thanks for your help.
i imagine that once the path is established (the string), imageArray is the variable specified for it. The array - imageArray, is, i am imagining, the still images inside the folder thats in the url string, and therefor, in adding imageArray, it's like referring to the group of images versus one specific image, as such "D:/flash cs5.5/image_sequence/twirl_test/image1.jpg
so instead of getting image1.jpg, i am trying to tell Flash to get the images in the array, in accordance with their numeric order.
that's what i imagine.
If that is what you think you want to do, then that is the problem. You only want to ask for one image at a time. By appending the entire array to the url, your attempting to add apples (an array) to oranges (a string)... they are two different classes of objects. You want to add strings to strings... and your array contains individual strings.
North America
Europe, Middle East and Africa
Asia Pacific