Wednesday, March 25, 2009

Flash Paginator: Get total of pages

Here is a really simple algorithm to get total of pages in a paginator.

var itemsTotal:int = 33;
var itemsPerPage:int = 6;

var remainder:int = itemsTotal % itemsPerPage;
var totalOfPages:Number = Math.round(itemsTotal / itemsPerPage);

if ( remainder > 0 )
{
totalOfPages = totalOfPages + 1;
}

trace(remainder + " = how many items are left.");
trace(totalOfPages + " = total of pages");

Friday, March 13, 2009

GTweenFilter Error - no filter at index

I'm not sure how many people are playing with Flash Player 10. I'm enjoying this current project. It is all being coded via Textmate using the Player 10 API. I'm currently using GTween for all my animation/transitions and have a simple tip for adding GTweenFilters to dynamic objects.

If you're trying to apply a GTweenFilter effect on a programmatic object you may get a 'no filter at index [number]'. Don't forget the filter for your object hasn't been created yet. You need to create a new filter and add it to your objects filters array. Here is a short example:

clip.filters = [ new BlurFilter( 0, 0, BitmapQuality.MEDIUM ) ];
new GTweenFilter( clip, 0.6, { blurX: 40, blurY: 40 }, { reflect:true, ease:Sine.easeInOut } );