Alex,

I added parentDocument at line 76, and the "problems" in Flex Builder
went away and it compiled and ran, but upon click at runtime:

ReferenceError: Error #1056: Cannot create property currentAC on iSlides.
at
DropLabel/clickHandler()[C:\work\clients\unboundary\presentationTool_v4.0\src\DropLabel.mxml:76]
at
DropLabel/___DropLabel_Label1_click()[C:\work\clients\unboundary\presentationTool_v4.0\src\DropLabel.mxml:6]

<paste reference code>
<?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.collections.ArrayCollection;

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"); */
sqlFile = File.documentsDirectory.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!");
var sqlFile:File;
var sqlConn:SQLConnection;
/* sqlFile = File.applicationDirectory.resolvePath(
"presentations_v7.db"); */
sqlFile = File.documentsDirectory.resolvePath(
"presentations_v7.db");
sqlConn = new SQLConnection();
sqlConn.open(sqlFile, SQLMode.READ);

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();
var presentationsSlidesAC:ArrayCollection = new
ArrayCollection(resultSPS.data);
line 47--->parentDocument.currentAC = presentationsSlidesAC;
Alert.show('Now displaying ' + this.text);
}

private function draggedInto(event:DragEvent):void
{
DragManager.acceptDragDrop(this);                    
}

]]>
</mx:Script>

</mx:Label>



  ----- Original Message -----
  From: "Alex Harui"
  To: "flexcoders@yahoogroups.com"
  Subject: RE: [flexcoders] data (array collections) in main
  application and components available to each other...how?
  Date: Sun, 8 Feb 2009 22:08:24 -0800

  Try parentDocument.currentAC

  Alex Harui

  Flex SDK Developer

  Adobe Systems Inc.

  Blog: http://blogs.adobe.com/aharui

  From: flexcoders@yahoogroups.com [mailto:flexcod...@yahoogroups.com]
  On Behalf Of David Kramer
  Sent: Sunday, February 08, 2009 8:31 PM
  To: flexcoders@yahoogroups.com
  Subject: [flexcoders] data (array collections) in main application
  and components available to each other...how?

  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


  

Reply via email to