Jesse,
Pretty cool!
Hmmmm... Would be great if the you were able to add filters to the
image below just within the bounds of that slice.
Cheers,
- Bill
On May 24, 2007, at 12:15 AM, Jesse Graupmann wrote:
Stage.scaleMode = 'noScale'
import flash.display.*
import flash.geom.*
function drawSlices ( image:MovieClip, drawMC:MovieClip,
rotation:Number,
sliceWidth:Number )
{
var slice_info = getSliceInfo ( image, rotation );
// DOT IS JUST A VISUAL MARKER
dot._x = image._x + slice_info.pt.x;
dot._y = image._y + slice_info.pt.y;
dot.swapDepths ( dot._parent.getNextHighestDepth() )
var angle = rotation * (Math.PI/180);
var slices_top = Math.ceil(image._width/sliceWidth);
var slices_bottom = Math.ceil((slice_info.pt.x)/sliceWidth)
var slice_array = [];
for ( var i = -slices_bottom; i < slices_top; i++ )
{
var slice = drawMC.createEmptyMovieClip ( 'slice_' + i,
drawMC.getNextHighestDepth() );
slice._x = i * ( sliceWidth-(sliceWidth/1.7));
var bmp_temp = new BitmapData ( sliceWidth+1,
slice_info.diagonal_height+sliceWidth, true, 0x00FFFFFF );
var bmp_temp_matrix:Matrix = new Matrix();
bmp_temp_matrix.rotate( angle );
bmp_temp_matrix.translate( -(sliceWidth) * i, -sliceWidth *
i );
bmp_temp.draw ( image, bmp_temp_matrix, null, null, null,
true );
var slice_bmp = new BitmapData ( slice_info.diagonal_width ,
slice_info.diagonal_height, true, 0x00FFFFFF );
var slice_bmp_matrix:Matrix = new Matrix();
slice_bmp_matrix.rotate(-angle);
slice_bmp_matrix.translate( (sliceWidth )*i, 0 );
slice_bmp.draw ( bmp_temp, slice_bmp_matrix, null,
null,null, true );
slice.attachBitmap ( slice_bmp, 1, true, true );
slice_array.push ( slice );
}
drawMC.slice_array = slice_array;
}
////////////////////////////////////////
function getSliceInfo ( image, angle)
{
var pt = new Point ( image._width, image._height );
var len = pt.length;
var degrees = 90 - angle;
var radians = degrees * (Math.PI/180);
var dpt = new Point ( len * Math.cos ( radians ), len * Math.sin (
radians ) );
dpt.x = Math.max ( 0, Math.min ( pt.x, dpt.x ));
dpt.y = Math.max ( 0, Math.min ( pt.y, dpt.y ));
var info = {
pt:dpt,
diagonal_width: dpt.x,
diagonal_height: dpt.length
}
return info;
}
////////////////////////////////////////
function drawSlicedImage ()
{
// ORIGINAL IMAGE
mc._alpha = 40
// SLICE HOLDER
var drawMC = this.createEmptyMovieClip ( 'drawMC',
this.getNextHighestDepth() );
drawMC._x = mc._x;
drawMC._y = mc._y;
// CREATE SLICES
var sliceWidth = 30
var angle = 45;
drawSlices ( mc, drawMC, angle, sliceWidth );
}
function addSliceInteraction ( )
{
drawMC.onMouseMove = function()
{
var xper = Math.max ( 0, Math.min ( 1, this._xmouse /
mc._width ) )
var yper = 1-Math.max ( 0, Math.min ( 1, this._ymouse /
mc._height ) )
var per = (xper+yper)/2
var inx = Math.round ( this.slice_array.length * per )
for ( var i in this.slice_array )
{
var slice = this.slice_array [ i ];
if ( i == inx )
{
slice._alpha = 10;
}
else
{
slice._alpha = 100;
}
}
}
}
//////////////////////////////////////
function INIT ()
{
drawSlicedImage ();
addSliceInteraction ();
}
INIT ();
_______________________________________________
Flashcoders@chattyfig.figleaf.com
To change your subscription options or search the archive:
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
Brought to you by Fig Leaf Software
Premier Authorized Adobe Consulting and Training
http://www.figleaf.com
http://training.figleaf.com