Simple Flex Fade in Fade out Banner Example
CODE:
CODE:
1: <?xml version="1.0" encoding="utf-8"?>
2: <mx:Application verticalScrollPolicy="off" verticalGap="0" horizontalGap="0" horizontalScrollPolicy="off" xmlns:mx="http://www.adobe.com/2006/mxml" layout="vertical" paddingTop="0" paddingLeft="0" paddingRight="0" paddingBottom="0" verticalAlign="middle" backgroundColor="white" creationComplete="{init();}">
3: <mx:Script>
4: <![CDATA[
5: import mx.effects.WipeLeft;
6: import mx.events.TweenEvent;
7: import mx.controls.Alert;
8: import mx.events.EffectEvent;
9: import mx.effects.Fade;
10: import mx.effects.Pause;
11: import mx.effects.Sequence;
12: import mx.effects.SetPropertyAction;
13: import mx.effects.WipeRight;
14: private var fader:Sequence;
15: private var wiper:Sequence;
16: public var wipeIn:WipeRight;
17: public var wipeOut:WipeLeft;
18: public var pause:Pause;
19: public var alphaOn:SetPropertyAction;
20: public var alphaOff:SetPropertyAction;
21: private var counter:int=1;
22: [Bindable]
23: private var imagesArr:Array =
24: [
25: "image1.jpg",
26: "image3.jpg",
27: "image4.jpg"
28: ];
29: public function init():void{
30: // for preloading image
31: var img:Image = new Image();
32: for(var i:int=0;i<imagesArr.length;i++){
33: img.source = "images/"+imagesArr[i];
34: }
35: start_wipe();
36: }
37: private function start_wipe():void {
38: wipeIn = new WipeRight();
39: wipeIn.showTarget = true;
40: wipeIn.duration = 3000;
41: wipeOut = new WipeLeft();
42: wipeOut.showTarget = false;
43: wipeOut.duration = 2000;
44: pause = new Pause();
45: pause.duration = 5000;
46: alphaOn = new SetPropertyAction();
47: alphaOn.name = "alpha";
48: alphaOn.value = 1.0;
49: alphaOff= new SetPropertyAction();
50: alphaOff.name = "alpha";
51: alphaOff.value = 0.0;
52: wiper = new Sequence();
53: wiper.addChild(alphaOn);
54: wiper.addChild(wipeIn);
55: wiper.addChild(pause);
56: wiper.addChild(wipeOut);
57: wiper.addChild(alphaOff);
58: wiper.stop();
59: wiper.play([imagePlaceHolder]);
60: wiper.addEventListener(EffectEvent.EFFECT_END,wiperEffectEnd);
61: }
62: public function wiperEffectEnd(evt:EffectEvent):void{
63: var len:int=imagesArr.length;
64: if(len==counter) counter=0;
65: img.source= "images/"+imagesArr[counter];
66: counter++;
67: this.start_wipe();
68: }
69: ]]>
70: </mx:Script>
71: <mx:HBox horizontalGap="0" verticalGap="0" id="imagePlaceHolder" width="100%" height="100%" verticalScrollPolicy="off" horizontalScrollPolicy="off" backgroundColor="#E6E6E6" alpha="0.0" paddingTop="0" paddingLeft="0" paddingRight="0" paddingBottom="0">
72: <mx:Image source="images/image1.jpg" id="img" />
73: </mx:HBox>
74: </mx:Application>
Comments
Post a Comment