Archive for May, 2010
Code Snippet - using as3Signals to delay function call by a frame no comments
Sometimes there’s a need to delay a function call by a frame (normally to insure a rendering phase has been completed). Easily done with Signals:
import org.osflash.signals.natives.NativeSignal;
var delayFrameSignal:NativeSignal = new NativeSignal(this, Event.ENTER_FRAME, Event);
delayFrameSignal.addOnce(delayFrameCall);
function delayFrameCall(e:Event):void
{
trace("called");
}
FCSS - Loading/merging external css files and loading external fonts (with source) no comments
Here is a proof of concept for using FCSS to load and merge css files externally for multilingual support. It could easily be integrated into a MVC(S) application but unfortunately I can’t share that code at this time. If you haven’t used FCSS take a look as it has some really handy features http://fcss.flashartofwar.com/. The demo may not look like much but don’t let that put you off how it can be used.
The basic process:
1. Load a default css file
2. Load a locale specific css file (could come from a flashVar or configuration setting)
3. Merger the 2 css files (FCSS handles this)
4. Get a list of used fontNames (with an optional rule to only return ones that have embedFonts:true)
5. Load font swfs ( this could easily be enhanced to work with a fontmapping configuration)
6. Use FCSS’s API for getting CSS textFormatting into a TextField (you could extend TextField to CSSTextField or the likes for real world applications)
7. Optionally use the css to set custom properties to manipulate positioning/layout of assets etc
Known issues:
· The CSS for fonts can only be; font, fontFace or font-face (FCSS hasn’t implemented font-family yet)
· The value of the font must not have quote “|’ around it i.e These will NOT work; font:”Arial”, font:’Arial’. This WILL work font:Arial (Need to log a bug with FCSS on this one)
Demo:
http://www.darklump.co.uk/experiments/fcss/loading-and-merging/
Source: (flash builder project)
http://www.darklump.co.uk/experiments/fcss/loading-and-merging/srcview/
Happy Days…