# loadVars in a function

**URL:** <https://forum.kirupa.com/t/loadvars-in-a-function/174630>\
**Category:** flash\
**Created:** [January 7, 2006, 1:57pm UTC](https://forum.kirupa.com/t/loadvars-in-a-function/174630 "2006-01-07T13:57:20Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![Sammo](https://yyz1.discourse-cdn.com/flex011/user_avatar/forum.kirupa.com/sammo/32/779_2.png) [@Sammo](https://forum.kirupa.com/u/Sammo)\
**Post date:** [January 7, 2006, 1:57pm UTC](https://forum.kirupa.com/t/loadvars-in-a-function/174630/1 "2006-01-07T13:57:20Z")

</div>

```auto
function loadBox(winTitle, textVar, x, y) {
	name = "box" + getNextHighestDepth();
	attachMovie("box", name, getNextHighestDepth());
	_root[name]._x = x, _root[name]._y = y;
	_root[name].topbar.winTitle.text = title;
	var loadText:LoadVars = new LoadVars();
	loadText.load("text.txt");
	loadText.onLoad = function() {
		_root[name].textArea.text = textVar;
	};
	_root[name].topbar.onPress = function() {
		_root[name].startDrag();
		updateAfterEvent();
	};
	_root[name].topbar.onRelease = _root[name].topbar.onReleaseOutside = function () {
		_root[name].stopDrag();
	};
}
loadBox("Text 1",text1, 100, 100);

```

This function attaches the movieclip successfully, however it does not pull the data from the text file, nor does it set the title.
