-2
我有一个应用程序,目前由Facebook和显示此获取事件数据到一个列表阵列将数据添加到变量
<s:List id="eventsDataGrid" width="100%" height="100%" dataProvider="{facebookEvents}">
<s:itemRenderer>
<fx:Component>
<s:ItemRenderer>
<fx:Script>
<![CDATA[
import com.facebook.graph.utils.FacebookDataUtils;
private function time2DateStr(time:String):String {
return FacebookDataUtils.stringToDate(time).toLocaleString();
}
]]>
</fx:Script>
<s:HGroup paddingBottom="10" paddingTop="10">
<s:Image source="{data.pic}"/>
<s:VGroup width="100%">
<s:Label text="{data.name}" fontWeight="bold" width="100%"/>
<s:Label text="Where: {data.location}" id="locationtxt"/>
<s:Label text="When: {time2DateStr(data.start_time)}"/>
</s:VGroup>
</s:HGroup>
</s:ItemRenderer>
</fx:Component>
</s:itemRenderer>
</s:List>
我想添加一个按钮,就会在网页视图显示位置,但我可以没有得到应用程序使用数组中的data.location与谷歌地图一起使用它(我只是将data.location的详细信息添加到Google地图网址的末尾,然后Google Maps地图将使用地图来搜索地点 我可以获取按钮的工作,但它不会搜索的位置,它只是在Flash Builder中显示错误(我假设是我没有正确添加数据到字符串)或搜索“data.location” 他再是当前的代码将加载URL,但没有位置
<s:List id="eventsDataGrid" width="100%" height="100%" dataProvider="{facebookEvents}">
<s:itemRenderer>
<fx:Component>
<s:ItemRenderer>
<fx:Script>
<![CDATA[
import com.facebook.graph.utils.FacebookDataUtils;
var webView:StageWebView = new StageWebView
var mapURL:String = "http://maps.google.com/maps?f=d&hl=en&saddr="
private function time2DateStr(time:String):String {
return FacebookDataUtils.stringToDate(time).toLocaleString();
}
protected function getDirections_clickHandler(event:MouseEvent):void
{
webView.stage = this.stage;
webView.viewPort = new Rectangle(0, 100, stage.stageWidth, stage.stageHeight);
webView.loadURL(mapURL);
}
]]>
</fx:Script>
<s:HGroup paddingBottom="10" paddingTop="10">
<s:Image source="{data.pic}"/>
<s:VGroup width="100%">
<s:Label text="{data.name}" fontWeight="bold" width="100%"/>
<s:Label text="Where: {data.location}" id="locationtxt"/>
<s:Label text="When: {time2DateStr(data.start_time)}"/>
<s:Label text="Get Directions" click="getDirections_clickHandler(event)" id="getDirections"/>
</s:VGroup>
</s:HGroup>
</s:ItemRenderer>
</fx:Component>
</s:itemRenderer>
</s:List>
全码
<fx:Script>
<![CDATA[
import mx.collections.ArrayCollection;
[Bindable] private var facebookEvents:ArrayCollection;
import com.facebook.graph.FacebookMobile;
private function onLoad():void
{
if(FacebookMobile.getSession() != null) {
getEvents()
} else {
eventsDataGrid.visible=false
NotLogin.visible=true
}
}
private function getEvents():void {
var fql:String = "select name, location, pic, start_time from event where creator = 148839887036 and eid in (select eid from event_member where uid=148839887036)";
FacebookMobile.fqlQuery(fql, handleGetEventsResponse);
}
private function handleGetEventsResponse(events:Object, fail:Object):void {
if (events != null)
facebookEvents = new ArrayCollection(events as Array);
//else
//status = "Error";
}
]]>
<s:List id="eventsDataGrid" width="100%" height="100%" dataProvider="{facebookEvents}">
<s:itemRenderer>
<fx:Component>
<s:ItemRenderer>
<fx:Script>
<![CDATA[
import com.facebook.graph.utils.FacebookDataUtils;
var webView:StageWebView = new StageWebView
var mapURL:String = "http://maps.google.com/maps?f=d&hl=en&saddr="
private function time2DateStr(time:String):String {
return FacebookDataUtils.stringToDate(time).toLocaleString();
}
protected function getDirections_clickHandler(event:MouseEvent):void
{
webView.stage = this.stage;
webView.viewPort = new Rectangle(0, 100, stage.stageWidth, stage.stageHeight);
webView.loadURL(mapURL);
}
]]>
</fx:Script>
<s:HGroup paddingBottom="10" paddingTop="10">
<s:Image source="{data.pic}"/>
<s:VGroup width="100%">
<s:Label text="{data.name}" fontWeight="bold" width="100%"/>
<s:Label text="Where: {data.location}" id="locationtxt"/>
<s:Label text="When: {time2DateStr(data.start_time)}"/>
<s:Label text="Get Directions" click="getDirections_clickHandler(event)" id="getDirections"/>
</s:VGroup>
</s:HGroup>
</s:ItemRenderer>
</fx:Component>
</s:itemRenderer>
</s:List>
我没有看到任何键入为数组的变量。你能更具体地确定你想要做什么以及哪里出错? –
为什么所有这些代码都在你的项目渲染器中?另外,如果StageWebView没有被添加到任何地方,那么您的StageWebView不能做太多... –
以下是页面的完整代码,该数组是在项目渲染器外部创建的(代码位于我的项目渲染器中,因为我一直尝试不同的事情来得到这个工作) – Moonie85