I read the Chapter2 that is written about EventListener.
I started the Chapter3 that is written about animation by scripting.
Archive for the ‘Dialy’ Category
[Diary] Today’s my reading result.
Tuesday, May 11th, 2010ActionScript 3.0 for Adobe Flash CS4 Professional Classroom in a Book (Kindle Edition)
Sunday, May 9th, 2010Yesterday I bought a book.
The book is ActionScript 3.0 for Adobe Flash CS4 Professional Classroom in a Book.
I have never read a English book from start to end.
But I can program ActionScript3.
I think if I understand the content that I read the book complete.
Now I am learning EventListener.
Test test.
Friday, May 7th, 2010SWFObject Embed Test.
sintax highlighter test
package { import caurina.transitions.Tweener; import flash.display.Bitmap; import flash.display.BitmapData; import flash.display.Graphics; import flash.display.MovieClip; import flash.display.Sprite; import flash.events.Event; import flash.events.MouseEvent; import flash.geom.Matrix3D; import flash.text.TextField; import flash.utils.getDefinitionByName; public class Main extends MovieClip { public var lego:BitmapData; public var panels:Array; public var isEffecting:Boolean = false; public var wrapper:Sprite; public var startTxt:TextField; public var isInit:Boolean = true; public function Main() { this.addEventListener(Event.ADDED_TO_STAGE, init); } public function init(e:Event):void { var LEGO:Class = getDefinitionByName("LEGO") as Class; lego = new LEGO(0, 0); createPanels(); stage.addEventListener(MouseEvent.MOUSE_DOWN, mouseDownHD); } private function mouseDownHD(e:MouseEvent):void { if (isInit) { startTxt.visible = false; isInit = false; } if (isEffecting) { return; } isEffecting = true; var i:int; var panel:Sprite; for (i = 0; i < panels.length; i++) { panel = panels[i]; Tweener.addTween(panel, { x:Math.random() * 600 - 300, y:Math.random() * 600 - 300, z:Math.random() * 600 - 300, rotationX:Math.random() * 720 - 360, rotationY:Math.random() * 720 - 360, rotationZ:Math.random() * 720 - 360, time:2, transition:"easeoutquart" }); var obj:Object = { x:panel.x, y:panel.y, z:0, rotationX:0, rotationY:0, rotationZ:0, time:2, transition:"easeinquart", delay:2 } if (i == panels.length - 1) { obj.onComplete = effectCompleteHD } Tweener.addTween(panel, obj); } addEventListener(Event.ENTER_FRAME, update); } private function effectCompleteHD():void { isEffecting = false; removeEventListener(Event.ENTER_FRAME, update); } private function createPanels():void { var offsetX:Number = (stage.stageWidth - 20 * col) / 2; var offsetY:Number = (stage.stageHeight - 20 * row) / 2; wrapper = new Sprite(); wrapper.z = 0; wrapper.x = offsetX; wrapper.y = offsetY; addChild(wrapper); panels = new Array(); var panel:Sprite; var col:int = lego.width; var row:int = lego.height; var i:int, j:int; var color:int; for (i = 0; i < row; i++) { for (j = 0; j < col; j++ ) { color = lego.getPixel(j , i); panel = createPanel(color); panel.x = j * 20 - col / 2 * 20; panel.y = i * 20 - row / 2 * 20; wrapper.addChild(panel); panels.push(panel); } } } private function createPanel(color:int):Sprite { var sp:Sprite = new Sprite(); var g:Graphics = sp.graphics; g.beginFill(color, 1); g.drawRect( -10, -10, 20, 20); g.endFill(); g.lineStyle(1, 0x4E4E4E, 0.5); g.moveTo( -10, -10); g.lineTo( -10, 10); g.lineTo( 10, 10); g.lineTo(10, -10); g.lineTo( -10, -10); return sp; } public function update(e:Event):void { var hw:Number = stage.stageWidth / 2; var hh:Number = stage.stageHeight / 2; var offsetX:Number = (hw - mouseX) / hw; var offsetY:Number = -(hh - mouseY) / hh; wrapper.rotationY += (offsetX * 180 - wrapper.rotationY) * 0.1; wrapper.rotationX += (offsetY * 180 - wrapper.rotationX) * 0.1; var i:int; var len:int = panels.length; var panel:Sprite; for (i = 0; i < len; i++) { panel = panels[i]; var mt3:Matrix3D = panel.transform.getRelativeMatrix3D(wrapper); panel.z = mt3.position.z; if (panel.z > 0) { panel.alpha = (300 - panel.z) / 300; } } panels.sortOn("z", Array.DESCENDING | Array.NUMERIC); for (i = 0; i < len; i++) { wrapper.setChildIndex(panels[i], i); } } } }