More Related Content
Similar to Sbaw091117 (20)
More from Atsushi Tadokoro
More from Atsushi Tadokoro (20)
Sbaw091117
- 11. 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);
}
- 12. //Circle
private function clickCircleHandler(event:MouseEvent):void
{
//
_test.message.text = "Circle";
}
//Rect
private function clickRectHandler(event:MouseEvent):void
{
//
_test.message.text = "Rect";
}
}
}
- 19. 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);
- 20. //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);
}
- 21. //
//
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;
}
}
}
- 25. 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); //
}
}
}
}
- 26. 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;
- 27. 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;
}
}
}
- 29. • Tween
• Tween
• 2
•
• Flash Tween
• TweenMax
•
•
• http://blog.greensock.com/tweenmaxas3/
• gs
- 30. • TweenMax
• TweeMax
import gs.TweenMax;
import gs.easing.*;
• Tween Tween
TweenMax.to( , ,{ });
- 31. •
• TweenMaxAS3_Basics.swf
- 33. 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); //
}
}
}
}
- 34. 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);
}
- 35. 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;
}
- 36. //
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;
}
}
}
- 45. 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);
- 46. //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;
}
- 47. 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);
}
- 48. 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);
}
}
}
- 49. 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});
}
}
- 50. 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});
}
}
- 51. 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});
}
}