Hello,
I’ve got code that takes text from an array and places it into a textbox. The first spot in the array is supposed to be null to correspond with the first section of the swf which shouldn’t have any text. But after navigating through the different array elements the movie gets confused and doesn’t recognize that the first slot should be empty and shifts things out of order.
What seems to be happening is when you are clicking the buttons to go to the sections there is a variable that is either incrimented or decrimented so that it can be used as the index for the array. It would seem that this variable is not being kept track of properly, as when you are at the end of the Array and there is no more sections you can still press the button that would incriment this variable and thus move to an element in the array that isn’t there (being array.length + 1 or -1 depending). so what is needed is some sort of condition that checks to see if this variable is infact at the last element in the array and if so not to incriment itself.
Here is the array code. This code is part of a loaded external movie.
[AS]
portfolioSection([" ", “section 02”, “section 03”, “section 04”]);
[/AS]
And this code is in the main movie that talks to the array in the external file.
[AS]
var aSectionTxt;
var iSectionIndex = 0;
_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;
path.section_mc.initEnterFrame(1);
}
};
path.back_btn.onRelease = function() {
if (targetX<527) {
targetX += 370;
path.section_mc.initEnterFrame(-1);
}
};
};
MovieClip.prototype.initEnterFrame = function(dir) {
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<<img src=“images/smilies/frustrated.gif” border=“0” alt="">targetX+1) && this._x><img src=“images/smilies/frustrated.gif” border=“0” alt="">targetX-1)) {
trace(“Stopping Enter Frame”);
this._x = targetX;
setSectionText(dir);
delete this.onEnterFrame;
}
};
};
_global.setSectionText = function (dir) {
if (dir != undefined) {
iSectionIndex += dir;
}
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;
}
};
[/AS]
I’ve been struggling with this for some time now, and had previously posted a thread about this earlier on but it’s since been deleted because there have been no responses and I wanted to try to present the problem a little clearer. Your help would be greatly appreciated. Thanks.