Links in XML

  • nero2000
  • Born
  • Born
  • nero2000
  • Posts: 1

Post 3+ Months Ago

Hey! New here - need some help please :)

I'm loading an xml file into flash, like so:

Code: [ Select ]
<?xml version="1.0" encoding="UTF-8"?>

<loc>
<locations>
<p>
<a href="http://www.link.com">link one</a> <BR>
<a href="http://www.link.com">link two</a> <BR> 
<a href="http://www.link.com">link three</a><BR>
</p>
</locations>
</loc>


  1. <?xml version="1.0" encoding="UTF-8"?>
  2. <loc>
  3. <locations>
  4. <p>
  5. <a href="http://www.link.com">link one</a> <BR>
  6. <a href="http://www.link.com">link two</a> <BR> 
  7. <a href="http://www.link.com">link three</a><BR>
  8. </p>
  9. </locations>
  10. </loc>


but I want the links to open in a new window .. so I tried adding _blank after the link, and the text wouldn't even load into flash. How can I make these load in new windows?

Here's the code in flash:

Code: [ Select ]
loc_txt.html = true;
loc_txt.wordWrap = true;
loc_txt.multiline = true;
loc_txt.label.condenseWhite=true;

//load css
locations = new TextField.StyleSheet();
locations.load("_load/style.css");
loc_txt.styleSheet = locations;

//load in XML
locations = new XML();
locations.ignoreWhite = true;
locations.load("_xml/edit.xml");
locations.onLoad = function(success)
{
    if(success)
    {
        loc_txt.text = locations;
    }
}
  1. loc_txt.html = true;
  2. loc_txt.wordWrap = true;
  3. loc_txt.multiline = true;
  4. loc_txt.label.condenseWhite=true;
  5. //load css
  6. locations = new TextField.StyleSheet();
  7. locations.load("_load/style.css");
  8. loc_txt.styleSheet = locations;
  9. //load in XML
  10. locations = new XML();
  11. locations.ignoreWhite = true;
  12. locations.load("_xml/edit.xml");
  13. locations.onLoad = function(success)
  14. {
  15.     if(success)
  16.     {
  17.         loc_txt.text = locations;
  18.     }
  19. }



Thanks guys!
  • RedBMedia
  • Proficient
  • Proficient
  • User avatar
  • Posts: 315

Post 3+ Months Ago

What do you mean you added the "_blank" after the link?

Heres a proper anchor tag that will open in a new window:

<a target="_blank" href="http://www.link.com">link one</a>
  • Bogey
  • Genius
  • Genius
  • Bogey
  • Posts: 8416
  • Loc: USA

Post 3+ Months Ago

isn't the target "_new" if you want something to be opened in a new window or is XML different?

And it should be <a href="http://www.link.com" target="_new">Link</a> rather then <a target="_new" href="http://www.link.com">link</a>.
  • graphixboy
  • Control + Z
  • Mastermind
  • User avatar
  • Posts: 1828
  • Loc: In the Great White North

Post 3+ Months Ago

The order specification within the <a> tag shouldn't make any difference.

I believe acceptable target attributes are:

_blank
_new
_self
_parent
frameName


The big question here is if flash's limited ability to interpret html allows for the use of targets in external html. To be safe I would go with _blank. However, if that still doesn't work you may want to load the xml as attributes (not html tags) and use a getURL function which would look something like this.

Code: [ Select ]
<?xml version="1.0" encoding="UTF-8"?>
<linkList>
 <link url="http://www.link.com" text="Link Title" targ="_blank" />
 <link url="http://www.link.com" text="Link Title" targ="_blank" />
 <link url="http://www.link.com" text="Link Title" targ="_blank" />
</linkList>
  1. <?xml version="1.0" encoding="UTF-8"?>
  2. <linkList>
  3.  <link url="http://www.link.com" text="Link Title" targ="_blank" />
  4.  <link url="http://www.link.com" text="Link Title" targ="_blank" />
  5.  <link url="http://www.link.com" text="Link Title" targ="_blank" />
  6. </linkList>


and actionscript

Code: [ Select ]
var url = node.attributes.url;
var title = node.attributes.text;
var targ = node.attributes.targ;

onSomeAction = function(){
getURL(url,targ);
}
  1. var url = node.attributes.url;
  2. var title = node.attributes.text;
  3. var targ = node.attributes.targ;
  4. onSomeAction = function(){
  5. getURL(url,targ);
  6. }
  • Bogey
  • Genius
  • Genius
  • Bogey
  • Posts: 8416
  • Loc: USA

Post 3+ Months Ago

graphixboy wrote:
The order specification within the <a> tag shouldn't make any difference.


It does, at least it did for me. I tried that way once and ended up with an error.
  • ATNO/TW
  • Super Moderator
  • Super Moderator
  • User avatar
  • Posts: 23454
  • Loc: Woodbridge VA

Post 3+ Months Ago

Read this post carefully. I believe it will provide the answer you need
http://board.flashkit.com/board/showthread.php?t=691428

I had a difficult time doing this myself.
  • graphixboy
  • Control + Z
  • Mastermind
  • User avatar
  • Posts: 1828
  • Loc: In the Great White North

Post 3+ Months Ago

Bogey wrote:
It does, at least it did for me. I tried that way once and ended up with an error.


I think order does matter based on the doctype. However, flash is not a web browser. It has a very limited understanding of html instead it deals with html as xml with some named attributes.

Post Information

  • Total Posts in this topic: 7 posts
  • Users browsing this forum: No registered users and 3 guests
  • You cannot post new topics in this forum
  • You cannot reply to topics in this forum
  • You cannot edit your posts in this forum
  • You cannot delete your posts in this forum
  • You cannot post attachments in this forum
 
 

© 1998-2014. Ozzu® is a registered trademark of Unmelted, LLC.