CSS Stylesheets for htmlText fields in Flash AS3

You can make your htmltext fields have highlights etc by applying some minor CSS styles to the htmltext fields in Flash. var theCSS:StyleSheet = new StyleSheet(); theCSS.setStyle("a:link", {color:'#361B59', textDecoration:'underline'}); theCSS.setStyle("a:hover", {color:'#532C8F', textDecoration:'none'}); contentField.styleSheet = theCSS; More things you can do: http://www.adobe.com/livedocs/flash/9.0/ActionScriptLangRefV3/flash/text/StyleSheet.html

HTML Characters in XML

I've been doing some work with XML in AS3 and needing to have the XML contain HTML characters for an htmltext field in Flash - for links and lists etc. Few ways to approach that: <![CDATA[ "Rampant <'s and &'s in the XML fields that XML ignores due to special CDATA tags within the fields"... Continue Reading →

Loading XML into flash as an XML object

loading XML into flash as an XML object // xml loader var xmlLoader:URLLoader = new URLLoader(); var xmlData:XML = new XML(); xmlLoader.addEventListener(Event.COMPLETE, loadXML); xmlLoader.load(new URLRequest("leadership_development_framework.xml")); function loadXML(event:Event):void { xmlData = new XML(event.target.data); } Further to that, once you've your xmlData filled, you can chop it up with XMLList to make sub-listings for easier management. For... Continue Reading →

AS3 Preloader

Found a good piece of code that is just a straight forward, simple barebones preloader addEventListener(Event.ENTER_FRAME, preloaderFunction); function preloaderFunction(event:Event) :void { var bytestotal = stage.loaderInfo.bytesTotal; var bytesloaded = stage.loaderInfo.bytesLoaded; var pctLoaded:int = bytesloaded * 100 / bytestotal; preloader.loadingField.text = String(pctLoaded) + "%"; if (bytesloaded >= bytestotal) { removeEventListener(Event.ENTER_FRAME, preloaderFunction); nextFrame(); } } Source: MikeTheVike at:... Continue Reading →

Links in AS3 – getURL / URLRequest

I know what you're thinking - why use getURL like in AS2 when you can write all this for a simple link: import flash.net.URLLoader; import flash.net.URLRequest; import flash.net.navigateToURL; var emailAddress:String = "noone34343@nowhere453646.com"; submitIdeaBtn.addEventListener(MouseEvent.CLICK, submitBtnIdeaHandler); function submitBtnIdeaHandler(event:MouseEvent):void { var mailString:String = "mailto:" + emailAddress + "?subject=Idea&body=This idea will help " + field0.text + " and is... Continue Reading →

startDrag bounds in AS3

The startDrag function in AS3 is a little different from in AS2: you define a rectangle from the initial location that you're starting the drag from rather than the absolute bounds like in AS2. So the code looks like below: import flash.geom.Rectangle; myMC.startDrag(false, new Rectangle(topX, topY, withToDrag, heightToDrag);

duplicateMovieClip in AS3

There're a lot of difficult ways I've seen online to duplicateMovieClip in AS3, when it can actually be quite easy: make the clip you wish to duplicate a class. Right-click on it in the library and export it as a class. Then when you want to duplicate it, just create a new movieclip that is... Continue Reading →

Tinting with AS3

import fl.motion.Color; //create a Color object var c:Color=new Color(); //set the color of the tint and set the multiplier c.setTint(0xff0000, 0.8); //apply the tint to the colorTransform property of //the desired MovieClip/DisplayObject mc.transform.colorTransform=c; //mc is a MovieClip Source: http://www.cainmedia.com/articles/9/tinting-with-actionscript-3/

Using a string as an integer and vice versa

It's quite simple. Say you've got a menu whose textfields go field0, field1 etc. as instance names, and you want to reference it's final character as the menu navigation id it'll use to navigate to that location. //code for the navigation buttons addEventListener(TextEvent.LINK, navClick); function navClick(event:TextEvent):void { var field:String = event.target.name; var tempNum:Number = Number(field.charAt(field.length-1));... Continue Reading →

Loading an external movie clip in AS3

You can't just use the loadMovie function, oh no! But this works perfectly: import flash.net.URLRequest; import flash.display.Loader; import flash.events.Event; import flash.events.ProgressEvent; function startLoad() { var mLoader:Loader = new Loader(); var mRequest:URLRequest = new URLRequest(“MouseActions.swfâ€); mLoader.contentLoaderInfo.addEventListener(Event.COMPLETE, onCompleteHandler); mLoader.contentLoaderInfo.addEventListener(ProgressEvent.PROGRESS, onProgressHandler); mLoader.load(mRequest); } function onCompleteHandler(loadEvent:Event) { addChild(loadEvent.currentTarget.content); } function onProgressHandler(mProgress:ProgressEvent) { var percent:Number = mProgress.bytesLoaded/mProgress.bytesTotal; trace(percent); } startLoad()... Continue Reading →

Proudly powered by WordPress | Theme: Baskerville 2 by Anders Noren.

Up ↑