Sbaw091117

1,553 views
1,474 views

Published on

0 Comments
0 Likes
Statistics
Notes
  • Be the first to comment

  • Be the first to like this

No Downloads
Views
Total views
1,553
On SlideShare
0
From Embeds
0
Number of Embeds
163
Actions
Shares
0
Downloads
7
Comments
0
Likes
0
Embeds 0
No embeds

No notes for slide
  • Sbaw091117

    1. 1. package { import flash.display.Sprite; import flash.display.StageAlign; import flash.display.StageScaleMode; import flash.events.MouseEvent; public class SwcTest extends Sprite { private var _test:SwcClassTest = new SwcClassTest; public function SwcTest() { // stage.align = StageAlign.TOP_LEFT; stage.scaleMode = StageScaleMode.NO_SCALE; // _test.x = stage.stageWidth/2; _test.y = stage.stageHeight/2; this.addChild(_test); // _test.circle.buttonMode = true; _test.rect.buttonMode = true; // _test.circle.addEventListener(MouseEvent.CLICK,clickCircleHandler); _test.rect.addEventListener(MouseEvent.CLICK, clickRectHandler); }
    2. 2. //Circle private function clickCircleHandler(event:MouseEvent):void { // _test.message.text = "Circle"; } //Rect private function clickRectHandler(event:MouseEvent):void { // _test.message.text = "Rect"; } } }
    3. 3. package { import fl.events.SliderEvent; import flash.display.Sprite; import flash.display.StageAlign; import flash.display.StageScaleMode; import flash.events.Event; [SWF(backgroundColor="#FFFFFF", frameRate="60")] public class GuiComponent extends Sprite { private var spin:Spin = new Spin(); private var ui:UserInterface = new UserInterface(); private var rotateSpeed:Number = 0; public function GuiComponent() { // stage.align = StageAlign.TOP_LEFT; stage.scaleMode = StageScaleMode.NO_SCALE; //Spin this.addChild(spin); spin.x = stage.stageWidth/2; spin.y = stage.stageHeight/2; this.addEventListener(Event.ENTER_FRAME, update);
    4. 4. //UserIntaface this.addChild(ui); ui.x = 20; ui.y = 20; // ui.speedSlider.minimum = 0; ui.speedSlider.maximum = 100; ui.speedSlider.liveDragging = true; ui.radiusSlider.minimum = 0; ui.radiusSlider.maximum = 100; ui.radiusSlider.value = 10; ui.radiusSlider.liveDragging =true; ui.alphaSlider.minimum = 0; ui.alphaSlider.maximum = 100; ui.alphaSlider.value = 100; ui.alphaSlider.liveDragging = true; //UserInterface ui.speedSlider.addEventListener (SliderEvent.CHANGE, speedSliderChangeHanlder); ui.radiusSlider.addEventListener (SliderEvent.CHANGE, radiusSliderChangeHanlder); ui.alphaSlider.addEventListener (SliderEvent.CHANGE, alphaSliderChangeHanlder); }
    5. 5. // // private function update(event:Event):void { spin.rotation += rotateSpeed; } //Speed private function speedSliderChangeHanlder(event:SliderEvent):void { rotateSpeed = ui.speedSlider.value; } //Radius private function radiusSliderChangeHanlder(event:SliderEvent):void { spin.scaleX = spin.scaleY = ui.radiusSlider.value / 10.0; } //Alpha private function alphaSliderChangeHanlder(event:SliderEvent):void { spin.alpha = ui.alphaSlider.value / 100; } } }
    6. 6. package { import flash.display.*; [SWF(backgroundColor="#000000", frameRate="30")] public class DrawParticle extends Sprite { public function DrawParticle() { stage.align = StageAlign.TOP_LEFT; stage.scaleMode = StageScaleMode.NO_SCALE; //200 for(var i:uint = 0; i < 200; i++){ // Circle var myParticle:Particle = new Particle(); addChild(myParticle); // } } } }
    7. 7. package { import flash.display.Sprite; import flash.events.Event; public class Particle extends Sprite { private var _speedX:Number; private var _speedY:Number; private var _scale:Number; public function Particle() { super(); _speedX = rand(-8,8); _speedY = rand(-8,8); _scale = rand(0.1, 1.0); var cp:CircleParticle = new CircleParticle; cp.scaleX = cp.scaleY = _scale; cp.cacheAsBitmap = true; this.addChild(cp); this.addEventListener(Event.ENTER_FRAME, update); this.addEventListener(Event.ADDED_TO_STAGE, addedHandler); } private function addedHandler(event:Event):void { x = Math.random() * stage.stageWidth; y = Math.random() * stage.stageHeight;
    8. 8. private function update(event:Event):void { limit(); x += _speedX; y += _speedY; } // private function limit():void { if(x < 0 || x > stage.stageWidth){ _speedX *= -1; } if(y < 0 || y > stage.stageHeight){ _speedY *= -1; } } // private function rand(min:Number, max:Number):Number { var randValue:Number = Math.random() * (max - min) + min; return randValue; } } }
    9. 9. • Tween • Tween • 2 • • Flash Tween • TweenMax • • • http://blog.greensock.com/tweenmaxas3/ • gs
    10. 10. • TweenMax • TweeMax import gs.TweenMax; import gs.easing.*; • Tween Tween TweenMax.to( , ,{ });
    11. 11. • • TweenMaxAS3_Basics.swf
    12. 12. package { import flash.display.*; [SWF(backgroundColor="#000000", frameRate="30")] public class TweenParticle extends Sprite { public function TweenParticle() { stage.align = StageAlign.TOP_LEFT; stage.scaleMode = StageScaleMode.NO_SCALE; //200 for(var i:uint = 0; i < 200; i++){ // Circle var myParticle:Particle = new Particle(); addChild(myParticle); // } } } }
    13. 13. package { import com.greensock.TweenMax; import com.greensock.easing.*; import flash.display.Sprite; import flash.events.Event; public class Particle extends Sprite { private var _speedX:Number; private var _speedY:Number; private var _scale:Number; public function Particle() { super(); _speedX = rand(-8,8); _speedY = rand(-8,8); _scale = rand(0.2, 1.0); var cp:CircleParticle = new CircleParticle; cp.scaleX = cp.scaleY = _scale; cp.cacheAsBitmap = true; this.addChild(cp); this.addEventListener(Event.ADDED_TO_STAGE, addedHandler); }
    14. 14. private function tweenMe():void { // var toX:Number = rand(0, stage.stageWidth); var toY:Number = rand(0, stage.stageHeight); //Tween TweenMax.to(this, rand(2,3), {x:toX, y:toY, ease:Sine.easeInOut, onComplete:tweenMe}); } private function addedHandler(event:Event):void { x = Math.random() * stage.stageWidth; y = Math.random() * stage.stageHeight; TweenMax.to(this, 0, {delay:rand(0,4),onComplete:tweenMe}); } private function update(event:Event):void { limit(); x += _speedX; y += _speedY; }
    15. 15. // private function limit():void { if(x < 0 || x > stage.stageWidth){ _speedX *= -1; } if(y < 0 || y > stage.stageHeight){ _speedY *= -1; } } // private function rand(min:Number, max:Number):Number { var randValue:Number = Math.random() * (max - min) + min; return randValue; } } }
    16. 16. package { import flash.display.*; import flash.events.Event; import flash.events.MouseEvent; [SWF(backgroundColor="#CCCCCC", frameRate="30")] public class Portfolio extends Sprite { private var _background:BackgroundImage = new BackgroundImage; private var _menu:Menu = new Menu; private var _top:Top; private var _bio:Biography; private var _works:Works; public function Portfolio() { stage.align = StageAlign.TOP_LEFT; stage.scaleMode = StageScaleMode.NO_SCALE; this.addEventListener(Event.ADDED_TO_STAGE, addedHandler); // this.addChild(_background); //Menu _menu.x = 20; _menu.y = 20; this.addChild(_menu);
    17. 17. //Menu _menu.menu1.buttonMode = true; _menu.menu2.buttonMode = true; _menu.menu3.buttonMode = true; _menu.menu1.gotoAndStop(1); _menu.menu2.gotoAndStop(1); _menu.menu3.gotoAndStop(1); // _menu.menu1.addEventListener(MouseEvent.ROLL_OVER,menuRollOverHandler); _menu.menu1.addEventListener(MouseEvent.ROLL_OUT,menuRollOutHandler); _menu.menu1.addEventListener(MouseEvent.CLICK, menu1ClickHandler); _menu.menu2.addEventListener(MouseEvent.ROLL_OVER,menuRollOverHandler); _menu.menu2.addEventListener(MouseEvent.ROLL_OUT,menuRollOutHandler); _menu.menu2.addEventListener(MouseEvent.CLICK, menu2ClickHandler); _menu.menu3.addEventListener(MouseEvent.ROLL_OVER,menuRollOverHandler); _menu.menu3.addEventListener(MouseEvent.ROLL_OUT,menuRollOutHandler); _menu.menu3.addEventListener(MouseEvent.CLICK, menu3ClickHandler); //Top _top = new Top(this); this.addChild(_top); } public function get menu():Menu { return _menu; }
    18. 18. private function addedHandler(event:Event):void { _background.width = stage.stageWidth; _background.height = stage.stageHeight; stage.addEventListener(Event.RESIZE, reseizeHandler); } private function reseizeHandler(event:Event):void { _background.width = stage.stageWidth; _background.height = stage.stageHeight; } private function menuRollOverHandler(event:MouseEvent):void { event.target.gotoAndStop(2); } private function menuRollOutHandler(event:MouseEvent):void { event.target.gotoAndStop(1); } private function menu1ClickHandler(event:MouseEvent):void { this.removeChildAt(2); //Top _top = new Top(this); this.addChild(_top); }
    19. 19. private function menu2ClickHandler(event:MouseEvent):void { this.removeChildAt(2); //Bio _bio = new Biography(this); this.addChild(_bio); } private function menu3ClickHandler(event:MouseEvent):void { this.removeChildAt(2); //Works _works = new Works(this); this.addChild(_works); } } }
    20. 20. package { import com.greensock.TweenMax; import com.greensock.easing.*; import flash.display.Sprite; import flash.events.Event; public class Top extends Sprite { private var _main:Portfolio; public function Top(main:Portfolio) { super(); _main = main; var _content:TopMc = new TopMc; this.alpha = 0; this.addChild(_content); this.addEventListener(Event.ADDED_TO_STAGE, addedHandler); } private function addedHandler(event:Event):void { this.x = 140; this.y = 100; TweenMax.to(this, 1, {y:20, alpha:1, delay:1, ease:Quint.easeOut}); } }
    21. 21. package { import com.greensock.TweenMax; import com.greensock.easing.*; import flash.display.Sprite; import flash.events.Event; public class Biography extends Sprite { private var _main:Portfolio; public function Biography(main:Portfolio) { super(); _main = main; var _content:BiographyMc = new BiographyMc; this.addChild(_content); this.addEventListener(Event.ADDED_TO_STAGE, addedHandler); this.alpha=0; } private function addedHandler(event:Event):void { this.x = 140; this.y = 100; TweenMax.to(this, 1, {y:20, alpha:1, delay:1, ease:Quint.easeOut}); } }
    22. 22. package { import com.greensock.TweenMax; import com.greensock.easing.*; import flash.display.Sprite; import flash.events.Event; public class Works extends Sprite { private var _main:Portfolio; public function Works(main:Portfolio) { super(); _main = main; var _content:WorksMc = new WorksMc; this.addChild(_content); this.addEventListener(Event.ADDED_TO_STAGE, addedHandler); this.alpha = 0; } private function addedHandler(event:Event):void { this.x = 140; this.y = 100; TweenMax.to(this, 1, {y:20, alpha:1, delay:1, ease:Quint.easeOut}); } }

    ×