# AS not working in Flash Player 8. Works in 6

**URL:** <https://forum.kirupa.com/t/as-not-working-in-flash-player-8-works-in-6/187693>\
**Category:** Uncategorized\
**Created:** [May 1, 2006, 4:39pm UTC](https://forum.kirupa.com/t/as-not-working-in-flash-player-8-works-in-6/187693 "2006-05-01T16:39:52Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![wyclef](https://avatars.discourse-cdn.com/v4/letter/w/65b543/32.png) [@wyclef](https://forum.kirupa.com/u/wyclef)\
**Post date:** [May 1, 2006, 4:39pm UTC](https://forum.kirupa.com/t/as-not-working-in-flash-player-8-works-in-6/187693/1 "2006-05-01T16:39:52Z")

</div>

Can someone take a look at this AS and see if they notice any reason it wouldn’t work in Flash Player 8?

```auto

function portfolioList() {
	// array of link names used in the dynamic text field name dText
	linkArray = ["AAA", "BBB", "CCC", "DDD"];
	folio_arr = ["a", "b", "c", "d"];
	// our starting depth
	depth = 6;
	// our starting coordinates
	startX = 45;
	startY = 97;
	// our multiplication number so the clips are stacked on each other
	n = 0;
	// our loop that creates a link for each element in linkArray
	for (var i = 0; i<linkArray.length; i++) {
		// if i equals have the array length
		// we should start a new row
		if (i == Math.ceil(linkArray.length/2)) {
			startX += 130;
			n = 0;
		}
		// attach the movieClip to _root's timeline 
		var x = this.attachMovie("dynamicLink", "dlink"+depth, depth++);
		// put them in their places
		x._x = startX;
		//x._y = startY+(x._height*n);
		x._y = startY+((x._height-1)*n);
		// assign their text
		x.dText.text = linkArray*;
		x.currindex = i;
		// incriment the number
		n++;
	}
}
portfolioList();
// ------------------------------------------------------------------
function clearPortfolioList() {
	var _mc;
	var d = 6;
	var t = linkArray.length;
	for (i=0; i<t; i++) {
		_mc = this["dlink"+(++d)];
		trace("unloading "+_mc);
		unloadMovie(_mc);
	}
}
// ------------------------------------------------------------------
var aSectionTxt;
var iSectionIndex = 0;
trace(iSectionIndex);
_global.portfolioSection = function(a) {
	targetX = 527;
	path = _root.sectionMC_03.folioClip;
	maxWidth = path.section_mc._width-529;
	velocity = 4;
	aSectionTxt = a.concat();
	path.section_mc.initEnterFrame();
	path.forward_btn.onRelease = function() {
		if (targetX>-(maxWidth-370)) {
			targetX -= 370;
			var dir = 1;
			if (iSectionIndex+dir>=0 && iSectionIndex+dir<=aSectionTxt.length) {
				iSectionIndex += dir;
			}
			// iSectionIndex must be set here -- not at the end of the enterframe func. 
			path.section_mc.initEnterFrame();
		}
	};
	path.back_btn.onRelease = function() {
		if (targetX<527) {
			targetX += 370;
			var dir = -1;
			if (iSectionIndex+dir>=0 && iSectionIndex+dir<=aSectionTxt.length) {
				iSectionIndex += dir;
			}
			// iSectionIndex must be set here -- not at the end of the enterframe func. 
			path.section_mc.initEnterFrame();
		}
	};
};
MovieClip.prototype.initEnterFrame = function() {
	path.section_txt.text = "";
	if (mcMovieToRemove != null) {
		removeMovieClip(mcMovieToRemove);
	}
	this.onEnterFrame = function() {
		trace("Running Enter Frame");
		this._x += (targetX-this._x)/velocity;
		if (this._x<(targetX+1) && this._x>(targetX-1)) {
			trace("Stopping Enter Frame");
			this._x = targetX;
			setSectionText();
			delete this.onEnterFrame;
		}
	};
};
_global.setSectionText = function() {
	if (typeof (aSectionTxt[iSectionIndex]) == "string") {
		path.section_txt.text = aSectionTxt[iSectionIndex];
	} else {
		mcMovieToRemove = path.attachMovie(aSectionTxt[iSectionIndex].linkage, "mcSectionMovie", 10);
		mcMovieToRemove._x = aSectionTxt[iSectionIndex].x;
		mcMovieToRemove._y = aSectionTxt[iSectionIndex].y;
	}
};
// ------------------------------------------------------------------
unloadMovie("folioClip");

```

---

<div class="post-metadata">

**Author:** ![wyclef](https://avatars.discourse-cdn.com/v4/letter/w/65b543/32.png) [@wyclef](https://forum.kirupa.com/u/wyclef)\
**Post date:** [May 12, 2006, 12:57am UTC](https://forum.kirupa.com/t/as-not-working-in-flash-player-8-works-in-6/187693/2 "2006-05-12T00:57:55Z")

</div>

I think the key is to change…

```auto

 if (iSectionIndex+dir>=0 && iSectionIndex+dir<=aSectionTxt.length) {
                iSectionIndex += dir;
            }

```

to include…if iSectionIndex + dir \>= 0 && iSectionIndex+dir\<=aSectionTxt.length AND this.\_x EQUALS targetX… or something like that then it would work. I just need iSectionIndex not to increment while this.\_x is busy reaching targetX and then I think everything would work. Or like if targetX-this.\_x/velocity = 0 then iSectionIndex += dir.
