Blog
swfaddress firefox 3 fix
November 10th, 2008
Hey
Since the release of firefox 3, some of our sites have been a little temperamental as we use swfaddress heavily in our production. This blog seems to be the place to solve this problem, but i had to fafe about getting the uncompressed version in order to add the code - thought i would post the amended code: swfaddressFF3_fix
i haven’t had time to compress it again - definitely needed as without javascript compression it doubles in size
Recruiting Developers in London
October 23rd, 2008
Thought I would share this list that we have compiled of good places to post if you are looking for developers in London:
jobsite.co.uk - £299 (+vat) / 2 weeks
cwjobs.com - £195
reed.co.uk - £50 (+vat)
creativepool.co.uk - £220 / 28 days
actionscript.org - $150 / 2 weeks (for freelancers)
thefwa.com - £58.75 / 30 days
krop.com - $200 / 30 days
theitjobboard.co.uk - £550
london.digital-jobs.org/ - Free
Let me know if you find any more!
FOWA Expo
October 9th, 2008
I’m at FOWA today courtesy of Adobe. Still not really sure what to think. I came with a hope of meeting some developers, ended up meeting some old friends and making some new contacts. Just sat through a talk about Cappuccino, talking about Object-J etc. Nice stuff and it’ll be interesting to see how it will run, but I don’t think it’s for us. There’s a big presence from Micro$oft, still flogging Shilvershite. Saw their “table”, which is basically a big iPhone. And please Carson, take your hat off indoors, you look like a plonker!
sync your mobile with google calendar
October 5th, 2008
Hey,
Here at emakmafu we abuse google apps to the max - they are an integral part of our administration. One thing I have been longing for for ages is a way to have my mobile hook up with google calendar and do a two way sync. I had a look about a year ago when i got my nokia n95, and the only solution was to sysnc with ical, then ical to google, (ball-ache!) so i dropped that, as that’s just adding a whole new calendar to the problem… I just checked again, and discovered www.goosync.com. Its a two tier service, basic calendar syncing is free, with the option to upgrade to take care of syncing contact and tasks, autosync + loads more.
I was up and running within 5 minutes! well chuffed! (iphone compatible too!)
Rounded corners using scale9Grid: Make everything look just like stuff does on a Mac. Again.
October 2nd, 2008
Just the other day I caught a developer here (who shall remain nameless) painstakingly positioning and resizing 3 assets from an external swf file, in order to give some resizable UI components we needed, the rounded corners they truly deserved. It would be much nicer to do this using just one sprite and purely in Actionscript though, wouldn’t it? Yes it would!
If you found Bryan’s post impenetrable and have some rectangles in need of a good rounding check have a look at this ridiculously easy snippet o’ code:
public function roundrect()
{
var matr : Matrix = new Matrix();
matr.createGradientBox(40,20,Math.PI/2);
var grid : Rectangle = new Rectangle(10,10,30,30);
var _myComponent = new Sprite();
_myComponent.graphics.beginGradientFill(GradientType.LINEAR,[0xFFFFFF, 0xAEAEAE],[1,1],[0x00,0xFF], matr);
_myComponent.graphics.drawRoundRect(0,0,50,50,20,20);
_myComponent.scale9Grid = grid;
_myComponent.height = 20;
_myComponent.width = 100;
_myComponent.x = 200;
_myComponent.y = 200;
addChild(_myComponent);
}
The above creates a rounded rectangle, _myComponent, and a rectangle called grid which fits squarely in the center of _myComponent and is used as the 9-segment scaling grid for _myComponent. Once done, you can resize the component freely and rounded corners of _myComponent will be preserved whatever the size. Scaled down to width=20 and height=20, you’ll get a perfect circle since this is the size of the rounded corners on the rounded rectangle. With the width increased to 200 you’ll get a lovely rounded button thing. Don’t get it? Look at the pretty pictures.
Scaled to 20 x 20:
Scaled to 200 x 20:
Careful: if you get an error using scale9Grid, make sure that the rectangle you are using for the grid fits within the bounds of the sprite you are scaling.
Tadaa!
Ah Yes, The Old “Fix Font Embedding Problems By Sneakily Embedding An IDE Created MovieClip With A TextField Instance” Solution
September 28th, 2008
I don’t think we are ever going to see a solution for embedding fonts in ActionScript that is easy to use. In AS3 we were introduced to the use of the [Embed] tag, allowing you to embed files both from the local system, and also from exported swf files. Extra options include the option to specify the unicode character ranges, to save on file size. The best solution, is to use runtime shared libraries or make use of getDefinitionByName() to extract them out of loaded swf, however what happens if you need a textual preloader to load the font swf, and you get the fatal “Unable to transcode Font” message when using the embed tag in the flex compiler?
Well, firstly this happens because there are three font transcoders in the Flex compiler, and they all prefer TrueType fonts, and all suck (in my humble opinion). So the solution is to use the old faithful Flash IDE to handle your PostScript related font issues.
To do this, create a TextField instance inside a symbol and give it an instance name like “textField”, make sure you select the “embded fonts” option and only include the number of characters you require. Next mark the symbol for export and remember the class name (you don’t need to create a corresponding .as file for this class, one will be generated for you, also it doesn’t matter if you have the “declare stage instances” option on or off, this will be handled by for you as well).
The next step is then to use the embed tag to import this symbol (quick tip use the # symbol after the .swf to access the class name quickly e.g. [Embed (source="embeddedFields.swf#FontField")] ) and then all you need to do is instantiate the class and use inline array notation to access the TextField instance and use it like a regular textfield, like (fontFieldInstance['textField'] as TextField).text = “ta da”;
Peezy
Stop LazyInitialization exceptions with the Hessian Hibernate Cleaner Aspect
September 24th, 2008
Here is a piece of code I hacked up this afternoon and just had to share with the world. A cure, if you like, for the Hibernate LazyInitialization exception.
I am tired of the Hibernate LazyInitialization exceptions when remoting via Hessian or doing pretty much anything when you’ve got a disconnected Hibernate session; perhaps there’s a nicer solution to what I’m gonna provide here but I don’t know what it is. I’m pretty sure it’s NOT to turn off Lazy Initialization….
This class descends recursively through the result of a method invocation which may have returned a class or collection which may contain uninitialized Hibernate Collection instances, such as PersistentBag, PersistentSet or PersistentMap.
Upon encountering such a Collection an attempt is made to initialize said Collection, if this fails the Collection is set to null.
You should put this class between a Spring service and the HessianServiceExporter. Alternatively, it could be implemented as part of a custom HessianSerializationFactory. If anyone rewrites it that way, feel free to share the implementation with the world.
MafuBryan
import java.beans.PropertyDescriptor;
import java.util.ArrayList;
import java.util.Date;
import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.Set;
import org.apache.commons.beanutils.PropertyUtilsBean;
import org.apache.log4j.Logger;
import org.aspectj.lang.ProceedingJoinPoint;
import org.hibernate.LazyInitializationException;
import org.hibernate.collection.PersistentBag;
public class HessianCleanerAspect {
/**
* Logger for this class
*/
private static final Logger logger = Logger
.getLogger(HessianCleanerAspect.class);
public Object clean(ProceedingJoinPoint call) {
try {
if (logger.isDebugEnabled()) {
logger
.debug("clean(ProceedingJoinPoint) - from logging aspect: entering method ["
+ call.toShortString()
+ "] with params:”
+ appendArgs(call.getArgs()));
}
Object point = call.proceed();
point = descendThroughNode(point, new ArrayList<Object>());
if (logger.isDebugEnabled()) {
logger
.debug(”clean(ProceedingJoinPoint) - from logging aspect: exiting method ["
+ call.toShortString()
+ "with return as:"
+ point);
}
return point;
} catch (Throwable t) {
throw new UnsupportedOperationException(t);
}
}
/**
*
* This method is going to presume a couple of things.
* <ol>
* <li>Presume that we are not using any kind of bags or collections which
* shall contain duplicate elements.</li>
* </ol>
*
* @param node
* @param visited
* a {@link List} of node references for the nodes that have
* already been visited, this prevents getting stuck on, for
* example, circular references.
* @return
*/
@SuppressWarnings("unchecked")
private Object descendThroughNode(Object node, List visited) {
// Check to see if we have already visited this node.
if (visited.contains(node)) {
// If we have, then just return.
return node;
} else {
// Otherwise add the node to our visited list
visited.add(node);
}
try {
if (node == null) {
return null;
}
// if (node instanceof PersistentCollection) {
// return null;
// }
// If you got a list back from Hibernate
if (node instanceof List) {
return handleList(node, visited);
}
PropertyUtilsBean propertyUtilsBean = new PropertyUtilsBean();
PropertyDescriptor[] propertyDescriptors = propertyUtilsBean
.getPropertyDescriptors(node);
for (PropertyDescriptor p : propertyDescriptors) {
String name = p.getName();
if (logger.isDebugEnabled()) {
logger.debug(”descendThroughPoint(Object) - ” + name);
}
if (!”class”.equals(name)) {
Object property = propertyUtilsBean.getProperty(node, name);
if (property instanceof Set) {
try {
((Set) property).size();
// Ok, didn’t crash … must be possible to get the
// data from it…
Set s = new HashSet();
for (Object o : ((Set) property)) {
s.add(descendThroughNode(o, visited));
}
property = s;
propertyUtilsBean.setProperty(node, name, s);
} catch (LazyInitializationException l) {
if (logger.isDebugEnabled()) {
logger
.debug(”descendThroughPoint(Object) - clearing the Set:”
+ name);
}
propertyUtilsBean.setProperty(node, name,
new HashSet());
}
} else if (property instanceof List) {
try {
if (property instanceof PersistentBag) {
if (((PersistentBag) property).wasInitialized()) {
((List) property).size();
// Ok, didn’t crash … must be possible to
// get the
// data from it…
List s = new ArrayList();
for (Object o : ((List) property)) {
s.add(descendThroughNode(o, visited));
}
propertyUtilsBean
.setProperty(node, name, s);
} else {
propertyUtilsBean.setProperty(node, name,
new ArrayList());
}
}
} catch (Throwable l) {
if (logger.isDebugEnabled()) {
logger
.debug(”descendThroughPoint(Object) - clearing the List:”
+ name);
}
propertyUtilsBean.setProperty(node, name,
new ArrayList());
}
} else if (property instanceof Map) {
try {
((Map) property).keySet().size();
// Ok, didn’t crash … must be possible to get the
// data from it…
Map s = new HashMap();
for (Object o : ((Map) property).keySet()) {
s.put(o, ((Map) property)
.get(descendThroughNode(o, visited)));
}
propertyUtilsBean.setProperty(node, name, s);
} catch (LazyInitializationException l) {
if (logger.isDebugEnabled()) {
logger
.debug(”descendThroughPoint(Object) - clearing the Map:”
+ name);
}
propertyUtilsBean.setProperty(node, name,
new HashMap());
}
} else {
if (logger.isDebugEnabled()) {
logger
.debug(”descendThroughPoint(Object) - have not detected any collection membership .. lets recurse ….”);
}
// If we can think of any other Simple objects that we
// shouldn’t descend upon .. add them here.
if (!isIgnorable(property)
) {
// property = descendThroughNode(property, visited);
propertyUtilsBean.setProperty(node, name,
descendThroughNode(property, visited));
}
}
}
}
return node;
} catch (Throwable t) {
throw new RuntimeException(t);
}
}
/**
* Can we ignore the property? This method should be modified to just check
* if the class is annotated with the ∧ entity annotation.
*
* @param property
* @return
*/
private boolean isIgnorable(Object property) {
return (property == null) || (property instanceof String)
|| (property instanceof Double) || (property instanceof Long)
|| (property instanceof java.sql.Timestamp)
|| (property instanceof Date)
|| (property instanceof java.sql.Date);
}
@SuppressWarnings(”unchecked”)
private Object handleList(Object node, List visited) {
if (node instanceof PersistentBag) {
if (!((PersistentBag) node).wasInitialized()) {
return (List) new ArrayList();
}
}
List ret = new ArrayList();
for (Object o : (List) node) {
ret.add(descendThroughNode(o, visited));
continue;
}
return ret;
}
private String appendArgs(Object[] args) {
StringBuffer ret = new StringBuffer();
for (Object object : args) {
ret.append(”:”);
ret.append(object);
ret.append(”:”);
}
return ret.toString();
}
}
At last! a bandwidth throttler for mac os
August 20th, 2008
Couldn’t believe my eyes today when i found this little nugget, as a mac only company, this is a huge help! now that rusty unmanned PC will have to work twice as hard for its place in the office!!
check it our: www.charlesproxy.com/
Flex Camp London open for registration!
August 8th, 2008
We are giving a hand running Flex Camp London 08, check it out:
Flex Camp London 08 is a FREE, community-run event for everyone interested in Adobe Flex! Whether you’re just getting started with Flex or you’re an expert, Flex Camp aims to provide something for you.
We’ve lined up some of the most experienced Flex developers in the UK who will share their knowledge on everything from creating your first application, connecting to data, creating components and development best practices through to selecting an application framework for larger projects.
Flex Camp will also include a panel discussion, provide an opportunity for you to show off what you’re building in the Show & Tell open session and let you meet up with other developers to talk about Flex. We’ve also got some great prizes to give-away throughout the day, including a ticket to Adobe MAX in Milan, Adobe software and Flex training courses from Academy Class.
Flex Camp is on August 28th, 2-8pm at Conway Hall, London WC1 - register today at http://ria.meetup.com…
This is a FREE event, but you must be registered to attend and names will be taken at the door.
See you there!
The biggest stench of them all…
July 25th, 2008
Recently here at emak mafu we’ve been building an internal framework to help quickly get some of sites up and running, and have been taking our queues from the Flex framework, asWing and the CS3 components. The best part about this is you get to dive into many peoples code to see their best practices and how they approach the problem (and sometimes shamelessly imitate it). Sometimes you will see a little to-do here, or a quirky comment from a developer as they implement a little hack, but sometimes you begin to get a whiff of a coding smell. This is not to say these frameworks are far in advance of our own, but I’d like to share one whiff that is too pungent to ignore.
The culprit is one mx.controls.listClasses.ListBase, in particular the method collectionChangeHandler(). The first thing to mention is that this class is nearly 10,000 lines long, which is an issue in itself although with the asDoc comments it is easy to forgive this. The method collectionChangeHandler is a method which is 395 lines long, which anyone who has read Refactoring will tell you is suffering from a bad case of long method, which is recommends a method be no longer then 10 - 20 lines.
Now to totally geek out, I started to count the number of if, try.. catch, and for.. loops so I could make a better point of why the method needs refactoring, but after 36th if.. else, 3rd try.. catch and 5th for.. loop I gave up. It is impossible to decipher the functionality without chatting to the author, and in such an important base class as well, where any of this behavior may need to be overriden. Anybody else out there found any blunders?


