Monday, March 09, 2009

AS3 Dynamic Text Wrapping or Flowing Around Objects

EDIT: Take a look here if you are able to use Flash Player 10. (http://labs.adobe.com/technologies/textlayout/)

The Flash community is still waiting for Adobe to implement dynamic or intelligent text wrapping into Flash. So meanwhile several programmers are creating their own solutions and work arounds.

After thinking about the problem, I did a quick search and I found that dispatchEvent.org actually had released a solution very similar to my own inital approach. So I took a look at their code and made some improves upon based off of their original dynamic text wrapping utility.

The improvements allow text to flow around multiple objects on the left and the right. It still utilizes BitmapData and transparent pixels around each slice, but simply manages a linked list of TextFormats to control the leftMargin. In addition, it will also accept a flash.geom.Rectangle as a bounding box to work in; the motivation for this function is to reduce the computational load.

Simply input a list of DisplayObjects for the $leftList and the $rightList. Here's the function prototype:
public static function bound($field:TextField, $leftList:Array, $rightList:Array, $wrapArea:Rectangle=null, $padding:Number=10):void;

To utilize it you would make an example call:
TextWrap.bound(tf,[o3,o4],[o1,o2]);

Where tf is the TextField which wraps around objects on its left o3 and o4 and warps around objects on its right o1 and o2.




Here is the code.

Of course, it's not perfect, but it's a starting point.

Wednesday, February 25, 2009

Removing Passwords Stored in Windows XP

Windows XP gives you the ability to store user names and passwords on your local computer so you do not have to enter in your credentials each time you access different sites or resources. Of course this provides some simplicity for users that have to remember more than one user name and password. However, in terms of security, any one who sits down at your computer while you are logged on can then access sites and resources using your cached credentials.

You can view and remove the stored credentials on your computer using the following steps:

1. Click Start and select Run.
2. Type in rundll32.exe keymgr.dll, KRShowKeyMgr and Click OK.
3. The Stored User Names and Passwords dialog box will appear.
4. You can remove an entry by selecting it from the list and clicking the Remove button.
5. Click Close.

Thursday, January 15, 2009

Increasing Memory Availability In Eclipse

I often work with large projects in Eclipse so I'm frequently using all of the memory allocated to Eclipse. On MacOS X the configuration file is located here:

/Applications/eclipse/Eclipse.app/Contents/MacOS/eclipse.ini

By default the following memory is allocated:

...
-Xms40m
-Xmx512m
...

I've changed this to:

...
-Xms256m
-Xmx512m
...

Thursday, December 18, 2008

Beginner: AS3 XMLList as a Primitive and XML as a Complex Datatypes

Using Flex SDK 3.1.0 build 2710

I'm not sure if this is true across the board after doing a little searching on the web. It seems that people have had different experiences. But as far as I'm concerned right now, XML is being handled as a complex datatype and XMLList is being handled as a primitive datatype.

I'm looking to confirm this though.

Flash has two types of datatypes: primitives and complex. Primitives are datatypes such as Strings or Numbers where each type you associate them a new instance is created.

var abc:String='three wise men';
var copy:String=abc;

abc='two plain dogs';

trace(abc);
trace(copy);

This above example associates copies the variable abc into the variable copy so that changes in abc later will no be reflected in copy.

Complex datatypes, such as Objects, retain references to an original instance stored in memory.

var dog:Object = {chase:true, likes:'cars'};
var cat:Object = {chase:false, likes:'naps'};

dog=cat;

cat.likes='mice';

trace(dog.likes);
trace(cat.likes);

In the above example the variable dog will now reference the same object as the variable cat. Therefore, changing the string 'likes' to mice will change both dog.likes and cat.likes.

XML and XMLList example.

Monday, October 06, 2008

Conway's Game of Life

Here's a neat implementation of Conway's Game of Life using bitmap data filters to run the logic.
"Another way to do the calculations is to use filters which perform all of the calculations that are needed for one step in the Game of Life in a few lines of Actionscript. Filters such as the blur and convolution filters determine the colour of a pixel based on its neighbour’s colours which is exactly the kind of behaviour we need to run the Game of Life calculations. All of the hard work is done behind the scenes, effectively at a lower level which makes the simulation faster.
http://www.stdio.co.uk/blog/?cat=4&paged=2

This makes me want to write my own version of Conway's Game.