In case Flash no longer exists; a copy of this site is included in the Flashpoint archive's "ultimate" collection.

Dead Code Preservation :: Archived AS3 works from wonderfl.net

なぜかTextFieldのホイールが利かない

Wonderfl だと なぜか TextField のマウスホイールが利きません。
なぜでしょう?
Get Adobe Flash player
by bkzen 24 Oct 2011
  • Forked from bkzen's マウスホイールの実験
  • Diff: 15
  • Related works: 1
  • Talk

    bkzen at 24 Oct 2011 09:00
    wmode が transparent だと起こる現象のようです。
    bkzen at 24 Oct 2011 09:18
    FlashPlayer10.3.183.10 でも、再現。 FP11 対応をしようとしたときに起きた wmode が変更されたっぽい?
    9re at 24 Oct 2011 10:13
    wmodeは変えることが可能です!(You can change wmode) http://twitter.com/#!/9re/status/128340183761436672/photo/1/large
    bkzen at 24 Oct 2011 11:03
    そんなところにあったんですね!w 気づきませんでした!ありがとうございます!

    Tags

    Embed
/**
 * Copyright bkzen ( http://wonderfl.net/user/bkzen )
 * MIT License ( http://www.opensource.org/licenses/mit-license.php )
 * Downloaded from: http://wonderfl.net/c/pxRT
 */

// forked from bkzen's マウスホイールの実験
package  
{
    import com.bit101.components.Label;
    import com.bit101.components.Style;
    import flash.display.Sprite;
    import flash.events.Event;
    import flash.text.TextField;
    
    /**
     * マウスホイールでのページスクロールを無理やりとめる。
     * 簡単で安易な実装。
     * 
     * @author jc at bk-zen.com
     */
    [SWF (backgroundColor = "0xFFFFFF", frameRate = "30", width = "465", height = "465")]
    public class ScrollTest extends Sprite
    {
        
        public function ScrollTest() 
        {
            if (stage) init();
            else addEventListener(Event.ADDED_TO_STAGE, init);
        }
        
        private function init(e: Event = null): void 
        {
            removeEventListener(Event.ADDED_TO_STAGE, init);
            //
            var txt: TextField = new TextField();
            var i: uint, n: uint = 50;
            for (i = 0; i < n; i++) 
            {
                txt.appendText(i + "\n");
            }
            addChild(txt);
            /*
            Style.fontName = "Verdana";
            Style.embedFonts = false;
            Style.fontSize = 12;
            new Label(this, 50, 25, "普通の Sprite");
            var normalSp: Sprite = new Sprite();
            normalSp.graphics.beginFill(0xCCCCCC);
            normalSp.graphics.drawRect(0, 0, 100, 200);
            normalSp.graphics.endFill();
            normalSp.x = 50, normalSp.y = 50;
            
            new Label(this, 200, 25, "マウスホイールをロックした Sprite");
            var lockSp: ScrollLockSprite = new ScrollLockSprite(100, 200);
            lockSp.graphics.beginFill(0xAAAAAA);
            lockSp.graphics.drawRect(0, 0, 100, 200);
            lockSp.graphics.endFill();
            lockSp.x = 200, lockSp.y = 50;
            
            addChild(normalSp);
            addChild(new DummyScrollBar(normalSp));
            addChild(lockSp);
            addChild(new DummyScrollBar(lockSp));
            */
        }
    }
}
/*
import flash.display.Graphics;
import flash.display.InteractiveObject;
import flash.display.Shape;
import flash.display.Sprite;
import flash.events.MouseEvent;
import flash.text.TextField;
class DummyScrollBar extends Shape
{
    private var target: InteractiveObject;
    function DummyScrollBar(target: InteractiveObject)
    {
        this.target = target;
        var g: Graphics = graphics;
        g.beginFill(0);
        g.drawRect(0, 0, 20, 30);
        x = target.x + target.width;
        y = target.y;
        target.addEventListener(MouseEvent.MOUSE_WHEEL, onWheel);
    }
    
    private function onWheel(e: MouseEvent): void 
    {
        var d: int = e.delta;
        var t: int = this.y - d;
        if (t < target.y) this.y = target.y;
        else if (t > target.y + target.height - height) this.y = target.y + target.height - height;
        else this.y = t;
    }
}

class ScrollLockSprite extends Sprite
{
    private var txt: TextField;
    private var firstV: int;
    function ScrollLockSprite(w: int, h: int)
    {
        addChild(txt = new TextField());
        var i: int, n: int = h / 6;
        for (i = 0; i < n; i ++ )
        {
            txt.appendText(i + "\n");
        }
        txt.width = w, txt.height = h;
        firstV = txt.scrollV = h / 12;
        txt.selectable = true;
        //txt.alpha = 0;
        txt.addEventListener(MouseEvent.MOUSE_WHEEL, onMouseWheel);
    }
    
    private function onMouseWheel(e: MouseEvent): void 
    {
        txt.scrollV = firstV;
    }
}
*/