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)); tempNum += 3; // offset for preloader, menu etc. before sections. and the sections start at 1 not 0. gotoAndStop(tempNum); }
http://www.wuup.co.uk/as3-quick-tips-string-to-number-conversion-and-vice-versa/
Tech Reference: AS3
Leave a Reply