<?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" applicationComplete="appComplete()"> <fx:Script> <![CDATA[ import twitter.api.*; import twitter.api.data.*; import twitter.api.events.*; import flash.utils.Dictionary; import mx.collections.ArrayCollection; [Bindable] private var userArray:ArrayCollection; private var prevY:Number; private function appComplete():void { if (Multitouch.supportsTouchEvents) { Multitouch.inputMode = MultitouchInputMode.TOUCH_POINT; stage.addEventListener(TouchEvent.TOUCH_BEGIN, onTouchBegin); stage.addEventListener(TouchEvent.TOUCH_MOVE, onTouchMove); stage.addEventListener(TouchEvent.TOUCH_END, onTouchEnd); } var twit:Twitter = new Twitter(); twit.addEventListener(TwitterEvent.ON_FRIENDS_RESULT,onFriendsLoad); twit.loadFriends("jlward4th", true); } private function onFriendsLoad(event:TwitterEvent):void { userArray = new ArrayCollection(event.data as Array); } private function onTouchBegin(event:TouchEvent):void { prevY = event.stageY; } private function onTouchMove(event:TouchEvent):void { var deltaY:Number = Math.round((prevY - event.stageY)); var scrollUp:Boolean = (deltaY < 0); var desiredScrollPosition:Number = dg.verticalScrollPosition + deltaY; if (desiredScrollPosition < 0) { desiredScrollPosition = 0; } else if (desiredScrollPosition > dg.contentHeight) { desiredScrollPosition = dg.contentHeight; } dg.verticalScrollPosition = desiredScrollPosition; prevY = event.stageY; } private function onTouchEnd(event:TouchEvent):void { } ]]> </fx:Script> <s:Scroller width="100%" height="100%" minViewportInset="10"> <s:DataGroup id="dg" dataProvider="{userArray}"> <s:layout> <s:VerticalLayout gap="0"/> </s:layout> <s:itemRenderer> <fx:Component> <s:ItemRenderer autoDrawBackground="false" width="100%" height="70"> <s:layout> <s:BasicLayout/> </s:layout> <mx:Image source="{data.profileImageUrl}" width="50" height="50" top="0"/> <s:RichText content="{data.status.text}" width="100%" fontSize="20" top="0" left="60" right="10"/> <s:Line left="0" right="10" bottom="10"> <s:stroke> <s:SolidColorStroke color="0x333333" weight="1" caps="square"/> </s:stroke> </s:Line> </s:ItemRenderer> </fx:Component> </s:itemRenderer> </s:DataGroup> </s:Scroller> </s:Application>