October 2010
2 posts
5 tags
[JS] Dynamic "Like" button on Cargo Collective...
I think you all know Cargo Collective. It’s a publishing platform for creative portfolios. It’s very sleek and comes with a lot of customization options. But one downside it’s that it still doesn’t have much third party apps compatibility.
To add a facebook “Like” button, you must go to the facebook page and set up a button for each project you have and then...
[AS3] Recursive Font Embeding
So, i’m sure that you had this problem before. You put a dynamic textfield on a MovieClip or Sprite and then set’s it to a variable coming from a XML file. Your client start using the website and complains to you that he cannot see the text in the right font on his computer, or some characters are missing.
Well….the truth is: the way Flash deals with font managing just suck!...
September 2010
5 posts
AS3 Library Linkage Class
So, you have a symbol on the library and you want to use it on your class files. You can sure use the new atribute and add to the Display List, but some of OOP Encapsulation will be lost, once the object is not on your packages but stored on the library. I personally like to use the undocumented function getDefinitionByName to get library symbols. The thing is, the implementation of...
AS3 RegExp Basics
Hi all. The idea behind this site is not really tutorials and stuff, but just be my repository of useful stuff that i create/find/improve. But i want to take this post and talk about Regular Expressions. Something that other programmers are very familiar with, but it’s kind of a new thing on actionscript.
Recently i had to remove all html tags from a text before showing on my application....
2 tags
AS3 FullScreen Stage Resizer and Align Class
This is a simple utility class that resizes a DisplayObject to fill the stage area and align based on predefined positions such as top, top-left, top-right, bottom, bottom-left, bottom-right, center, center-left, center-right. There’s a lot of debate wheter or not to use private static on as3, i figured that if the class compiles with no errors, we are good to go.
package...
2 tags
AS3 Pixel Precise Hit Testing
This is a simple utility function to detect pixel precise hit testing. Here i use the features of the BitmapData class to make a pixel perfect hitText
public static function hitTest(object:DisplayObject, point:Point):Boolean
{
if(object is BitmapData)
{
return (object as BitmapData).hitTest(new Point(0,0), 0, object.globalToLocal(point));
}
else
{
if(!object.hitTestPoint(point.x,...
2 tags
AS3 put itens on a grid
This is a simple utility function that grid the DisplayObjects together with a predefined horizontal and vertical spacing
public static function gridItens(itens:Array, numCols:int, spacingW:Number, spacingH:Number):void
{
for (var i:int = 0; i < itens.length; i++)
{
var item:DisplayObject = itens[i];
item.x = (i % numCols * spacingW);
item.y = Math.floor(i / numCols) *...
August 2010
6 posts
3 tags
4 tags
Using the Flash Player 10.1 Debugger Version on...
Chrome is my favorite browser! I’m sure it’s yours too! So i installed the Flash CS5 and the Flash Builder 4, but somehow it screw up my debug player for chrome. All other browsers are still with the debug version of the player, but chrome is not.
After checking some sites out, i found out that chrome keeps both plugins installed but priorizes the non debug version. The reason for...
2 tags
Wanderer Flying Sprites
This is a way to implement a wanderer flying animation to any display object. you can check out the demo on wonderfl below.
Flying Shapes - wonderfl build flash online
package
{
import flash.display.Sprite;
import flash.geom.Matrix;
public class FlashTest extends Sprite
{
public function FlashTest()
{
var matr:Matrix = new Matrix();
matr.createGradientBox(100,...
2 tags
Simple Image Slider
This is a simple image slider for that situation when you have a image that is larger than the stage size, so you can move the mouse and the image will follow allowing you to see it.
package
{
import flash.display.SpreadMethod;
import flash.geom.Matrix;
import flash.display.GradientType;
import flash.display.Sprite;
import caurina.transitions.Tweener;
import...
2 tags
Flash JSFL Scaffolding.
This video shows how i use JSFL to integrate my projects with my Framework. With just a few clicks i can have a full project skeleton with swfaddres, context menu and a lot of features.
This is a work in progress, more to come soon.
PS: Please hit fullscreen!
2 tags
How To use my JSFL scripts
Hi there.
I had a friend of mine asking me how to use the JSFL scripts on your enviroment. Well, JSFL stands for Flash Javascript and is not an as3 script.
This is meant to save you time when working with the Flash IDE by sending commands to execute a task, just like a plugin would do.
To run the JSFL scripts, just copy them to a new text file and name it with a .jsfl extension, like...
July 2010
9 posts
4 tags
AMFPHP Service - JPEGEncoder
This AMFPHP service receives an image byte array and transforms it to a JPG image.
<?php
class JPEGEncoder
{
function JPEGEncoder ( )
{
}
/**
@desc save the JPEG on server
*/
function saveToServer ( $pInfos )
{
$bytearray = $pInfos["jpegstream"];
// bytearray is in the ->data property
$imageData = $bytearray->data;
$idimage = $pInfos["fileName"];
return...
3 tags
Flex Component - Generic TextInput
This Flex Component receives a defaultValue string and sets it as the textfield value, when the user focus the textfield, the value is clear and when the user focus out the textfield, if the value is still cleared, it resets the textfield string to the default value.
<?xml version="1.0" encoding="utf-8"?>
<mx:TextInput xmlns:mx="http://www.adobe.com/2006/mxml"...
3 tags
AS3 - Convert Serialized Object to XML Object
This utility code runs a loop to a serialized object, parse all it’s content into a xml object.
Esse código percorre um laço num objeto serializado e transforma esse objeto em um xml.
/**
* This function converts an serialized object to XML
* @param obj
* @return
*
*/
public static function objectToXML(obj:Object):XML
{
delete obj.mx_internal_uid; // comment this if you are...
2 tags
JSFL Allow Smoothing
This simple script select allowSmoothing for all library images.
Este script percorre toda a biblioteca e marca a opção allowSmoothing das imagens
var libItems = fl.getDocumentDOM().library.items;
for (i = 0; i < libItems.length; i++){
if(libItems[i].itemType == "bitmap"){
libItems[i].allowSmoothing = true;
libItems[i].compressionType = "lossless";
}
}
3 tags
AS3 Currency Converter
This is a little utility that i found on the internet and gave it some personal touch. It formats a number value to a currency string.
Esse é um código que eu achei na internet e modifiquei um pouco. Ele formata um numero e transforma em uma string com o valor
function currency(num:Number,decimalPlace:Number=2,currency:String="R$"):String
{
//assigns true boolean value to neg in number less...
2 tags
JSFL Convert all selected objects to MovieClip
This script converts all selected objects to Movieclip using a standard insance name, library name and registration point.
Esse script converte todos os objetos selecionados para Movieclips usando um nome de instância padrão, nome do item da biblioteca e registration point.
if (fl.getDocumentDOM().selection.length > 0)
{
var cur_selection = fl.getDocumentDOM().selection;
var mySelected = new...
2 tags
JSFL Give an Instance Name to all Selected Objects
This script applies an instance name to all selected objects using a counter. Very useful for when you have to make animations involving a lot of objects.
Esse script aplica um nome de instância a todos os objetos selecionados. Bem últil para quando você precisa fazer animações que envolvem muitos objetos
if (fl.getDocumentDOM().selection.length > 0)
{
var cur_selection =...
2 tags
JSFL Export PNG or JPG to SWF
This script converts all images on a folder to a SWF file. Optionally, you can browse for a folder to save the FLA files. This is useful because PNG images are very large and when we convert to SWF, Flash compresses them but you can keep the transparent background.
Este escript converte todas as imagens de uma pasta para um arquivo SWF. Opcionalmente, você pode escolher uma pasta para salvar os...
2 tags
JSFL Pixel Snapping
Here is a Quick JSFL Script to select all items in the stage and Pixel Snap their position so they are not affected by Flash Player’s smoothing bug. Once this is done, all your items will have integer x and y positions
Este é um script JSFL que irá selecionar e zerar as posições de todos os items no stage para que eles não sejam afetados pelo bug do Flash Player que borra os objetos. Quando...