Created
October 22, 2010 22:12
-
-
Save davidortinau/641483 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package { | |
import reflex.containers.Application; | |
import reflex.behaviors.TouchScrollBehavior; | |
import reflex.components.Scroller; | |
import flash.display.Bitmap; | |
import flash.display.MovieClip; | |
/** | |
* @author David Ortinau <dave@davidortinau.com> | |
*/ | |
[SWF(backgroundColor="#FFFFFF", frameRate="31", width="1200", height="800")] | |
public class Demos extends Application { | |
[Embed(source="../bin/assets/images/ipad_case_01.jpg")] | |
private var imgCls : Class; | |
private var photo : MovieClip; | |
private var scroller : Scroller; | |
public function Demos() { | |
scroller = Scroller(this.addChild(new Scroller())); | |
scroller.width = 400; | |
scroller.height = 400; | |
scroller.x = 20; | |
photo = MovieClip(scroller.addChild(new MovieClip())); | |
photo.addChild(new imgCls() as Bitmap); | |
scroller.behaviors.addItem(new TouchScrollBehavior(photo)); | |
} | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?xml version="1.0" encoding="utf-8"?> | |
<rx:Application | |
xmlns:fx="http://ns.adobe.com/mxml/2009" | |
xmlns:rx="http://rx.reflex.io/2010" | |
xmlns:behaviors="reflex.behaviors.*" > | |
<rx:Scroller width="400" height="400"> | |
<rx:behaviors> | |
<behaviors:TouchScrollBehavior /> | |
</rx:behaviors> | |
<rx:BitmapImage source="http://farm3.static.flickr.com/2766/4474105201_af63f79a2d_b.jpg" /> | |
</rx:Scroller> | |
</rx:Application> |
A few things... The first is that when you use the standard Flash APIs addChild/removeChild it acts exactly like it does in Flash, and so Reflex doesn't touch it. It doesn't position it or add interactivity or anything like that. That API is preserved for you to take manual control. The Reflex version is to use the content property (ie. component.content.addItem(something)). This tells reflex to automatically do layout and positioning, add behaviors and whatever other "automatic" stuff we provide. This is consistent throughout all the components that can contain items. Also, when you add a behavior to the behaviors collection, it is automatically assigned the target (in this case the scroller). No other target should be assigned.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
The mxml version runs, the AS version doesn't. I'm just curious what the appropriate AS expression of the mxml should be.