AS/XML Relationship in defining links

  • Strikeplate
  • Born
  • Born
  • Strikeplate
  • Posts: 2

Post 3+ Months Ago

Greetings.

New to the forum and searching for this answer but thought I'd post it as a topic as well. Just getting into using XML with my flash and have a simple (I think) question. When defining links I see a lot of XML which looks something like:

<sample>
<button title="Apples" image="images/applebtn.jpg" link="http://www.iloveapples.com/" target="_self">
</sample>

Of course these are links to external URL's. What I want to be able to do is make this sample button link (gotoAndPlay) to a frame label on the main timeline within the same .fla. So the example above would change to something like:

<sample>
<button title="Apples" image="images/applebtn.jpg" link="apples">
</sample>

It would also be alright if it were a frame number or if it had to call to a movieclip. It would be appreciated if someone could point me in the right direction on this forum or elsewhere or even supply a bit of direct assistance if feeling generous.

Thanks in advance.
  • graphixboy
  • Control + Z
  • Mastermind
  • User avatar
  • Posts: 1828
  • Loc: In the Great White North

Post 3+ Months Ago

Well its generally bad practice to target a frame by number (what if something changes and your numbers are suddenly all off?) However, you can place anything in your xml and have flash do something with it.

For example
Code: [ Select ]
gotoAndPlay(xmlNode.attributes.link);

// or

getURL(xmlNode.attributes.link, xmlNode.attributes.target);
  1. gotoAndPlay(xmlNode.attributes.link);
  2. // or
  3. getURL(xmlNode.attributes.link, xmlNode.attributes.target);


Now notice that I didn't include the "" when going to a frame label or website. The reason for that is that everything in xml is read in as a string (what the quotes designates). So the catch is that if you want to use a frame number in your xml you'll have to convert it from a string to an actual number in flash.
Code: [ Select ]
var frameNum = Number(xmlNode.attributes.link);
gotoAndPlay(frameNum);
  1. var frameNum = Number(xmlNode.attributes.link);
  2. gotoAndPlay(frameNum);
  • Strikeplate
  • Born
  • Born
  • Strikeplate
  • Posts: 2

Post 3+ Months Ago

Thanks for the response graphixboy.

Actually I would prefer to call to a frame label for just the reasons you mentioned. However, I'm still not clear on how I implement your solution. Expanding on my earlier example, lets say I'm loading 3 external image icons via XML:

<sample>
<button title="Apples" image="images/applebtn.jpg" link="apples">
<button title="Oranges" image="images/orangebtn.jpg" link="oranges">
<button title="Pears" image="images/pearbtn.jpg" link="pears">
</sample>

When the user clicks the various icons they move to the associated frame lables within the .swf.

I don't think the code you suggest (gotoAndPlay(xmlNode.attributes.link);) goes inside the link quotes. It appears to be AS, so does it go in actions on Frame 1...elsewhere? And don't I need some sort of onRelease type of function?

Thanks again.

Post Information

  • Total Posts in this topic: 3 posts
  • Users browsing this forum: No registered users and 5 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.