Animation Window
February 26th, 2009 Posted in AIR, ActionScript 3.0
Well, this is another AIR project with Native Window. In this AIR project you will see how to animate a Native Window, and the Tween Method if you do not already know, but I think you are knowing this method. I used the simple Tween Method not the TweenMax or another. But if you like the TweenMax you can use it. The code is not very hard to understand. Put if you don’t understand go to the previous post and look there or leave me a comment, and I will answer you in the shortest time.
OK…enough talking, this is the code and the explanations:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 | package { // ---------------------------------------- // Imports // ---------------------------------------- import flash.display.MovieClip; import flash.display.NativeWindow; import flash.display.NativeWindowType; import flash.display.NativeWindowInitOptions; import flash.display.NativeWindowSystemChrome; import flash.display.StageDisplayState; import flash.display.StageAlign; import flash.display.StageScaleMode; import flash.text.TextField; import flash.events.MouseEvent; import flash.system.Capabilities; import fl.transitions.Tween; import fl.transitions.easing.Bounce; import fl.transitions.TweenEvent; public class AnimationWindow extends MovieClip { // ---------------------------------------- // Variables // ---------------------------------------- //Same public variables which will help us in the following private methodes public var mainWindow:NativeWindow; public var newWinInit:NativeWindowInitOptions = new NativeWindowInitOptions (); public var newWin:NativeWindow; public var labelText:TextField = new TextField(); public var createIt:MovieClip = new MovieClip(); public var moveWin:MovieClip = new MovieClip(); public var thisTime:Date = new Date(); // ---------------------------------------- // CONSTRUCTOR // --------------------------------------- //Now set the constructor of your ActionScript class public function AnimationWindow ():void { //At this point, you must remember that the new window you will create has to keep the //content unaltered. To do this, you have assigned the StageScaleMode.NO_SCALE value to scaleMode //property and the StageAlign.TOP_LEFT value to the align properties mainWindow = stage.nativeWindow; stage.scaleMode = StageScaleMode.NO_SCALE; stage.align = StageAlign.TOP_LEFT; //The content for the New Native Window labelText.htmlText = String("Today is <b>"+thisTime.getDate()+"/"+(thisTime.getMonth()+1)+"/"+thisTime.getFullYear()+"</br>"); addChild(createIt); addChild(moveWin); designButton(createIt, 100,30,0,0); designButton(moveWin, 100,30,0,100); createIt.addEventListener(MouseEvent.CLICK,createWindow); moveWin.addEventListener(MouseEvent.CLICK, moveWindow); } // ---------------------------------------- // Private Methods // ---------------------------------------- private function createWindow(e:MouseEvent):void { //Next are the methods that create the new window: newWinInit.systemChrome = NativeWindowSystemChrome.STANDARD; newWinInit.type = NativeWindowType.UTILITY; newWin = new NativeWindow(newWinInit); newWin.activate() newWin.stage.addChild(labelText); newWin.title = "Calendar|Window"; newWin.x = 0; newWin.width = 300; newWin.height = 100; newWin.stage.addEventListener(MouseEvent.CLICK,closeMe); } function closeMe(event:MouseEvent):void { //The closeMe method allows you to close both of the windows once the user clicks the utility window. newWin.close(); mainWindow.close(); } private function moveWindow(event:MouseEvent) { //The next method, allows you to move the window on the user’s desktop. var moveIt:Tween = new Tween(newWin, "x", Bounce.easeOut,newWin.x,((Capabilities.screenResolutionX) - newWin.width), 5, true); moveIt.addEventListener(TweenEvent.MOTION_FINISH,backIt); function backIt(event:TweenEvent) { moveIt.yoyo(); } } private function designButton(obj:MovieClip, objWidth:Number, objHeight:Number, objX:Number, objY:Number) { //Set the position to the buttons with(obj.graphics) { beginFill(0xAACCDD, 1); drawRect(objX,objY,objWidth, objHeight); endFill() } obj.buttonMode = true; } } } |
There is the file with .air extension: Animation Window

January 19th, 2010 at 7:16 PM
finally, I could find this article again. You have few useful tips for my school project. Now, I won’t forget to bookmark it.
May 18th, 2010 at 7:11 PM
Very habitually I visit this blog. It very much is satisfying to me. Thanks the author