Typically you get '5005: Unknown error optimizing byte code' message in Flash-based applications made up of thousands of lines of code, numerous large objects, or a great number of small classes. You can fix this by increasing the Java VM memory which I think you have already done. The ReferenceError: Error #1065 occurs when you do not declare your class as public. Private classes can not be used as document classes because they are out of the class package and therefore are not a part of the private scope. Try this out and see if it helps.