PDA

View Full Version : help for a Mask Effect transition AS3



Babaloo
April 14th, 2009, 09:42 AM
Hi everyone :krazy:

I'm extending a tutorial from Flashtuts by Michael Chen (http://flash.tutsplus.com/tutorials/effects/create-a-slick-image-revealer-in-flash-using-actionscript-3/).
My goal is to have the grid fill in random, masking the image for a transition, as the famed Mask Effect transition from Flash-filter.

This is what i got so far:
http://joaomiguelaliano.com/flush/banner.html

AS3:

var maskImg:MovieClip = new MovieClip();
addChild(maskImg);
imageToReveal_mc.mask = maskImg;
imageToReveal_mc.cacheAsBitmap=true;
maskImg.cacheAsBitmap=true;

var xPos:Number = imageToReveal_mc.x;
var yPos:Number = imageToReveal_mc.y;
var spacingX:Number = 70;
var spacingY:Number = 70;


var maxXPos:Number = imageToReveal_mc.x + imageToReveal_mc.width + spacingX;
var maxYPos:Number = imageToReveal_mc.y + imageToReveal_mc.height + spacingY;

function revealImage():void {

var ca:quadroAnimado = new quadroAnimado();
ca.x = xPos;
ca.y = yPos;
maskImg.addChild(ca);

var randoX:Number = Math.floor(Math.random()*10);
var randoY:Number = Math.floor(Math.random()*4);

for (var i:Number = 1; i < 50; i++) {
xPos = spacingX*randoX;
yPos = spacingY*randoY;
}

trace("X: "+randoX);
trace("Y: "+randoY);
//trace("For: "+i);
}

var timer:Timer = new Timer(20);
timer.addEventListener(TimerEvent.TIMER, onTimer);
timer.start();
function onTimer(evt:TimerEvent):void {
revealImage();
}So I can fill in the grid, but I need to id the recticles so that they don't stack n top of each other, filling in only where the mask's still missing, until the transiton is completed.

I'm looking into miniml's grid (http://www.reflektions.com/miniml/template_permalink.asp?id=276), maybe I'll find something there, tho I'm not sure it's AS3, which I'm trying to catch up to.

SandeR2
April 14th, 2009, 11:05 AM
I can't help you but as I was testing your Flash I found that if you go over the movie with your mouse it slows down. Any idea why? Nice effect btw maybe if you make it a bit slower you could also use it as a header ;) (Just a thought)

Babaloo
April 14th, 2009, 03:38 PM
I can't help you but as I was testing your Flash I found that if you go over the movie with your mouse it slows down. Any idea why? Nice effect btw maybe if you make it a bit slower you could also use it as a header ;) (Just a thought)

It slows down because it's in an infinite loop, chunking up ever larger pieces of RAM =(

I'm trying to figure it out exactly for that purpose, use it as a banner.

My conclusion is that you really have to make a grid and have the recticles in an array. it's the only way to address each one of them individually, I guess.