5 Replies Latest reply on Dec 13, 2007 2:55 PM by mcadle

    addChild() to a canvas get object name?

    mcadle Level 1
      So once you add an object to a canvas via drag drop and the addChild() method, how do you get that objects flex assigned name? When you move it, you can call event.dragInitiator.name and it will tell you the childs name. I need that name the moment the user drops it. Here is the code that I have:

      if(event.dragSource.hasFormat("items"))
      {
      var items:Array = event.dragSource.dataForFormat("items") as Array;
      trace(items[0].PHOTO);
      var img:Image = new Image()
      img.x=event.localX
      img.y=event.localY
      img.source=items[0].PHOTO
      img.addEventListener(MouseEvent.MOUSE_MOVE,dragIt);
      cvs.addChild(img);
      // What is this childs name now? OR After it has been dropped, how do you get its source from img.source?
      }

      So as I said in the comment, if you can't get the childs name, after the drop, can you get the childs original source, i.e. the actual path - images/photo.jpg?