Flex 3:HTTPService 不适用于一个文件...有人看到代码有什么问题吗?
因此,我对三个不同的 XML 文件进行了三个 HTTPService 调用:
<mx:HTTPService id="projectsHttp" url="projects.xml" resultFormat="e4x" makeObjectsBindable="true" result="countProjects(event)" />
<mx:HTTPService id="studentsHttp" url="students.xml" resultFormat="e4x" makeObjectsBindable="true" result="createStudentsCollection(event)" />
<mx:HTTPService id="dprepHttp" url="directorsPrep.xml" resultFormat="e4x" makeObjectsBindable="true" result="createPhase(event)" />
前两个工作很好......但最后一个不起作用。出于测试目的,createPhase 函数如下所示:
public function createPhase(e:ResultEvent):void
{
Alert.show("Testing");
}
另外,directorsPrep.xml 文件如下所示:
<?xml version="1.0" encoding="utf-8"?>
<directorspreps>
<directorsprep>
<prepid>1</prepid>
<title>dir. prep. 1</title>
<workingtitle>dp1 WT</workingtitle>
<startdate>7/7/2011</startdate>
<numdays>2</numdays>
<positions>
<role>1D</role>
<role>2D</role>
<role>1C</role>
</positions>
</directorsprep>
<directorsprep>
<prepid>2</prepid>
<title>dir. prep. 2</title>
<workingtitle>dp2 WT</workingtitle>
<startdate>7/10/2011</startdate>
<numdays>3</numdays>
<positions>
<role>1D</role>
<role>2D</role>
<role>1C</role>
<role>GE</role>
</positions>
</directorsprep>
</directorspreps>
有人看到任何会阻止directorsPrep.xml 文件不加载的内容吗?
编辑: 我是个白痴...没有执行 .send(); :( 抱歉浪费了时间
So, i've got three HTTPService calls for three different XML files:
<mx:HTTPService id="projectsHttp" url="projects.xml" resultFormat="e4x" makeObjectsBindable="true" result="countProjects(event)" />
<mx:HTTPService id="studentsHttp" url="students.xml" resultFormat="e4x" makeObjectsBindable="true" result="createStudentsCollection(event)" />
<mx:HTTPService id="dprepHttp" url="directorsPrep.xml" resultFormat="e4x" makeObjectsBindable="true" result="createPhase(event)" />
The first two work great... but that last one just won't work. For testing purpose, the createPhase function looks like this:
public function createPhase(e:ResultEvent):void
{
Alert.show("Testing");
}
Also, the directorsPrep.xml file looks like this:
<?xml version="1.0" encoding="utf-8"?>
<directorspreps>
<directorsprep>
<prepid>1</prepid>
<title>dir. prep. 1</title>
<workingtitle>dp1 WT</workingtitle>
<startdate>7/7/2011</startdate>
<numdays>2</numdays>
<positions>
<role>1D</role>
<role>2D</role>
<role>1C</role>
</positions>
</directorsprep>
<directorsprep>
<prepid>2</prepid>
<title>dir. prep. 2</title>
<workingtitle>dp2 WT</workingtitle>
<startdate>7/10/2011</startdate>
<numdays>3</numdays>
<positions>
<role>1D</role>
<role>2D</role>
<role>1C</role>
<role>GE</role>
</positions>
</directorsprep>
</directorspreps>
Anybody see anything that would prevent the directorsPrep.xml file from not loading?
EDIT:
I'm a moron... Didn't do the .send(); :( Sorry for the time waster
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
很难肯定地说。我在 Flex3 中创建了一个小项目,其中包含您的 XML 文件,它对我来说工作得很好。您应该添加一个
fault
处理程序来了解失败的原因。如果您需要检查某些内容,请在该处理程序中放置一个断点。另外,请确保您正在调用send()
以便加载该 XML 文件。这是对我有用的示例(包括故障处理程序)。祝你好运!
It is tough to say for sure. I created a little project in Flex3 that includes your XML file and it worked fine for me. You should add a
fault
handler to know why it is failing. Put a breakpoint in that handler if you need to examine things. Also, make sure that you are callingsend()
in order for that XML file to get loaded. Here is an example of what was working for me (including the fault handler).Good luck!