0

My question today deals with checking an XML file for a specific node.

Example:

<vid 
flv="videoName" 
thumb="thumbnail.jpg"
title="Video Title" 
logo="Path to logo here">
</vid>

<vid 
flv="videoName" 
thumb="thumbnail.jpg"
title="Video Title" 
</vid>

The first vid node contains a path to a logo graphic, I then need to check in my ActionScript if there is a logo there or not, and to do something if there is(display the logo)

Now below is the code I need help with, I can trace out the logo path so I thought I could run a simple if/else to check if there is anything in that node and if so to do something:

private function thumbOver(e:MouseEvent = null):void
{
trace("\r");
trace("YOU ROLLED OVER THUMBNAIL: " + e.target.id);
trace("PLAY THIS VIDEO: " + tabData[tabID].video[e.target.id].@flv);
trace("THE VIDEO TITLE: " + tabData[tabID].video[e.target.id].@title);
trace("HAS LOGO? " + tabData[tabID].video[e.target.id].@logo);

if (tabData[tabID].video[e.target.id].@logo == null)
{
    trace("No logo here");
            // Don't do anything
} else {
    trace("Does have Logo");
            // Code to display Logo
}

    /*var lgo:Bitmap = loader.getBitmap(tabData[tabID].video[e.target.id].@logo);
    lgo.width  = 78;
    lgo.height = 44;
    lgo.x = 0;

    logoPlace.addChild(lgo);
    thumbRollmc.addChild(logoPlace);*/

descriptionMaker(tabData[tabID].video[e.target.id].@title);
}

Now I've tried everything, but it will always trace out "Does have a logo" no matter what I do. I tried:

 if (tabData[tabID].video[e.target.id].@logo == "")

 if (tabData[tabID].video[e.target.id].@logo == null)

However I get the same results, what should my approach to this problem be?

1 Answer 1

2
if (tabData[tabID].video[e.target.id].hasOwnProperty("@logo"))
Sign up to request clarification or add additional context in comments.

2 Comments

OMG thanks that was it! :D I'm not that well verse with all the XML syntax... I love this site!
hasOwnProperty is a method of the Flash Object class, so you can use that on pretty much any class. Very handy.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.