【发布时间】:2010-01-15 00:23:16
【问题描述】:
我正在开发多文件上传器,并希望根据我的数据网格中选定的 questionID(即目录名称)设置上传目录。
代码可以在这里找到http://pastie.org/784185
类似这样的:
我已经设置了 myQuestionID(要上传到的目录),所以它是可绑定的(第 136-137 行):
[Bindable] public var myQuestionID:int;
在我的数据网格中,我使用了一个更改处理程序(第 539 行):
change="setQuestionID();"
我们在 setQuestionID 函数中设置变量(第 400-407 行):
[Bindable (event="questionChange")]
private function setQuestionID():void
{
myQuestionID = questionsDG.selectedItem.QuestionID;
dispatchEvent(new Event("questionChange"));
}
然后尝试在我的上传脚本中使用它(第 448-475 行):
// initUploader is called when account info loads
public function getSessionInfoResult(event:ResultEvent):void{
// Get jsessionid & questionid (final directory) for CF uploader
myToken = roAccount.getSessionToken.lastResult;
// BUG: myQuestion is null in actionscript, but okay in form.
var postVariables:URLVariables = new URLVariables();
postVariables.jsessionid = myToken;
postVariables.questionid = myQuestionID;
multiFileUpload = new MultiFileUpload(
filesDG,
browseBTN,
clearButton,
delButton,
upload_btn,
progressbar,
uploadDestination,
postVariables,
350000,
filesToFilter
);
multiFileUpload.addEventListener(Event.COMPLETE,uploadsfinished);
}
我可以在我的 MXML 中看到绑定的值(第 639 行):
<mx:Label text="{myDirectory}"/>
当我单击数据网格中的一行时它会更新。但是,如果我尝试在任何操作脚本中访问此 myQuestionID 值,它将显示为 null (0)。我知道我的上传器正在工作,因为我可以将 myDirectory 硬编码到一个已知目录,它会上传正常。
我真的很难过。
【问题讨论】:
-
请提供更多代码
-
这一行出现在哪个函数
myDirectory = myDataGrid.selectedItem.someID;?您如何/何时调用该函数? -
你能把文件贴在馅饼或要点上吗?看起来它应该可以工作,但可能是范围问题或您认为不会影响它的事情。
标签: apache-flex data-binding binding