【发布时间】:2012-02-10 04:21:16
【问题描述】:
我在使用 Adobe Flash Builder 在 flex 4.6 中使用 SplitViewNavigator 组件时遇到问题。
[更新]* * *
我正在为黑莓 playbook 平板电脑构建一个 reddit 应用程序,并且正在使用 reddit 的 API。我有三个 mxml 视图:RedditReaderHomeView.mxml、redditFeed.mxml 和 subredditList.mxml。在 RedditReaderHomeView.mxml 我有一个 splitViewNavigator。在我的 SplitViewNavigator 的左侧是 subredditList.mxml,右侧是 redditFeed.mxml。在初始化时,redditFeed.mxml 拉入 XML 数据以使用 reddit 条目填充其列表,并且 subredditList.mxml 拉入 XML 数据,该 XML 数据在其列表中填充要显示的 subreddits(类别)。当用户单击左侧的 subreddit 条目时,右侧的 redditFeed.mxml 应该更新,以便它提取的数据是左侧选择的 subreddit 类别的条目。换句话说,经典的主/详细导航。左侧的类别,在右侧打开该类别的条目。
好吧,我有一个函数可以将所选 subreddit 的 url 传递给 redditFeed.mxml。
subredditList.mxml - 这里选择了一个 subreddit 并将其 url 发送到 redditFeed.mxml 中的函数
public function list_clickHandler(event:IndexChangeEvent):void {
var RSSItem:Object = redditList.dataProvider.getItemAt(event.newIndex);
var thisItem:Item = RSSItem as Item;
rlink = thisItem.link;
var moddedLink:String = rlink.slice(1, int.MAX_VALUE)
var pushSub:redditFeed = new redditFeed();
pushSub.myList_creationCompleteHandler(moddedLink);
}
redditFeed.mxml - url 用于从特定 subreddit 中获取数据...
public function myList_creationCompleteHandler(url:String):void
{
getRedditFeedResult.token = redditFeedGrabber.getRedditFeed(url);
}
...尽管此数据似乎从未显示在火花列表组件中,即使我可以看到通过网络监视器进行的调用。 我花了好几个小时试图解决这个问题。而且我相信这与视图“活动”与“停用”有关,因为当我尝试从 redditFeed.mxml 中发出相同的调用时,调用通过并且列表中的数据更新。我想这可能是因为该操作是在包含显示数据的列表的同一视图中执行的。因此,在这种情况下,当在该视图中执行操作时,它将是“活动的”。
感谢任何人提供的任何帮助。另外,请不要犹豫,向我要求澄清/更多详细信息。我真的很想解决这个问题。 谢谢!
RedditReaderHomeView.mxml - 这是您请求的代码。让我知道您是否需要更多/其他东西。
<?xml version="1.0" encoding="utf-8"?>
<s:View xmlns:fx="http://ns.adobe.com/mxml/2009"
xmlns:s="library://ns.adobe.com/flex/spark"
actionBarVisible="false" tabBarVisible="true" title="Reddit Reader by Domisy" creationPolicy="all"
actionBarVisible.landscape="true">
<fx:Script>
<![CDATA[
import com.adobe.fiber.core.model_public;
import mx.events.FlexEvent;
import views.redditFeed;
public var defUrl:String = new String("");
public function refreshRSS(event:Event):void
{
//***UPDATED CODE****
var refreshFunction:Object = redditFeedNav.getElementAt(0);
refreshFunction.refreshList();
//var refreshFunction:redditFeed = new redditFeed();
//refreshFunction.refreshList();
}
]]>
</fx:Script>
<fx:Declarations>
</fx:Declarations>
<s:states>
<s:State name="portrait"/>
<s:State name="landscape"/>
</s:states>
<s:actionContent>
<s:Button includeIn="landscape" click="navigator.pushView(profileView)"
icon="@Embed('assets/images/profileIcon.png')"/>
</s:actionContent>
<s:SplitViewNavigator width="100%" height="100%" id="splitViewNavigator" autoHideFirstViewNavigator="true">
<s:ViewNavigator id="redditListNav" firstView="views.subredditList" width="300" height="100%"/>
<s:ViewNavigator id="redditFeedNav" firstView="views.redditFeed" width="100%" height="100%">
<s:actionContent.landscape>
<s:Button id="refreshButtonlLandscape" icon="@Embed('assets/refresh160.png')" click="refreshRSS(event)" />
</s:actionContent.landscape>
<s:actionContent.portrait>
<s:Button id="refreshButton" icon="@Embed('assets/refresh160.png')" click="refreshRSS(event)" />
<s:Button id="navigatorButton" label="Search" click="splitViewNavigator.showFirstViewNavigatorInPopUp(navigatorButton)" />
</s:actionContent.portrait>
</s:ViewNavigator>
</s:SplitViewNavigator>
</s:View>
【问题讨论】:
标签: apache-flex data-binding view mxml