PDA

View Full Version : AS3 - Alpha Mask Help



oddball25
10 Sep 2010, 07:14 AM
Hi

I have a startDrag function set up on a loader and mask that when the mouse is down on the loader it drags, when not it doesn't. There is also 2 buttons that control whether mask1 or mask2 is used.

What i would like however is when the mouse is down - the area of the loader outside of the mask is visible but only by about 10/20% alpha, that way the user can see where all the image is while dragging. Is this possible?

Full code can be seen below and i have attached the zip with the .fla file:



// Imports.
import flash.display.Sprite;
//

// Sets masks as false on start up.
maskP1.visible = false;
maskP2.visible = false;
//

// Load External Image into loader.
var imageP1:Loader = new Loader();
var request:URLRequest = new URLRequest("image.jpg");
imageP1.load(request);
addChild(imageP1);
imageP1.contentLoaderInfo.addEventListener(Event.COMPLETE, onLoadComplete);

function onLoadComplete(event:Event):void {
imageP1.x = 67;
imageP1.y = 67;
imageP1.width = 425;
imageP1.height = 282;
}
//

// Make Loader a Child of Sprite.
var imageP1_Content:Sprite = new Sprite();
imageP1_Content.buttonMode = true;
imageP1_Content.addChild(imageP1);
addChild(imageP1_Content);
//

// Set Drag Function.
imageP1.addEventListener(MouseEvent.MOUSE_DOWN, drag);
imageP1.addEventListener(MouseEvent.MOUSE_UP, drop);

function drag(event:Event):void {
imageP1_Content.startDrag();
}
function drop(event:Event):void {
imageP1_Content.stopDrag();
}
//

// Set functions for mask scale.
_10x10.addEventListener(MouseEvent.MOUSE_UP,scale1);
_20x20.addEventListener(MouseEvent.MOUSE_UP,scale2);

function scale1 (event:Event):void {
maskP1.visible = true;
maskP2.visible = false;
imageP1.mask = maskP1;
}

function scale2 (event:Event):void {
maskP2.visible = true;
maskP1.visible = false;
imageP1.mask = maskP2;
}
//


Please, please help! :)

Thanks in advance

John