# Reading XML element as MovieClip

**URL:** <https://forum.kirupa.com/t/reading-xml-element-as-movieclip/285709>\
**Category:** flash\
**Created:** [April 4, 2009, 1:35pm UTC](https://forum.kirupa.com/t/reading-xml-element-as-movieclip/285709 "2009-04-04T13:35:51Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![bhnh](https://avatars.discourse-cdn.com/v4/letter/b/eb8c5e/32.png) [@bhnh](https://forum.kirupa.com/u/bhnh)\
**Post date:** [April 4, 2009, 1:35pm UTC](https://forum.kirupa.com/t/reading-xml-element-as-movieclip/285709/1 "2009-04-04T13:35:51Z")

</div>

I’m running into what I suspect is an elementary problem.

On the stage of an .fla I have three MovieClips: square, triangle and line. I reference them in a simple xml document…

```auto

[COLOR=#008080]<?xml version="1.0" encoding="UTF-8"?>[/COLOR]
[COLOR=#0000ff]<[/COLOR][COLOR=#800000]testing[/COLOR][COLOR=#0000ff]>[/COLOR]
[COLOR=#0000ff]<[/COLOR][COLOR=#800000]objects[/COLOR][COLOR=#0000ff]>[/COLOR]
[COLOR=#0000ff]<[/COLOR][COLOR=#800000]clip[/COLOR][COLOR=#0000ff]>[/COLOR] square [COLOR=#0000ff]</[/COLOR][COLOR=#800000]clip[/COLOR][COLOR=#0000ff]>[/COLOR]
[COLOR=#0000ff]<[/COLOR][COLOR=#800000]clip[/COLOR][COLOR=#0000ff]>[/COLOR] triangle [COLOR=#0000ff]</[/COLOR][COLOR=#800000]clip[/COLOR][COLOR=#0000ff]>[/COLOR]
[COLOR=#0000ff]<[/COLOR][COLOR=#800000]clip[/COLOR][COLOR=#0000ff]>[/COLOR] line [COLOR=#0000ff]</[/COLOR][COLOR=#800000]clip[/COLOR][COLOR=#0000ff]>[/COLOR]
[COLOR=#0000ff]</[/COLOR][COLOR=#800000]objects[/COLOR][COLOR=#0000ff]>[/COLOR]
[COLOR=#0000ff]</[/COLOR][COLOR=#800000]testing[/COLOR][COLOR=#0000ff]>[/COLOR]

```

The class file tied to the .fla reads as follows:

```auto
package{
 import flash.display.*;
 import flash.events.*;
 import flash.net.URLRequest;
 import flash.net.URLLoader;
 
 public class ImportXMLClip extends MovieClip{
  private var ldr:URLLoader;
  private var file:XML;
  private var req:URLRequest;
  public var mc:MovieClip;
 
  public function ImportXMLClip(){
   file = new XML();
   req = new URLRequest("clipDemo.xml");
   ldr = new URLLoader(req);
   ldr.addEventListener(Event.COMPLETE, loadedUp);
  }
 
  function loadedUp(e:Event){
   file = XML(e.target.data);
   trace("Data loaded");
   trace(file.objects.clip[1]);
   mc = MovieClip(file.objects.clip[1]);
   mc.addEventListener(Event.ENTER_FRAME, spin);
  }
 
  function spin(e:Event){
   e.target.rotation += 5;
  }
 }
}

```

When I run this I get the following error…  
TypeError: Error #1034: Type Coercion failed: cannot convert XML@105087c1 element \<clip\> to flash.display.MovieClip.

The question is how do I identify the XML element as a MovieClip? Many thanks in advance!
