Okay, I found some interesting code in AS3, but I just wanted to know if it would be possible to convert it to AS2…? There’s probably not much to convert, but I don’t know what it should be in AS2… I’m a novice and really don’t know a lot about the differences in AS2 and AS3. Thanks!
[COLOR=Black]var myImages = “”; // Should be like “1.jpg|2.jpg|3.jpg|4.jpg” (from a text file)
var myDelay = 5;
var img = 0;
var ordre = 0;
var image_total = 0;[/COLOR]
*var imageLoader:Loader = new Loader();
var imageLoader2:Loader = new Loader();
var myTween:TweenLite;
var myImages_array:Array = new Array;
function init_slideshow()
{
myImages_array = myImages.split("|");
image_total = myImages_array.length;
load_image(imageLoader,img);
load_image(imageLoader2,img+1);
img = img + 1;
animate_slideshow();
}
function animate_slideshow()
{
if(ordre == 0)
{
myTween = new TweenLite(myLoader, 2, {alpha:0,delay:myDelay, onComplete:next_slide});
}
else
{
myTween = new TweenLite(myLoader2, 2, {alpha:0,delay:myDelay, onComplete:next_slide});
}
}
function next_slide()
{
if(img >= image_total-1)
{
img = -1;
}
if(ordre == 0)
{
setChildIndex(myLoader,0);
setChildIndex(myLoader2,1);
myLoader.alpha = 1;
load_image(imageLoader,img+1);
img = img + 1;
ordre = 1;
}
else
{
setChildIndex(myLoader,1);
setChildIndex(myLoader2,0);
myLoader2.alpha = 1;
load_image(imageLoader2,img+1);
img = img + 1;
ordre = 0;
}
animate_slideshow();
}
function load_image(myMc,img)
{
myMc.unload();
if(ordre == 0)
{
for(var i:uint = 0; i < myLoader.numChildren; i++){
myLoader.removeChildAt(i);
}
}
else
{
for(var z:uint = 0; z < myLoader2.numChildren; z++){
myLoader2.removeChildAt(z);
}
}
myMc.load(new URLRequest("MyImagesURL/images/" + myImages_array[img]));
}
function hide_image()
{
if(img == myImages_array.length - 1)
{
img = 0;
}
else
{
img = img + 1;
}
myTween = new TweenLite(myLoader, 5, {alpha:0,delay:myDelay, onComplete:load_image, onCompleteParams:[img]});
}
imageLoader.contentLoaderInfo.addEventListener(Event.COMPLETE, function(e:Event){
myLoader.addChild(e.target.content);
});
imageLoader2.contentLoaderInfo.addEventListener(Event.COMPLETE, function(e:Event){
myLoader2.addChild(e.target.content);
});
[COLOR=Black]myLoader.x = 0;
myLoader.y = 0;
myLoader2.x = 0;
myLoader2.y = 0;[/COLOR]
[COLOR=#808080]var rnd:Number=Math.floor(Math.random()*100000000);
var url:String = “MyHandlerURL/handler.ashx?rn=”+rnd;
var loadit:URLLoader = new URLLoader();
loadit.addEventListener(Event.COMPLETE, completeHandler);
loadit.load(new URLRequest(url));
function completeHandler(event:Event):void {
myImages = event.target.data;
init_slideshow();[/COLOR]
}*
As for now, I have this (which is the last part of the code above (in grey)):
*rnd = Math.floor(Math.random()*100000000);
url = site_root + “/handler.ashx?id=” + _root.myid + “&rn=”+rnd; //Any existant image in the folder
var sendLV:LoadVars=new LoadVars();
var receiveLV:LoadVars=new LoadVars();
receiveLV.onData=function(src){*
myImages = src;*
init_slideshow();
*
*}
sendLV.sendAndLoad(url,receiveLV,“POST”);*
I know some of that is pretty much evident, but I’m taking no chance. Thanks!