[swx] Need help with Object being returned from swx
Jake Ketcheson
jake at fiveht.com
Thu Apr 24 12:38:12 PDT 2008
I'm trying to convert an object returned into an multidimensional array
to be used as a menu later on in the script.
Here is my current code (please excuse the terribleness of it):
import org.swxformat.*;
progressIndicator._visible = false;
dataLoaded._visible = false;
_root.classesArray = new Array;
// Create a new SWX object
var swx:SWX = new SWX();
swx.encoding = "POST";
swx.gateway = "http://localhost:8888/php/swx.php";
// Load the movie
loadDataButton.onRelease = function ()
{
// Set call details.
var callDetails:Object =
{
serviceClass: "courses",
method: "listClasses",
args:[""],
result: [this, resultHandler],
timeout: [this, timeoutHandler],
debug: true
}
// Carry out SWX call.
swx.call(callDetails);
// Set status display.
}
function resultHandler(resultObj:Object)
{
// Load is complete.
isLoading(false);
// Display the results.
_root.classesArray = resultObj.result;
//trace(feed.1.length);
parseObject(_root.classesArray);
}
function timeoutHandler(event:Object)
{
// Call timed out.
isLoading(false);
contentText.text = "The call timed out. Please try again.";
}
function parseObject(resultObj:Array){
var count:Number = 0;
var i:Number = 0;
var j:Number = 0;
var objLength = new Array();
var className:Object = new Object();
var classId = new Array();
var count:Number = 0
resultObj = resultObj["classes"];
for (var key in resultObj){
objLength[count] = resultObj[key].name.length;
for (var j = 0; j<objLength[count]; j++)
className[count][j]. = resultObj[key].name[j];
}
count++;
}
}
I'm getting stuck on trying to force flash to give me an array I could
access in the form of className[0][1]
It seems whenever I try to make this I just get undefined back from the
trace.
Here is the object SWX returns to me:
(Object)#0
classes = (Object)#1
1 = (Object)#2
id = (Array)#3
[0] "11"
name = (Array)#4
[0] "Procurement Foundations online learning"
2 = (Object)#5
id = (Array)#6
[0] "13"
[1] "8"
[2] "12"
[3] "15"
[4] "7"
[5] "9"
name = (Array)#7
[0] "Administering and Evaluating Contract Performance"
[1] "Contract Management Planning"
[2] "Contract Solicitation, Award and Monitoring"
[3] "Laws and Ethics for Competitive Procurement"
[4] "Procurement Management and Negotiations: Theory and Issues"
[5] "Understanding and Drafting Contracts elearning"
3 = (Object)#8
id = (Array)#9
[0] "37"
[1] "14"
[2] "35"
[3] "34"
[4] "38"
[5] "16"
name = (Array)#10
[0] "Advanced Contract Drafting elearning"
[1] "Advanced Contract Management Planning"
[2] "Advanced Law, Ethics, and Best Practices in Procurement Management"
[3] "Advanced Negotiation Skills"
[4] "Case Study Presentations and Graduation"
[5] "RFP Preparation"
4 = (Object)#11
id = (Array)#12
[0] "25"
[1] "23"
[2] "22"
[3] "26"
[4] "27"
[5] "24"
[6] "19"
name = (Array)#13
[0] "Advanced Procurement Strategies: Achieving Success in Ministry
Contracts"
[1] "Planning it Right: How To Avoid Disasters, Scandals and Litigation"
[2] "Procurement and Contract Management Planning Essentials for Executives"
[3] "Sharing Risk and Reward Between Government and the Private Sector"
[4] "The New Approach to Performance Management"
[5] "The Role of the Executive Ethics, Liability, and Standards of
Conduct"
[6] "The Role of the Senior Manager Ethics, Liability, and Standards
of Conduct"
Any help would be greatly appreciated.
More information about the swx
mailing list