-
[RESOLVED] var's to array problem
Please help. The problem is the string of numbers load from the file.txt and look ok. But they do not become a usable array(undefined). So mc1 does not move.
The data in the file.txt is formatted like this -
&myData=10,15,20,25,30,35,40,45,50,55,60,65,70
// the code
var inc = 0;
var lv = new LoadVars();
lv.onLoad = function(success)
{
if(success)
{
myData = lv.myData;
move = new Array(myData);
}
}
lv.load("file.txt");
onEnterFrame = function()
{
_root.mc1._x = move[inc];
inc += 1;
if(inc > 10) {inc = 0};
}
-
FK'n_dog
PHP Code:
lv.onLoad = function(success){
move = new Array();
if(success){
myData = lv.myData;
move = myData.split(","); // split the loaded string by the comma delimiter
}
}
hth
-
Thank you(a_modified_dog) so much for you help! Your code works great! I've spent far too many hours reading the actionscript dictionary, tutorials, forum threads and experimenting with the code. I've learnt alot about loading var's and array handing. But it still escaped me. I wish I had posted here earlier. I did try split, concat, push, jump, scream, and shout! and some. But not like the way you have done it. I can now see that you have to create an new array object first, then split the var's later. Thank you!
-
Still kisses with saliva
I'm trying to do almost exactly the same thing, but I'm still getting (undefined). When I trace the variable that's being split into the array, it returns: <p align="left"></p>
My text file is MEname9.txt and contains:
&MEnames=1,2,3,4
The code I have currently for this section is:
var photoNum = 0;
var NameLoader = new LoadVars();
NameLoader.onLoad = function(success){
NameArray = new Array();
if (success){
MEnames = NameLoader.MEnames;
NameArray = MEnames.split(",");
}
}
NameLoader.load("MEname9.txt");
trace(MEnames);
NameBox.text = NameArray[photoNum];
It's identical to what a_modified_dog posted, and I can't see any difference in what I'm doing vs. what ellis001 was trying to do as far as importing the text and putting it into an array. But the array just isn't working. Any advice?
a pig
in a cage
on antibiotics
-
Still kisses with saliva
a pig
in a cage
on antibiotics
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|