/ Published in: ActionScript 3
If you need to read data files from Adobe After Effects in Flash and want to parse them... AAE exports every scene from frame 0, no matter where on the movie the scene starts. This is a good and easy way to fix frame numbering and make it easier for Flash to parse/read them.
Expand |
Embed | Plain Text
package { import flash.display.MovieClip; import flash.display.*; import flash.events.*; import flash.net.*; import flash.net.URLRequest; public class Main extends MovieClip { /* Author: Chrysto Panayotov ( burnandbass[at]gmail.com ) Affter effects data files to AS3 conversion; */ private var finalData:String = ""; public function Main() { //add here path to the after effects data file var a:URLLoader = new URLLoader(new URLRequest("temp.txt")); a.addEventListener(Event.COMPLETE, onComplete); } private function onComplete(event:Event):void{ var tempArray:Array = String(event.target.data).split("\n"); //add here the frame the scene occure var startNum:Number = 11; for(var i:uint = 0; i<tempArray.length; i++ ){ var line:String = String(tempArray[i]).replace(/^\s+|\s+$/g, ''); line.replace(" ", " "); var startRegExpress:RegExp = /^\D/g; var sectionRegExpress:RegExp = /^Effects/g if( ! startRegExpress.test( line )){ var sections:Array = line.split("\t"); if(sections[0] != undefined && sections[1] != undefined && sections[2] != undefined){ var _frameNum:Number = Math.ceil(Number( sections[0] )); var _pointX:Number = sections[1]; var _pointY:Number = sections[2]; _frameNum = _frameNum + startNum; finalData += _frameNum + " : " + _pointX + " , " + _pointY + "\n"; } } else if(sectionRegExpress.test( line ) ) { finalData += "\n\n" + line + "\n"; } } trace(finalData); } }//end }
You need to login to post a comment.
