プレゼンツール

すっごい低機能なやつを作ってみた。要Tweenerライブラリ

package com.gioext
{
    import flash.filters.BlurFilter;
    import flash.display.*;
    import flash.text.*;
    import flash.events.*;
    import flash.ui.Keyboard;
    import caurina.transitions.Tweener;
    import caurina.transitions.properties.FilterShortcuts;

    public class Slide extends Sprite
    {
        private var pageList:Array = new Array();
        private var currentPage:int = -1;

        public function Slide()
        {
            stage.addEventListener(KeyboardEvent.KEY_DOWN, keyDownHandler);
            stage.addEventListener(MouseEvent.CLICK, mouseClickHandler);
            FilterShortcuts.init();
        }

        public function keyDownHandler(event:KeyboardEvent):void
        {
            switch(event.keyCode)
            {
                case Keyboard.RIGHT:
                    next();
                    break;
                case Keyboard.LEFT:
                    prev();
                    break;
            }
            stage.focus = stage;
        }

        public function mouseClickHandler(event:MouseEvent):void
        {
            var x:int = event.stageX;
            var width:int = stage.stageWidth;
  
            if ((width / 2) > x)
            {
                 prev();
            }
            else
            {
                next();
            }
      stage.focus = stage;
        }
       
        public function takahashi(text:String):void
        {
            trace(text);
            var tf:TextField = new TextField();
            tf.htmlText = text;
            tf.width = stage.stageWidth;
            tf.height = stage.stageHeight;
            tf.multiline = true;
            tf.x = stage.stageWidth * 1.5
            pageList.push(tf);
        }
        
        public function show(page:int):void
        {
            trace("show");
            var newPage:int = Math.min(Math.max(0, page), pageList.length - 1);
            if (newPage == currentPage)
            {
                return;
            }
            for (var i:int = 0; i < numChildren; i++)
            {
                var child:DisplayObject = getChildAt(i);
                if(child.x != 0)
                {
                    removeChild(child);
                }
            }
            var d:DisplayObject = pageList[currentPage];

            if (d != null && contains(d))
            {
                Tweener.addTween(d, {
                    time: 1.5,
                    x: stage.stageWidth * (newPage < currentPage ? 1.5 : -1.5),
                    onComplete: function():void {
                        removeChild(d);
                    }
                });
            }
            currentPage = newPage;
            var current:DisplayObject = pageList[currentPage];
            addChild(current);
            current.filters = [new BlurFilter(100, 100)]
            Tweener.addTween(current, {
                x: 0,
                time: 0.5,
                delay: 0.1,
                alpha: 0.6,
                _Blur_blurX: 16,
                _Blur_blurY: 16
            });
            Tweener.addTween(current, {
                time: 0.5,
                delay: 0.6,
                alpha: 1,
                _Blur_blurX: 0,
                _Blur_blurY: 0
            });
        }

        public function next():void
        {
            trace("next");
            show(currentPage + 1);
        }
        
        public function prev():void
        {
            trace("prev");
            show(currentPage - 1);
        }
    }
}
package
{
    import flash.display.*;
    import com.gioext.Slide;

    [SWF(backgroundColor="#000000", width=640, height=480)]
    public class SlideShow extends Slide
    {
        public function SlideShow()
        {
            takahashi("<font size=\"120\" color=\"#FFFFFF\">はじめまして</font>");
            takahashi("<font size=\"120\" color=\"#FFFFFF\">id:gioextです</font>");
            takahashi("<font size=\"120\" color=\"#FFFFFF\">高橋メソッド</font>");
            takahashi("<font size=\"120\" color=\"#FFFFFF\">パクリました</font>");
            takahashi("<font size=\"120\" color=\"#FFFFFF\">御清聴\nありがとう\nございました</font>");
            show(0);
        }
    }
}


・いまいち表示オブジェクトの制御方法が分らない。
・TextField#htmlTextでfontサイズを指定した場合、折り返されない?
・外部CSSを使うと良さそう。
はてな上で動かせるように、SWFファイルの置き場所をどうにかしなきゃ