出现未知错误在 Flex Builder 4.5.1 移动版中
我最近学习了如何在 Flash Builder 中使用 API。所以我做了这个(注意:它没有错误,并且可以在普通的 Flex 应用程序中工作:
<?xml version="1.0" encoding="utf-8"?>
<s:Application xmlns:fx="http://ns.adobe.com/mxml/2009"
xmlns:s="library://ns.adobe.com/flex/spark"
xmlns:mx="library://ns.adobe.com/flex/mx"
width="957" minWidth="800" minHeight="600"
creationComplete="initApp(event)">
<fx:Declarations>
<!-- Place non-visual elements (e.g., services, value objects) here -->
<s:HTTPService id="myRequest"
resultFormat="e4x"
url="{api_request}"
result="getMyPhotos(event)">
</s:HTTPService>
</fx:Declarations>
<fx:Script>
<![CDATA[
import mx.collections.XMLListCollection;
import mx.events.FlexEvent;
import mx.rpc.events.ResultEvent;
[Bindable]
public var api_request:String;
protected function initApp(event:FlexEvent):void
{
btnClear.addEventListener(MouseEvent.CLICK, leegAlleVelden);
btnSearch.addEventListener(MouseEvent.CLICK, zoekOpFlickr);
flickrFotoCollection.addEventListener(MouseEvent.CLICK, haalFoto);
}
protected function zoekOpFlickr(event:MouseEvent):void
{
var api_URL:String = 'http://api.flickr.com/services/rest/';
var api_method:String = 'flickr.photos.search';
var api_key:String = '290845e3c32e4e10a9e4b09fd993ddb9';
var api_tags:String = txtSearchString.text;
api_request = api_URL + '?method=' + api_method +
'&api_key=' + api_key + '&tags=' + api_tags;
myRequest.send(); // hier maak je connectie met flickr
}
//http://api.flickr.com/services/rest/?method=flickr.photos.search&api_key=290845e3c32e4e10a9e4b09fd993ddb9&tags=cat&format=rest&api_sig=93e43cc21b7209d2e59af67736d27eb3
protected function leegAlleVelden(event:MouseEvent):void
{
txtSearchString.text="";
}
protected function getMyPhotos(event:ResultEvent):void
{
//photos allemaal ingelezen
flickrFotoCollection.dataProvider = new XMLListCollection(myRequest.lastResult.photos.photo);
}
public function haalFoto(selectedFoto:Object):String {
// http://farm{farm-id}.static.flickr.com/{server-id}/{id}_{secret}_[mstb].jpg
var farm_id:String = selectedFoto.@farm;
var server_id:String = selectedFoto.@server;
var id:String = selectedFoto.@id;
var secret:String = selectedFoto.@secret;
var size:String = 't';
var api_selectedPhotoURL:String = "http://farm"+farm_id+".static.flickr.com/"+server_id+
"/"+id+"_"+secret+"_"+size+".jpg";
return api_selectedPhotoURL;
}
public function toonFoto(event:MouseEvent):void
{
}
]]>
</fx:Script>
<s:BorderContainer x="0" y="21" width="800" height="100%" backgroundColor="#000000">
<s:HGroup x="30" y="14">
<s:TextInput x="0" y="23" width="267" id="txtSearchString"/>
<s:Button x="289" y="24" label="Search" id="btnSearch" click="zoekOpFlickr(event);"/>
<s:Button x="394" y="24" label="Clear" id="btnClear" click="leegAlleVelden(event);"/>
</s:HGroup>
<s:HGroup x="30" y="54" width="742" height="500">
<mx:Tile width="399" height="500">
<mx:Repeater id="flickrFotoCollection" dataProvider="{myRequest.lastResult.photos.photo}">
<s:Image id="fotoKlein"
source="{haalFoto(flickrFotoCollection.currentItem)}"
click="toonFoto(event);"
width="80" height="80"
scaleMode="stretch"/>
</mx:Repeater>
</mx:Tile>
<s:Image id="fotoGroot" width="336" height="500"/>
</s:HGroup>
</s:BorderContainer>
</s:Application>
接下来,我想看看是否可以让它在 4.5.1 移动应用程序中工作。除了第 87 行显示“无法解析
...”。因此,由于某种原因,它无法识别
标记?
我试过寻找此问题的原因,但没有找到它
是否在正常应用程序中工作但在移动应用程序中不起作用的原因?
I recently learned how to work with API's in Flash Builder. So I made this (note: it has no errors and it works in a normal Flex application:
<?xml version="1.0" encoding="utf-8"?>
<s:Application xmlns:fx="http://ns.adobe.com/mxml/2009"
xmlns:s="library://ns.adobe.com/flex/spark"
xmlns:mx="library://ns.adobe.com/flex/mx"
width="957" minWidth="800" minHeight="600"
creationComplete="initApp(event)">
<fx:Declarations>
<!-- Place non-visual elements (e.g., services, value objects) here -->
<s:HTTPService id="myRequest"
resultFormat="e4x"
url="{api_request}"
result="getMyPhotos(event)">
</s:HTTPService>
</fx:Declarations>
<fx:Script>
<![CDATA[
import mx.collections.XMLListCollection;
import mx.events.FlexEvent;
import mx.rpc.events.ResultEvent;
[Bindable]
public var api_request:String;
protected function initApp(event:FlexEvent):void
{
btnClear.addEventListener(MouseEvent.CLICK, leegAlleVelden);
btnSearch.addEventListener(MouseEvent.CLICK, zoekOpFlickr);
flickrFotoCollection.addEventListener(MouseEvent.CLICK, haalFoto);
}
protected function zoekOpFlickr(event:MouseEvent):void
{
var api_URL:String = 'http://api.flickr.com/services/rest/';
var api_method:String = 'flickr.photos.search';
var api_key:String = '290845e3c32e4e10a9e4b09fd993ddb9';
var api_tags:String = txtSearchString.text;
api_request = api_URL + '?method=' + api_method +
'&api_key=' + api_key + '&tags=' + api_tags;
myRequest.send(); // hier maak je connectie met flickr
}
//http://api.flickr.com/services/rest/?method=flickr.photos.search&api_key=290845e3c32e4e10a9e4b09fd993ddb9&tags=cat&format=rest&api_sig=93e43cc21b7209d2e59af67736d27eb3
protected function leegAlleVelden(event:MouseEvent):void
{
txtSearchString.text="";
}
protected function getMyPhotos(event:ResultEvent):void
{
//photos allemaal ingelezen
flickrFotoCollection.dataProvider = new XMLListCollection(myRequest.lastResult.photos.photo);
}
public function haalFoto(selectedFoto:Object):String {
// http://farm{farm-id}.static.flickr.com/{server-id}/{id}_{secret}_[mstb].jpg
var farm_id:String = selectedFoto.@farm;
var server_id:String = selectedFoto.@server;
var id:String = selectedFoto.@id;
var secret:String = selectedFoto.@secret;
var size:String = 't';
var api_selectedPhotoURL:String = "http://farm"+farm_id+".static.flickr.com/"+server_id+
"/"+id+"_"+secret+"_"+size+".jpg";
return api_selectedPhotoURL;
}
public function toonFoto(event:MouseEvent):void
{
}
]]>
</fx:Script>
<s:BorderContainer x="0" y="21" width="800" height="100%" backgroundColor="#000000">
<s:HGroup x="30" y="14">
<s:TextInput x="0" y="23" width="267" id="txtSearchString"/>
<s:Button x="289" y="24" label="Search" id="btnSearch" click="zoekOpFlickr(event);"/>
<s:Button x="394" y="24" label="Clear" id="btnClear" click="leegAlleVelden(event);"/>
</s:HGroup>
<s:HGroup x="30" y="54" width="742" height="500">
<mx:Tile width="399" height="500">
<mx:Repeater id="flickrFotoCollection" dataProvider="{myRequest.lastResult.photos.photo}">
<s:Image id="fotoKlein"
source="{haalFoto(flickrFotoCollection.currentItem)}"
click="toonFoto(event);"
width="80" height="80"
scaleMode="stretch"/>
</mx:Repeater>
</mx:Tile>
<s:Image id="fotoGroot" width="336" height="500"/>
</s:HGroup>
</s:BorderContainer>
</s:Application>
Next, I wanted to see if I could get it to work in a 4.5.1 mobile application. I didn't get any errors except for a "could not resolve <mx:Repeater>
..." At line 87. So for some reason it doesn't recognize the <mx:Repeater>
tag?
I tried to find the cause of this problem, but didn't find it.
Is there a reason why it works in a normal application, but not in a mobile application?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
移动项目不支持 MX 组件。为了在 Flash Builder 移动项目中编译该代码,您必须手动将包含 MX 组件的 SWC 添加到库路径中。不过,要做好表现不佳的准备。
The MX Components are not supported in a Mobile Project. For that code to compile in a Flash Builder mobile project you will have to manually add the SWC with MX components to the library path. Be prepared for poor performance, though.