|
-
I need Actionscript Help with this! Anyone!!!
Hi evryone
Iv been banging my head against a brick wall for the last 3months ... i cant get any assistance anyware and its really driving me mad.... this is my problem... iv managed to put together a php script that reads the contents of the folder that the php file is in... so if theres 6files in a specific folder on your Apache server when you execute the php file in your web browser the output strings would be for e.g file3=getFiles.fla file4=getFiles.swf ....ect..! Right php working fine...ITS JUST FLASH thats being silly ..Right? heres my script!
var myLoadVars:LoadVars = new LoadVars();
myLoadVars.onLoad = function(success:Boolean) {
if (success) {
for (var i = 0; i<10; i++) {
var fileName = "file";
var fileNumber = i;
var files = fileName+fileNumber;
trace(files);
myTree.dataProvider = [myLoadVars.file3,myLoadVars.file5];
}
trace(myLoadVars.file3);
}
};
myLoadVars.load("http://localhost/listfiles.php");
If you wanna see the results for yourself just change localhost to moneyspiderr.com!!
You see the "myTree.dataProvider = [myLoadVars.file3,myLoadVars.file5];" section that puts the php output results in the Tree component... i just want to add the "i" value to the file3 value so i get somthing like this "file"+i = file1,file2,file3 ect....as you can see i have accomplised that with this
for (var i = 0; i<10; i++) {
var fileName = "file";
var fileNumber = i;
var files = fileName+fileNumber;
trace(files);
its just that when i now try to use that paticular string inside the [myLoadVars.file3,myLoadVars.file5];" statement like this [myLoadVars.files] the statement dont work!!! it returns a undefined value.....what would be the correct way to deal with this problem....please help...im going mad over here...lol if i can pull this off i would of created a flash tree menu that can read and display the content of your folder....if you aint got one of these then you can have a copy of my completed fla.......
I hope you can help me...Thanx
Jaden
www.moneyspiderr.com
-
FK'n_dog
The data of a tree component must be provided from an XML data source,
and needs to be well formed ( which yours is not, [use List Variables] )
so you need to manipulate the string from your php file to correct it,
or manipulate it into well formed XML in Flash
this is a method to correct the string in Flash -
PHP Code:
var myLoadVars:LoadVars = new LoadVars();
myLoadVars.onLoad = function(success:Boolean) {
if (success) {
str = unescape(this).toString();
str = str.split("<dataSet><data><name></name></data></dataSet>").join("");
arr = str.split("<br>");
arr.pop();
newStr = "";
for(var i=0;i<arr.length;i++){
var u = arr[i].split("=");
newStr +="<node label='"+u[1]+"'/>";
}
var trDP_xml:XML = new XML("<node label='Local Files'>"+newStr+"</node>");
myTree.dataProvider = trDP_xml;
}
};
myLoadVars.load("http://moneyspiderr.com/listfiles.php");
i doubt it is exactly as you want it, but it should help you on your way
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
|