ThemeForest

block transition

1277 posts
  • Bought between 50 and 99 items
  • Contributed a Tutorial to a Tuts+ Site
  • Exclusive Author
  • Has been a member for 5-6 years
  • Interviewed on the Envato Notes blog
  • Referred between 100 and 199 users
  • Repeatedly Helped protect Envato Marketplaces against copyright violations
+2 more
rondog says

hey guys. I have an image that I want to transition using that block transition that is pretty common. I have the block part down. I want each block to fade in now obviously. I can get them to fade in one row or column at a time, just not each individual block at a time. It has to do with the delay set on my tween line I think

var rows = 7;
var columns = 7;
var blockWidth = Math.ceil(e.target.content.width / columns);
var blockHeight = Math.ceil(e.target.content.height / rows);

for (i = 0; i < rows; i++)
{
    for (j = 0; j < columns; j++)
    {
        bitmap_data = new BitmapData(blockWidth,blockHeight);
        matrix = e.target.content.transform.matrix;
        matrix.translate(-blockWidth * i, -blockHeight * j);
        bitmap_data.draw(e.target.content,matrix);

        block = new Sprite();
        block.alpha = 0;
        block.x = blockWidth * i;
        block.y = blockHeight * j;
        bitmap = new Bitmap(bitmap_data);
        block.addChild(bitmap);
        photoHolder.addChild(block);
        TweenLite.to(block,0.3,{alpha:1,delay: (i * 0.08) });
    }
}
755 posts
  • Beta Tester
  • Bought between 100 and 499 items
  • Croatia
  • Exclusive Author
  • Has been a member for 6-7 years
  • Referred between 50 and 99 users
  • Sold between 50 000 and 100 000 dollars
djankey says
something like this?
TweenLite.to(block,0.3,{alpha:1,delay: ((i*columns + j) * 0.08) });
1954 posts
  • Bought between 10 and 49 items
  • Exclusive Author
  • Has been a member for 5-6 years
  • Netherlands
  • Referred between 10 and 49 users
  • Sold between 5 000 and 10 000 dollars
Emroni says

Instead of using 2 for loops, I would suggest using the modulus instead:

for(i=0;i<10;i++){
     trace( i % 2 ); // output: 0, 1, 0, 1, 0, 1, 0, 1, 0, 1
}
The following makes a 3×3 grid:

for(i=0;i<9;i++){
     block.x = ( i % 3 ) * blockWidth;   // So this goes: 0, 1, 2, 0, 1, 2, 0, 1, 2
     block.y = Math.floor( i / 3 ) * blockHeight; // And this one: 0, 0, 0, 1, 1, 1, 2, 2, 2 
}

Might be useful when doing delays as well.

260 posts
  • Author had a Free File of the Month
  • Bought between 10 and 49 items
  • Exclusive Author
  • Grew a moustache for the Envato Movember competition
  • Has been a member for 4-5 years
  • Referred between 1 and 9 users
  • Sold between 5 000 and 10 000 dollars
  • United Kingdom
ravenwill says

Or diagonally would be:

TweenLite.to(block,0.3,{alpha:1,delay: ((j*rows/columns + i) * 0.08) });

:)

1277 posts
  • Bought between 50 and 99 items
  • Contributed a Tutorial to a Tuts+ Site
  • Exclusive Author
  • Has been a member for 5-6 years
  • Interviewed on the Envato Notes blog
  • Referred between 100 and 199 users
  • Repeatedly Helped protect Envato Marketplaces against copyright violations
+2 more
rondog says

something like this?
TweenLite.to(block,0.3,{alpha:1,delay: ((i*columns + j) * 0.08) });

Or diagonally would be:

TweenLite.to(block,0.3,{alpha:1,delay: ((j*rows/columns + i) * 0.08) });

:)

ah perfect guys..that is so awesome

by
by
by
by
by