var imageData:ByteArray = new ByteArray();
var headshotStatement:SQLStatement = new SQLStatement();
headshotStatement.sqlConnection = dbConnection;
var headshotStr:String = "SELECT headshot FROM ac_images WHERE id = " + idx;
headshotStatement.text = headshotStr;
headshotStatement.execute();
Error references the final line in this block. I found a few references online where people are unable to select a BLOB using AS3 that has had data inserted into it from an external program, which is my exact situation.
Exact error trace is:
RangeError: Error #2006: The supplied index is out of bounds.
at flash.data::SQLStatement/internalExecute()
at flash.data::SQLStatement/execute()
at edu.bu::DataManager/getHeadshotImageData()[omitted/DataManager.as:396]
at edu.bu::CustomStudentProfileEditorWindow/editStudent()[omitted/CustomStudentProfileEditorWindow.mxml:194]
at edu.bu::CustomStudentProfileEditorWindow/profileEditor_completeHandler()[omitted/CustomStudentProfileEditorWindow.mxml:37]
at edu.bu::CustomStudentProfileEditorWindow/___CustomStudentProfileEditorWindow_Window1_creationComplete()[omitted/CustomStudentProfileEditorWindow.mxml:9]
at flash.events::EventDispatcher/dispatchEventFunction()
at flash.events::EventDispatcher/dispatchEvent()
at mx.core::UIComponent/dispatchEvent()[E:\dev\4.x\frameworks\projects\framework\src\mx\core\UIComponent.as:12528]
at mx.core::UIComponent/set initialized()[E:\dev\4.x\frameworks\projects\framework\src\mx\core\UIComponent.as:1627]
at mx.managers::LayoutManager/doPhasedInstantiation()[E:\dev\4.x\frameworks\projects\framework\src\mx\managers\LayoutManager.as:759]
at mx.managers::LayoutManager/doPhasedInstantiationCallback()[E:\dev\4.x\frameworks\projects\framework\src\mx\managers\LayoutManager.as:1072]
Any ideas what could be wrong with the data that is causing AS3 to choke?
Edit: I've tried to insert the same data into a binary type field using SQLite Manager 3.5 for OS X with the same result. I'm working with a JPG, going to try other image formats, though I can't begin to guess which supplied index is out of bounds given that trying to jump to the definition just states that it's getting it from a SWC and I can't see. Grasping at straws before I distribute the data in a zip and decompress it on the fly, which I don't want to do.
Edit 2, Workaround Edition: For now, I've written a quick MXML Window that prompts for the images and inserts the data into the database. Would still love to know why another application can't store BLOB data in a way that SQLStatement understands. I'm essentially setting up a few buttons that prompt for file paths to the images I want in the database, reading them in with readBytes() to a ByteArray, and storing that into the SQLite db using SQLStatement. I am then able to read the image back without difficulty.
Edit 3: Here is an image of the table structure. Note, this same table is being used successfully when I have Flash do the database image insert, as opposed to some other tool which properly stores the data in the BLOB field for every other application but Flash...