Flash 8 Dynamic Textfield

I have created a Flash photo slideshow that uses an xml file to populate the show, I have added a text field to show the image name but it only populates on the first photo, when I click the next button or allow the timer to switch photos the text field does not update.  I am using the textvariable.text = picArray[currentElement]; in the init() function and again in the nextpic() function which is called during the timed picture change and on the button press.  I am new to actionscript but I thought this would be a simple task please help!
chetweewaxAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

asaivanCommented:
Can you post more of your code?
chetweewaxAuthor Commented:
Here is all the code
import mx.transitions.Tween;
import mx.transitions.easing.Strong;
 
this.createEmptyMovieClip("container2_mc",this.getNextHighestDepth());
this.createEmptyMovieClip("container1_mc",this.getNextHighestDepth());
this.createEmptyMovieClip("buttons_mc",this.getNextHighestDepth());
this.attachMovie("loader","loader_mc",this.getNextHighestDepth());
loader_mc._x = (Stage.width - loader_mc._width)/2;
loader_mc._y = (Stage.height - loader_mc._height)/2;
container1_mc._x = 0;
container1_mc._y = 0;
container2_mc._x = 0;
container2_mc._y = 0;
 
var myMCL:MovieClipLoader = new MovieClipLoader();
var myListener:Object = new Object();
myMCL.addListener(myListener);
 
myListener.onLoadProgress = function(target,bytesLoaded,bytesTotal) {
	loader_mc._alpha = 100;
	var pct = Math.round(bytesLoaded/bytesTotal*100);
	loader_mc.bar_mc._xscale = pct;
}
 
myListener.onLoadComplete = function(target) {
	loader_mc._alpha = 0;
	fadeIn();
}
 
buttons_mc.attachMovie("prev","prev_mc",buttons_mc.getNextHighestDepth());
buttons_mc.attachMovie("next","next_mc",buttons_mc.getNextHighestDepth());
buttons_mc.attachMovie("play","play_mc",buttons_mc.getNextHighestDepth());
buttons_mc.attachMovie("pause","pause_mc",buttons_mc.getNextHighestDepth());
buttons_mc.attachMovie("name_txt","name_mc",buttons_mc.getNextHighestDepth());
buttons_mc.pause_mc._visible = false;
 
buttons_mc.name_mc._x = 5;
buttons_mc.name_mc._y = 390;
 
buttons_mc.next_mc._x = ((Stage.width - buttons_mc.next_mc._width)/2) + 50;
buttons_mc.next_mc._y = Stage.height - buttons_mc.next_mc._height - 10;
 
buttons_mc.prev_mc._x = ((Stage.width - buttons_mc.next_mc._width)/2) - 50;
buttons_mc.prev_mc._y = Stage.height - buttons_mc.next_mc._height - 10;
 
buttons_mc.pause_mc._x = (Stage.width - buttons_mc.pause_mc._width)/2;
buttons_mc.pause_mc._y = Stage.height - buttons_mc.pause_mc._height - 3;
 
buttons_mc.play_mc._x = (Stage.width - buttons_mc.play_mc._width)/2;
buttons_mc.play_mc._y = Stage.height - buttons_mc.play_mc._height - 3;
 
//-------XML ------//
var myXML:XML = new XML();
myXML.ignoreWhite = true;
 
var picArray:Array = new Array();
var currentElement:Number = 0;
 
myXML.onLoad = function(success) {
	if (success) {
		var ss:Array = myXML.firstChild.childNodes;
		for (i=0;i<ss.length;i++) {
			picArray.push(ss[i].attributes.url);
		}
		init();
	}
	else
	{
		trace("XML could not load");
	}
}
 
myXML.load("cake.xml");
 
var currentContainer:MovieClip = container1_mc;
 
function init() {
	myMCL.loadClip(picArray[currentElement],container1_mc);
	buttons_mc.name_mc.namepic.text = picArray[currentElement];
}
 
buttons_mc.pause_mc.onRelease = function() {
	buttons_mc.play_mc._visible = true;
	buttons_mc.pause_mc._visible = false;
	clearInterval(myInterval);
}
 
buttons_mc.play_mc.onRelease = function() {
	buttons_mc.pause_mc._visible = true;
	buttons_mc.play_mc._visible = false;
	clearInterval(myInterval);
	myInterval = setInterval(nextPicture, 5000);
	nextPicture();
}
 
buttons_mc.next_mc.onRelease = function() {
	buttons_mc.pause_mc._visible = true;
	buttons_mc.play_mc._visible = false;	
	nextPicture();
	clearInterval(myInterval);
	myInterval = setInterval(nextPicture, 5000);
}
 
 
function nextPicture()
{
	if (currentContainer == container1_mc) {
		currentContainer = container2_mc;
	}
	else
	{
		currentContainer = container1_mc;
	}
	currentContainer._alpha = 0;
	container1_mc.swapDepths(container2_mc);
	if (currentElement < picArray.length-1) {
		currentElement++;
	}
	else
	{
		currentElement = 0;
	}
	
	buttons_mc.name_mc.namepic.text = picArray[currentElement];
	myMCL.loadClip(picArray[currentElement],currentContainer);
 
}
 
 
buttons_mc.prev_mc.onRelease = function() {
	buttons_mc.pause_mc._visible = true;
	buttons_mc.play_mc._visible = false;
	if (currentContainer == container1_mc) {
		currentContainer = container2_mc;
	}
	else
	{
		currentContainer = container1_mc;
	}
	currentContainer._alpha = 0;
	container1_mc.swapDepths(container2_mc);
	if (currentElement > 0) {
		currentElement--;
	}
	else
	{
		currentElement = picArray.length-1;
	}
	myMCL.loadClip(picArray[currentElement],currentContainer);
	clearInterval(myInterval);
	myInterval = setInterval(nextPicture, 5000);
}
 
function fadeIn() {
	new Tween(currentContainer,"_alpha",Strong.easeOut,0,100,36,false);
}

Open in new window

asaivanCommented:
Well, one thing I'm noticing is that you don't have myInterval declared outside of any code block.  I don't know if it's directly related to the problem, but in order to access the myInterval consistently as the same object, you'll need to declare it.  

var myInterval:Object;

Try this first.

Determine the Perfect Price for Your IT Services

Do you wonder if your IT business is truly profitable or if you should raise your prices? Learn how to calculate your overhead burden with our free interactive tool and use it to determine the right price for your IT services. Download your free eBook now!

chetweewaxAuthor Commented:
I get a type mismatch error if I add the var myInterval:Object;  The myInterval only has to do with the timer to change pictures automatically.  The text field does not update even on the click of the next button.
asaivanCommented:
Then untype the object.

var myInterval;

What do you get if you do:

trace ( buttons_mc.name_mc.namepic.text );

in the nextPicture function?  Is it changing?



chetweewaxAuthor Commented:
when I did a trace on buttons_mc.name_mc.namepic.text the image name was always the first picture.  I changed the buttons_mc.name_mc.namepic.text = picArray[currentElement]; to buttons_mc.name_mc.namepic = picArray[currentElement]; and ran another trace and the value changed as the pictures changed.  So it seems to be working now.
asaivanCommented:
ok, keep me posted

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Adobe Flash

From novice to tech pro — start learning today.