SoFunction
Updated on 2025-04-13

Flex achieves draggable frosted glass effect


// ActionScript file
import ;
import ;
import ;
import ;
import ;
import ;
import ;
private var m_mouseDown : Boolean = false;
private var m_offsetPt : Point;
private function onCreationComplete(evt:Event) : void
{
onBoxRender(null);
}
private function onBoxRender(evt:Event) : void
{
if( > 0 && > 0 )
{
var bmpData : BitmapData = new BitmapData( , , false);
var matrix : Matrix = new Matrix();

// Translate the matrix
( -1 * , -1 * );

// Fill the background onto the moving element
( ctlContainer
, matrix
, null
, null
, new Rectangle( 0, 0, + 4, + 4) // Crop area
);
( bmpData
, new Rectangle( 0, 0, , )
, new Point( 0, 0)
, new BlurFilter( 5, 5, 5) // The larger the parameters of BlurFilter, the larger the calculation amount, the more stuck it is when moving
);
(bmpData, null, false, false);
( 0, 0, , );
();
}
}
private function onMouseDown(evt:MouseEvent) : void
{
m_mouseDown = true;
m_offsetPt = new Point( , );
}
private function onMouseUp(evt:MouseEvent) : void
{
m_mouseDown = false;
();
}
private function onMouseMove(evt:MouseEvent) : void
{
if( m_mouseDown )
{
= - m_offsetPt.x;
= - m_offsetPt.y;
();
}
}
// ActionScript file
import ;
import ;
import ;
import ;
import ;
import ;
import ;
private var m_mouseDown : Boolean = false;
private var m_offsetPt : Point;
private function onCreationComplete(evt:Event) : void
{
    onBoxRender(null);
}
private function onBoxRender(evt:Event) : void
{
    if( > 0 && > 0 )
    {
        var bmpData : BitmapData = new BitmapData( , , false);
        var matrix : Matrix = new Matrix();

// Translation transformation of the matrix
        ( -1 * , -1 * );

// Fill the background onto the moving element
        ( ctlContainer
        , matrix
        , null
        , null
new Rectangle( 0, 0, + 4, + 4) // Crop area
        );
        ( bmpData
            , new Rectangle( 0, 0, , )
            , new Point( 0, 0)
New BlurFilter( 5, 5, 5) // The larger the parameters of BlurFilter, the larger the calculation amount, the more stuck it is when moving
            );
        (bmpData, null, false, false);
        ( 0, 0, , );
        ();
    }
}
private function onMouseDown(evt:MouseEvent) : void
{
    m_mouseDown = true;
    m_offsetPt = new Point( , );
}
private function onMouseUp(evt:MouseEvent) : void
{
    m_mouseDown = false;
    ();
}
private function onMouseMove(evt:MouseEvent) : void
{
    if( m_mouseDown )
    {
         = - m_offsetPt.x;
         = - m_offsetPt.y;
        ();
    }
}