# Why is this dictionary not working HELP,HELP

**URL:** https://forum.kirupa.com/t/why-is-this-dictionary-not-working-help-help/329157
**Category:** flash
**Created:** [July 26, 2012, 4:07pm UTC](https://forum.kirupa.com/t/why-is-this-dictionary-not-working-help-help/329157 "2012-07-26T16:07:50Z")
**Posts on this page:** 1
**Page:** 1

<div class="post-metadata">

### Author: ![m2244](https://avatars.discourse-cdn.com/v4/letter/m/ac91a4/32.png) [@m2244](https://forum.kirupa.com/u/m2244)
#### Post date: [July 26, 2012, 4:07pm UTC](https://forum.kirupa.com/t/why-is-this-dictionary-not-working-help-help/329157/1 "2012-07-26T16:07:50Z")

</div>

The 2 traces at the bottom output this:

//nameX  
//undefined

So, the first trace outputs what I expected but the second trace comes back as undefined. I am trying to access text which I assigned to the drop target, but it does not work

Can anyone help me here?

```auto

var refDict:Dictionary = new Dictionary;
stop();
 / *************Set up the questions with text from the XML file.********************* /
 for(var i:int = 0; i < xmlFile.questions.question.length(); i++)
 { 
  var quesBack:mcQuesBack = new mcQuesBack();
  quesBack.x = 20;
  quesBack.y = 20 + (i * 60);
  quesBack.width = 550;
  quesBack.name = String(i);
  refDict[quesBack] = String(xmlFile.questions.question*.answer);
  
  var quesText:TextField = new TextField();
  quesText.defaultTextFormat=formatNormal;
  quesText.multiline=true;
  quesText.selectable=false;
  quesText.mouseEnabled = false;
  quesText.wordWrap=true;
  quesText.width=400;
  quesText.x = 20;
  quesText.y = 20 + (i * 60);
  quesText.autoSize=TextFieldAutoSize.LEFT;
  quesText.name = String(i); // Not sure why I did this.
  quesText.text = xmlFile.questions.question*.content;
 
  stage.addChild(quesBack);
  stage.addChild(quesText);
 }
 
 / *************Set up the draggers with text from the XML file.********************* /
 for(var n:int = 0; n < xmlFile.draggers.answer.length(); n++)
 {
  var ansBacking:mcDragger = new mcDragger();
  ansBacking.x = 650;
  ansBacking.y = 30 + (n * 70);
  ansBacking.buttonMode = true;
  ansBacking.txtAnswer.text = xmlFile.draggers.answer[n].content;
  ansBacking.mouseChildren = false;
  ansBacking.name = xmlFile.draggers.answer[n].content;
  ansBacking.addEventListener(MouseEvent.MOUSE_DOWN, startDragging);
  stage.addChild(ansBacking);
 }
 
function startDragging(evt:MouseEvent):void
{
 evt.currentTarget.removeEventListener(MouseEvent.MOUSE_DOWN, startDragging);
 origLocatX = evt.currentTarget.x;
 origLocatY = evt.currentTarget.y;
 evt.currentTarget.startDrag(false);
 evt.currentTarget.parent.addChild(evt.currentTarget);
 evt.currentTarget.addEventListener(MouseEvent.MOUSE_UP, onDrop);
}
function onDrop(evt:MouseEvent):void
{
 
 evt.currentTarget.removeEventListener(MouseEvent.MOUSE_UP, onDrop);
 evt.currentTarget.addEventListener(MouseEvent.MOUSE_DOWN, startDragging);
 
 evt.currentTarget.stopDrag();
 
 if([EMAIL="xmlFile.draggers.@multiUse"]xmlFile.draggers.@multiUse[/EMAIL] == true)
 {
  evt.currentTarget.x = origLocatX;
  evt.currentTarget.y = origLocatY;
  
 }
 else
 {
  stage.removeChild(DisplayObject(evt.currentTarget));
 }
 
 //if(evt.currentTarget.dropTarget != null)
 if(evt.currentTarget.hitTestObject)
 {
  trace(evt.currentTarget.dropTarget.name);
  trace(refDict[evt.currentTarget.dropTarget]);
 }
 
} 

```
