# Need help to convert from AS3 to AS2

**URL:** https://forum.kirupa.com/t/need-help-to-convert-from-as3-to-as2/310593
**Category:** Uncategorized
**Created:** [June 14, 2010, 2:57pm UTC](https://forum.kirupa.com/t/need-help-to-convert-from-as3-to-as2/310593 "2010-06-14T14:57:52Z")
**Posts on this page:** 1
**Page:** 1

<div class="post-metadata">

### Author: ![StackOverflow](https://avatars.discourse-cdn.com/v4/letter/s/46a35a/32.png) [@StackOverflow](https://forum.kirupa.com/u/StackOverflow)
#### Post date: [June 14, 2010, 2:57pm UTC](https://forum.kirupa.com/t/need-help-to-convert-from-as3-to-as2/310593/1 "2010-06-14T14:57:52Z")

</div>

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 &lt; myLoader.numChildren; i++){
       myLoader.removeChildAt(i);
    }
}
else
{
    for(var z:uint = 0; z &lt; 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!
