I took your advice and worked up some code. I'm having problems fetching the XML in my ActionScript though. Any help?
Here's my XML:
<?xml version='1.0' encoding='UTF-8'?>
<feed xmlns='http://www.w3.org/2005/Atom'xmlns:openSearch='http://a9.com/-/spec/opensearch/1.1/'
xmlns:gml='http://www.opengis.net/gml'xmlns:georss='http://www.georss.org/georss'xmlns:media='http://search.yahoo.com/mrss/' xmlns:batch='http://schemas.google.com/gdata/batch'xmlns:yt='http://gdata.youtube.com/schemas/2007'xmlns:gd='http://schemas.google.com/g/2005'>
<entry gd:etag='W/"C0AMRn47eCp7ImA9WxRQGUw."'>
<media:group>
<media:thumbnail url='http://img.youtube.com/vi/videoid/default.jpg' height='35' width='44'yt:name='default'/>
<yt:videoid>Py4tMHhkPtM</yt:videoid>
</media:group>
<entry>
</feed>
AS3
// Initialize the XML, place the xml file name, initialize the URLRequest
// put URLRequest into a new URLLoader, and add event listener on
// myLoader listening for when the XML loading is complete
var myXML:XML = new XML();
var XML_URL:String = "thumbnailLoadXML.xml";
var myXMLURL:URLRequest = new URLRequest(XML_URL);
var myLoader:URLLoader = new URLLoader(myXMLURL);
myLoader.addEventListener("complete", xmlLoaded);
// Create the xmlLoaded function
function xmlLoaded(event:Event):void {
// Place the xml data into the myXML object
myXML = XML(myLoader.data);
// Initialize and give var name to the new external XMLDocument
var xmlDoc:XMLDocument = new XMLDocument();
// Ignore spacing around nodes
xmlDoc.ignoreWhite = true;
// Define a new name for the loaded XML that is the data in myLoader
var menuXML:XML = XML(myLoader.data);
// Parse the XML data into a readable format
xmlDoc.parseXML(menuXML.toXMLString());
for each (var entry:XML in myXML.entry){
var ytthumbnail1:String = entry.thumbnail.toString();
}
my_thumb1.addChild(ytthumbnail1);
}.
Sorry if it's not clear. I did my best.
This isn't doing ANYTHING. I don't see any problems in my XML, so it has to be the AS3. I've never worked with these nodes, so I'm guessing my problem is that I'm calling them wrong (I've underlined the main part where I'm positive the code is wrong). I need a spot here. Also, pointing out anything else I may have overlooked, will help a big deal as well.
the error I get: "1067: Implicit coercion of a value of type String to an unrelated type flash.display:DisplayObject.
my_thumb1.addChild(ytthumbnail1) "
thnx --
You received this message because you are subscribed to the Google Groups "YouTube APIs Developer Forum" group.
To post to this group, send email to youtube-api-gdata@googlegroups.com.
To unsubscribe from this group, send email to youtube-api-gdata+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/youtube-api-gdata?hl=en.
No comments:
Post a Comment