Thursday 23 June 2011

Thursday 16 June 2011

AS3 - Embedding fonts issue

If the font is not appearing then try adding this line to the complier arguments.


-managers flash.fonts.JREFontManager flash.fonts.BatikFontManager flash.fonts.AFEFontManager


also try adding this to the embed tag


embedAsCFF="false"


http://livedocs.adobe.com/flex/3/html/help.html?content=fonts_06.html

Friday 10 June 2011

AS3 - HTML Superscript characters

In order to use superscript characters you need to embed the superscript font and call the font face when needed.


Register font



[Embed(source="/../resource/font/ggsupersans.ttf", 
mimeType="application/x-font-truetype", 
fontName="SuperSans", 
fontWeight="normal", 
fontStyle="regular", 
advancedAntiAliasing="true" )]
private var SuperSans : Class;


Font.registerFont( SuperSans );


Using Superscript Characters


<font face="SuperSans" >&#174;</font>


Download
www.fahimchowdhury.com/files/ggsupersans.ttf

Wednesday 8 June 2011

Flash ClickTag

for a clickTag all you need to do is add script.


on (release) { if (_root.clickTAG.substr(0,5) == "http:") { getURL(_root.clickTAG, "_blank"); } }

Friday 3 June 2011

AS3 - Child listening to Parent Dispatches

To get a child object to listen to events dispatched by the parent the parent dispatches an event which bubbles and the child listens for the event on the stage.


Child Code:


if (stage)
{
init ();
} else
{
addEventListener (Event.ADDED_TO_STAGE, init);
}
function init (evt:Event = null):void
{
removeEventListener (Event.ADDED_TO_STAGE, init);
stage.addEventListener("messageToChild", messageFromParent)
//trace("init _");
}

function messageFromParent(event:Event){
trace("MESSAGE from parent - go to CTA");
gotoAndStop("CTA");
}



Parent Code:


function playCTA():void {
ExpandingComponent.collapse();
dispatchEvent(new Event("messageToChild", true))
;

}

Thursday 2 June 2011

AS3 - Round Decimals

To round a decimal number to the a specific decimal point you can use either the 'toFixed' or 'toPrecision' which are Number methods. 



var myNum:int = new int(3.454954849584)
myNum.toFixed(3);
trace(myNum); // 3.454


You can also do precision based decimal rounding with the toPrecision, this will round the last decimal outside the length parameter.


myNum.toPrecision(3);
trace(myNum); // 3.455;


Old-Skool way (does not round chopped off numbers)


2 decimal places:
value = int(( yourNumber ) * 100 ) / 100; 


3 decimal places:
value = int(( yourNumber ) * 1000 ) / 1000;