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…
[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:
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!