Q:

Error joining AS2 with AS3

I have problems joining two scripts into one.
This is main part of the script: AS3.
And this is already joined script.
And here is part of the code that I need to import (AS2) :
stop();
var banners:Array = new Array();
var imagePaths:Array = new Array();
var links:Array = new Array();
var bodyTexts:Array = new Array();
var imageTime:Number;
var numberOfBanners:Number;
var isRandom:String;
var showHeader:String;
var bannersXML:XML = new XML();
bannersXML.ignoreWhite = true;
bannersXML.load("banners.xml");
bannersXML.onLoad = function(success) {
    if (success) {
        trace("XML LOADED");
        imageTime = parseInt(this.firstChild.firstChild.firstChild)*1000;
        numberOfBanners = parseInt(this.firstChild.childNodes[1].firstChild);
        isRandom = this.firstChild.attributes["isRandom"];
        showHeader = this.firstChild.childNodes[2].attributes["showHeader"];

        var bannerSequence:Array = new Array();
        if (isRandom == "true") {
            //Make a random sequence
            while (bannerSequence.length<numberOfBanners) {
                newRandomNumber = random(numberOfBanners);
                //Make sure that the random one chosen is not already chosen
                for (var i = 0; i<=bannerSequence.length; i++) {
                    if (newRandomNumber != bannerSequence[i]) {
                        alreadyThere = false;
                    } else {
                        alreadyThere = true;
                        break;
                    }
                }
                //Add only random values that aren't in the array
                if (!alreadyThere) {
                    bannerSequence.push(newRandomNumber);
                }
            }
        } else {
            for (var i = 0; i<numberOfBanners; i++) {
                bannerSequence.push(i);
            }
        }
    }

    //Read XML in the Random Order Chosen
    for (var i = 0; i<numberOfBanners; i++) {
        banners.push(this.firstChild.childNodes[2].childNodes[bannerSequence[i]].firstChild.firstChild.toString());
        bodyTexts.push(this.firstChild.childNodes[2].childNodes[bannerSequence[i]].childNodes[1].firstChild.nodeValue);
        imagePaths.push(this.firstChild.childNodes[2].childNodes[bannerSequence[i]].childNodes[2].firstChild.nodeValue);
        links.push(this.firstChild.childNodes[2].childNodes[bannerSequence[i]].childNodes[3].firstChild.nodeValue);
    }
    play();
};
//Start the image counter at 0
var imageCounter = 0;

I get erorr in this part of the code
function doRandArray(a:Array):Array {//make random array
 var nLen:Number = a.length;
 var aRand:Array = a.slice();
 var nRand:Number;
 var oTemp:Object;
 for (var i:Number = 0; i < nLen; i++) {
  oTemp = aRand[i];
  nRand = i + (random(nLen – i));
  aRand[i] = aRand[nRand];
  aRand[nRand] = oTemp;
 }
 return aRand;
}

When I run it, I get an error in this place:
nRand = i + (random(nLen – i));
Scene 1, Layer 'Layer 1', Frame 1, Line 265 1084: Syntax error: expecting rightparen before i.

A:

as2 random(random(nLen – i)); is generate 0,1,...nLen-i-1. not floating only int value.
correct as3 code is int(Math.random()*(nLen-i)); or Math.floor(Math.random()*(nLen-i));
as2: random()
as3: Math.random()

