Archive for the 'Uncategorized' Category
Increase Memory in Flash Builder / Eclipse for Mac OS
If you ever get the eclipse “Out of Memory” error, then you need to increase the default memory size. It’s relatively easy, but you have to know where to look.
In your eclipse install folder, right click on the Eclipse launcher and choose “Show Package Contents”. Then navigate to Contents/MacOS and open eclipse.ini. Change the min & max values to:
-Xms128m
-Xmx512m
Object Translator – Normalizing Objects
This is an extension of a great blog from Justin Opitz on normalizing value objects. We were discussing the a best way to take objects that are somewhat similar in form and conform them to an interface. Normalizing objects allows you perform logic on data that is generic and more makes your code more reusable.
So imagine we have several different object types coming in, like Artist, Album, & Track objects with properties that are similar, yet unique, including “artistName”, “albumName”, “trackName”, among others. We want to put this into a VO with just “name”.
Below is a modified version of the translator. If you have several different VOs that implement an interface then you may want the ability to assign them as needed. Since it could be any one of the VOs being, we’ll pass it in as a wild card
and then return the newly assigned object. Also, if the current propety doesn’t match a pattern we’re looking for, then it assigns it as-is.
So here’s what the function will look like:
{
for (var s:String in vo)
{
//we are going to check each prop name to see if there is a match for our
//targetObject’s known properties
//obvious ly this list will grow the more props you have to normalize
//however it only grows once regardless of the number of non-normalized VOs
if (s.toLowerCase().indexOf(’name’) != -1)
targetObject.name = String(vo[s]);
else if (s.toLowerCase().indexOf(’id’) != -1)
targetObject.id = int(vo[s]);
else if (s.lowerCase().indexOf(’genres’) != -1)
targetObject.genres = vo[s] as Array;
else
targetObject[s] = vo[s];
return vo;
}
}
New Blog – Finally
I finally got my new blog up and running. This is mainly here to serve as a placeholder, but in actuality, I’ll probably never delete it so I should try to at least put something useful here.I’ll be posting things that I have found to be helpful in my daily Flex development. Also I’ll be writing about issues I’ve come across that were painful to work around so hopefully someone else can reap the benefits of me banging my head against the wall. I’ve done a lot of work with using audio in Flex so I will be writing about Sound as well.
No comments