Belden
Belden

Reputation:

Checking if an item exists in Action Script

Sorry, I've never done AS before, so I apologize for the basic question. There is a line in this file I am trying to modify:

var media:Namespace = rssXML.channel.item[i].namespace("media");

I'm just trying to check to see if it exists and if it has a value?

I know in PHP it would be

if(isset(rssXML.channel.item[i].namespace("media") && !empty(rssXML.channel.item[i].namespace("media")) {

//Do Something

}

What would be the AS equivalent?

Upvotes: 2

Views: 2333

Answers (2)

typeoneerror
typeoneerror

Reputation: 56958

All AS classes extend Object which has a hasOwnProperty() test which returns a boolean if a property with the name exists. Then you can test if (property) or if (property == null).

http://livedocs.adobe.com/flash/9.0/ActionScriptLangRefV3/Object.html#hasOwnProperty()

Upvotes: 0

SpliFF
SpliFF

Reputation: 38976

if (variablename) { // it's there } else { // it's not }

Upvotes: 2

Related Questions