Skip to content

Instantly share code, notes, and snippets.

@curi1119
Created March 23, 2012 17:37
Show Gist options
  • Save curi1119/2173087 to your computer and use it in GitHub Desktop.
Save curi1119/2173087 to your computer and use it in GitHub Desktop.
AS Sample slide(Flex4.6 with tweener)
<?xml version="1.0" encoding="utf-8"?>
<s:Group 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="180" height="400"
clipAndEnableScrolling="true" creationComplete="init()">
<fx:Declarations>
<!-- 非ビジュアルエレメント (サービス、値オブジェクトなど) をここに配置 -->
</fx:Declarations>
<fx:Script>
<![CDATA[
import spark.components.Image;
import caurina.transitions.Tweener;
[Embed(source="/assets/cat.jpg")]
[Bindable]
private var _cat:Class;
private var _center:Image = new Image();
private var _left:Image = new Image();
private var _right:Image = new Image();
public function init():void{
_left.source = _cat;
_right.source = _cat;
_center.source = _cat;
addElement(_center)
_center.x = 0;
_center.y = 200;
}
public function moveRight():void{
addElement(_left);
_left.x = -180;
_left.y = 200;
Tweener.addTween(_center, {x:(_center.x+180), time:0.2, transition:'linear', onComplete: function():void{
_center.x = 0;
removeElement(_left);
}});
Tweener.addTween(_left, {x:(_left.x+180), time:0.2, transition:'linear'});
}
public function moveLeft():void{
addElement(_right);
_right.x = 180;
_right.y = 200;
Tweener.addTween(_center, {x:(_center.x-180), time:0.2, transition:'linear', onComplete: function():void{
_center.x = 0;
removeElement(_right);
}});
Tweener.addTween(_right, {x:(_right.x-180), time:0.2, transition:'linear'});
}
]]>
</fx:Script>
<s:Button x="34" y="51" label="←" click="moveLeft()" />
<s:Button x="90" y="118" label="→" click="moveRight()" />
</s:Group>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment