HTMLtext linking to actionscript functions

AS3 You can do it with a link event: html text would be: <a href='event:moveUp'>UP</a> listener on the field: myHTML.addEventListener(TextEvent.LINK, linkHandler); function linkHandler(event:TextEvent):void { trace(event.text); // traces 'moveUp' } See this page if that's not enough: http://blog.circlecube.com/2008/12/portfolio/asfunction-texteventlink-tutorial-for-as3-flash-html-link-to-call-actionscript-function-tutorial/ In as2 it was a bit different, see below: AS2: You can use htmlText to call AS functions.... Continue Reading →

for each – handy for arrays.

Pretty basic stuff here, but for each is quite handy for looping through an array that may hold more than one type of content for each (var o:Object in gridArray) { // do something } That'll pull out each object in gridArray for you to manipulate as o.

onReleaseOutside in AS3

There is no onReleaseOutside call in AS3. So, to get that, the best way is to, when your MOUSE_DOWN event function is called, to add a MOUSE_UP event listener to the stage. Then remove that listener when the event is triggered. eg. myBtn.addEventListener(MouseEvent.MOUSE_DOWN, downHandler): function downHandler(event:MouseEvent):void { stage.addEventListener(MouseEvent.MOUSE_UP, upHandler); // do whatever on mouseDown eg.... Continue Reading →

Convert number to hex code AS3

If you trace a colour you've input as 0xFFFFFF, it'll trace back as some big number (no time to do exmaple properly). If you need to say, then reuse this color number and put it back in to htmltext formatting for colour (which deals in hex) - you can use toString(16) to convert it back... Continue Reading →

Write to local drive with javascript – hta

This will create a text file 'text.txt' in the folder where test.hta is residing. Could use to create xml and config files with javascript for courses to manipulate later. <html> <head> <script language="javascript"> function WriteToFile() { try { var fso, s; fso = new ActiveXObject("Scripting.FileSystemObject"); /* s = fso.OpenTextFile("C:\\test.txt" , 8, 1, -2); */ s... Continue Reading →

Sending variables with an event – AS3

See this thread: http://stackoverflow.com/questions/792451/want-to-send-parameters-with-custom-dispatch-event Incase they remove it, public class YourEvent extends Event { public static const SOMETHING_HAPPENED: String = "somethingHappend"; public var data: Object; public function YourEvent(type:String, date: Object, bubbles:Boolean=false, cancelable:Boolean=false) { data = this.data; super(type, bubbles, cancelable); } override public function clone():Event { return new YourEvent (type, data, bubbles, cancelable); } }

Basic Image Loader in AS3

Basic wee loader which loads an image, then is put inside a container movieclip. // image loader var imageLoader:Loader = new Loader(); imageLoader.load(new URLRequest("thumbnails/example_thumb.jpg")); var myImage:MovieClip = new MovieClip(); myImage.addChild(imageLoader); addChild(myImage); If you want something to happen when it's loaded (like load the next one etc, slap a listener on the contentLoaderInfo beneath the loader.... Continue Reading →

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

Up ↑