문제

I am developing a panel in Photoshop with Flex and Extendscript. I am pretty close to getting this to work, but with my Flex skills I am having a little issue with the Array I am pulling in from the jsx file. The array is displayed fine in the alert box, but somewhere between my split and creating new collection something is wrong. Thanks for any help on this.

Here is my Flex

protected function loadData():void {
    var grabFolderNames:SyncRequestResult = CSXSInterface.instance.evalScript("labNames");
    var list:String = grabFolderNames.data;
    var array:Array = list.split(",");
    var arrayCollection:ArrayCollection = new ArrayCollection();
    arrayCollection.source = array;
    labFolderList.dataProvider = arrayCollection;
}

and here is the jsx

function labNames() {
  var labs = ["Red", "Green", "Blue", "Purple", "Yellow"];
    alert("This function is firing" + labs);
}
도움이 되었습니까?

해결책

1) You should modify your labNames() method to return the array:

function labNames() {
    var labs = ["Red", "Green", "Blue", "Purple", "Yellow"];
    return labs;
}

2) Make sure in the HTML Wrapper for your flex object you have allowScriptAccess="always" (or allowScriptAccess="sameDomain") in order to enable javascript/Flex communication.

3) If it still doesn't work, replace

var grabFolderNames:SyncRequestResult = CSXSInterface.instance.evalScript("labNames");

by:

var obj:* = CSXSInterface.instance.evalScript("labNames");

then put a breakpoint on that line and see if "obj" is populated by some data and report results here.

Hope that helps.

다른 팁

I am not familiar with the CSXSInterface but, since labNames() just displays the string in an alert, and does not return it as a String, grabFolderNames.data may not contain what you expect it to contain. Why don't you check its value with a debugger?

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top