All, I created the DropLabel.mxml component (that is attached for reference) for my AIR project, so now I can drag and drop item from a Grid on to the Label of the List item (and not add to the list) Awesome.
Once I had that solved, I added some code to handle what I wanted to happen in SQLite on the drop, which works great too. I then added a clickHandler to the Label (because it should be clickable too), so now it goes and gets that particular presentation (each list item is a presentation by the way) in SQLite and puts the results in an array collection, and that's great too. However, I can't assign that array collection to another bindable variable (type ArrayCollection too) previously declared (and heavily used) in the main application file while I'm in the DropLabel.mxml component (Flex is like "undefined, dude"). A little help...please? (About bubbling or sharing data between components, or something else that I need to understand?) I attached the DropLabel.mxml as a .txt file for reference. You'll see the issue in the clickHandler(); and it's probably laughably easy, but go easy on me. Thank you in advance everyone. : ) David
<?xml version="1.0" encoding="utf-8"?> <mx:Label xmlns:mx="http://www.adobe.com/2006/mxml" text="{data.pTitle}" dragEnter="draggedInto(event)" dragDrop="testDrop(event)" click="clickHandler(event)" width="220" textAlign="left" color="#ffffff" fontSize="12"> <mx:Script> <![CDATA[ import mx.controls.Alert; import mx.core.DragSource; import mx.managers.DragManager; import mx.events.DragEvent; import flash.data.SQLResult; import flash.filesystem.File; import flash.data.SQLStatement; import flash.data.SQLConnection; import flash.events.SQLEvent; //import flash.events.SQLErrorEvent; private function testDrop(event:DragEvent):void { if (event.dragSource.hasFormat("items")) { var itemsArray:Array = event.dragSource.dataForFormat("items") as Array; // breakpoint, examine itemsArray[0] sqlFile = File.applicationDirectory.resolvePath("presentations_v7.db"); sqlConn = new SQLConnection(); sqlConn.open(sqlFile, SQLMode.UPDATE); var sqlConn:SQLConnection; var sqlFile:File; var stmtSIP:SQLStatement = new SQLStatement(); stmtSIP.sqlConnection = sqlConn; stmtSIP.text = 'INSERT INTO presentationSlides ' + ' (pid,sid,sURL) ' + ' VALUES ' + '( "'+ this.data.pid + '", "'+ itemsArray[0].sid + '", "'+ itemsArray[0].source + '")'; stmtSIP.execute(); //Alert.show(itemsArray[0].sTitle + '\nadded to\n' + this.text); Alert.show('Slide added to\n' + this.text); } } private function clickHandler(event:MouseEvent):void { //trace("clicked!"); sqlFile = File.applicationDirectory.resolvePath("presentations_v7.db"); sqlConn = new SQLConnection(); sqlConn.open(sqlFile, SQLMode.READ); var sqlConn:SQLConnection; var sqlFile:File; var stmtSPS:SQLStatement = new SQLStatement(); stmtSPS.sqlConnection = sqlConn; stmtSPS.text = 'SELECT sURL As source, pid, sid, sort FROM presentationSlides WHERE pid = ' + '"' + this.data.pid + '"'; stmtSPS.execute(); var resultSPS:SQLResult = stmtSPS.getResult(); //presentationsSlidesAC = new ArrayCollection(resultSPS.data); this assignment is a no go----->//currentAC = presentationsSlidesAC; Alert.show('Now displaying ' + this.text); } private function draggedInto(event:DragEvent):void { DragManager.acceptDragDrop(this); } ]]> </mx:Script> </mx:Label>