-
Reference XML object from value saved as string
I'm trying to access an XMLList object from an href in a textField.
For instance, I have an object: plogXML.day[0].file[0].@url. I want to be able to reference that object when the user clicks on a hypertext link in a text field.
For instance, <a href="event: plogXML.day[0].file[0].@url">Text to click</a>.
Clicking on the link calls the event handler, but how do I access the corresponding XMLList object from a string value. I can do trace(this["plogXML"]) but not further down the food chain than that.
As always, any help, yada, yada,
Jennifer
-
Senior Member
You mean this:
PHP Code:
list.htmlText="<a href=\"event: plogXML.day[0].file[0].@url\">Text to click</a>"; addEventListener (TextEvent.LINK,linkHandler); function linkHandler (linkEvent:TextEvent):void { trace(linkEvent.text); }
- The right of the People to create Flash movies shall not be infringed. -
-
Aw, you don't mean the link event can send an object!?!?
I guess I just assumed the only thing a link event could send was a text string (which I think was the case with asfunction).
Stupid, stupid me. I should have tested. Thanks CI.
Jennifer
-
Hm, no, I think my original suspicion was right. The link event does send a string, thus the linkEvent.text. There's still no way to evaluate (gosh, I sure miss eval()) the string as an object.
Please tell me if I'm missing something here.
Jennifer
PS And as always, I appreciate any reply. Even those replies that don't prove -- um, useful -- often provoke another avenue of inquiry.
-
Senior Member
Of course it is text, but you can cast it as XMLList. I have not tested if this works. I leave it to you
- The right of the People to create Flash movies shall not be infringed. -
-
Thanks for the clarification, CI. I have tried casting it as an XMLList to no avail.
If evt.text == "plogXML.day[0].file[0].@url", then trace(this[evt.text]) just returns undefined.
If evt.text == "plogXML", then trace(this[evt.text]) returns the entire XMLList, but I can't go any deeper in the hierarchy.
Trying something like var temp:XMLList = new XMLList(evt.text) just assumes I'm trying to create a new, badly formed XMLList.
And trace(evt.text as XMLList) just returns null.
Usually all I get back from my trace statement is either the text string, undefined or null and not an outright error.
I suspect it's not possible to evaluate a string as a reference to an XMLList object because that functionality is already being used to evaluate a string as an XMLList object.
I'm trying to create a hierarchical menu using a textField with hrefs that trigger TextEvent.LINK actions. But I think I'll just go back to basically emulating what the Adobe supplied scrollable List component does -- creating objects into which other object values can be saved. Which is basically just like a menu that I already created in Flash MX. I just thought that using a text field was a more elegant approach.
Oh well, live and learn.
JJP
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|