# Variables in Functions Quick Question

**URL:** <https://forum.kirupa.com/t/variables-in-functions-quick-question/169533>\
**Category:** flash\
**Created:** [November 17, 2005, 12:27am UTC](https://forum.kirupa.com/t/variables-in-functions-quick-question/169533 "2005-11-17T00:27:27Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![misterpatrick](https://avatars.discourse-cdn.com/v4/letter/m/da6949/32.png) [@misterpatrick](https://forum.kirupa.com/u/misterpatrick)\
**Post date:** [November 17, 2005, 12:27am UTC](https://forum.kirupa.com/t/variables-in-functions-quick-question/169533/1 "2005-11-17T00:27:27Z")

</div>

Hey all,

I can’t figure this out.

```auto

function createTextBoxes() {
	for (var n=0; n<caption_obj.textXML.length; n++){
		this.createTextField("captions"+n, n, 280, 288, 470, 87);
		this["captions"+n]._x = 200;
		this["captions"+n]._y = 200;
		this["captions"+n].text = caption_obj.currCaption[n];
	}
};

```

The XML portion is working fine. What I’d like to be able to do is access the created text fields outside of the function. For example:

captions1.alphaTo(0,1,“linear”,1);

This works fine when it’s inside of the function, but outside of it, it won’t. Basically I need to time the captions to things that are happening in an animation. The animations are also tween driven, so it would be something like obj\_mc.tween("\_x", 200,2,“linear”,5,fadeOutCaption1); with fadeOutCaption1 being a function that fades out the first caption and brings in the second. If there is a better/more effecient way of doing this let me know.

I also can’t seem to apply any styles to the text field. Do I need to create an array or object with [“captions”+n] and then pull from that?

Thanks!
