PDA

View Full Version : Moving an MC using an external text file


jbuk27
02-05-2007, 12:21 PM
Hi,

I need to make a movieclip traverse along the x coordinate by using a simple .txt file with a number in it. For example, if my text file had a 1 in it, the MC would be something like: this.test_mc._x= 100; and a 2, this.test_mc._x= 200; and so on (up to ten times). Can anyone help, I'm getting lost with this one.

This is the code I have cobbled together, but obviously doesn't work:

var txtfile = new LoadVars();
txtfile.load("test.txt");

if (txtfile="1") {
this.test_mc._x= 100;

}
if (txtfile="2") {
this. test_mc._x= 200;
}


Many thanks

JB

mooska
02-05-2007, 12:33 PM
var lv:LoadVars = new LoadVars();

lv.root = this;
lv.onLoad = function(s:Boolean){
if(s){
if(this.variable == "1"){
this.root._x = 100;
}
}
}
lv.load("file.txt");

jbuk27
02-05-2007, 01:12 PM
mooska: Many thanks for taking the time to try and give me a solution, but I still cannot get this to work… any ideas?