A Flash Developer Resource Site

Results 1 to 5 of 5

Thread: xml and getURL problem

  1. #1
    Junior Member
    Join Date
    Dec 2000
    Posts
    14

    xml and getURL problem

    Hi Everybody,

    Here's is my problem...I'm building a horizontal sliding menu on the fly from an XML doc featuring thumbnails and text. I've got 10 childnodes in my XML doc that are supposed to load as 10 movieclips featuring 10 separate and different thumbnails...which they do...the problem arises when I try to apply links to the movieclips from url's also defined in the XML doc. I can trace the urls no problem and the following code gives me a list of my 10 urls:

    Code:
    var link_to:Array = [featuresXML.childNodes[i].childNodes[4].firstChild];
    trace(link_to);

    When I try to apply them to the movieclips though:

    Code:
    postersMC.itemsMC[name].mc_buttonPicture.onRelease = function() {
    				trace(link_to);
    I get only the last link from the list of 10...and it is applied to all the movieclips...so no matter which one I click on, I get the same link.

    I think it has something to do with the array and that I'm not calling it properly in my onRelease function...I dunno...any suggestions would be much appreciated. Let me know if you need more of the code. I'd be happy to post it all...this is the last thing I need to finish this project and it's really got me in a bind.

    Thanks in advance.
    “Life is not a movie. Good guys lose, everybody lies, and love... does not conquer all.”
    - Buddy Ackerman

  2. #2
    dubba you tee eff steven_h_2000's Avatar
    Join Date
    Oct 2000
    Location
    Columbus, Ohio
    Posts
    137
    i think i understand your problem.... all of your onRelease()'s are tracing just that value of link_to. Try this:

    Code:
    postersMC.itemsMC[name].mc_buttonPicture.myLink = link_to;
    postersMC.itemsMC[name].mc_buttonPicture.onRelease = function() {
    				trace(this.myLink);
    you may need to stick it into a loop or something, but i hope you get the idea

  3. #3
    Flashmatics silentweed's Avatar
    Join Date
    Mar 2005
    Location
    London, UK
    Posts
    4,876
    yep be helpful if you show us more code and your xml fiel structure as well... you must be defining the link_to within a for loop thats why this is happening..anyway post up more so we can have a look
    Flashmatics | Flashmatics Library (free downloads)
    -----------------------------------------------------
    Latest Projects:
    The Dead Room | Are You Smarter | Prison Break (Frame A Friend) | Beck's Fusions | The 24 Experience

    -----------------------------------------------------
    Flash Certified Developer

  4. #4
    [ORPHIC] Chavez
    Join Date
    Mar 2006
    Location
    Saratoga Springs, NY
    Posts
    19
    what I would do is this: create a function declaring a button ID... you can then reference the current URL as a global variable "_global.LinkVariable"

    // BEGIN AS
    var xmlPath = ("xml_.xml");
    var btnID:Number = 0;
    var LinkVar = ("");

    btn_1.onRollOver = function (){
    set("btnID",1)
    RollOver();
    }

    function RollOver (){
    trace("Button ID = " + btnID);
    StoreCurrentVars();
    }

    function StoreCurrentVars(){
    set ("LinkVar", links[btnID]);
    trace (LinkVar);
    _global.LinkVariable = LinkVar;
    }

    function loadXML(loaded) {
    if (loaded) {
    xmlNode = this.firstChild;
    links = [];
    total = xmlNode.childNodes.length;
    for (i=0; i<total; i++) {
    links[i] = xmlNode.childNodes[i].childNodes[0].firstChild.nodeValue;
    }
    } else {
    content = "file not loaded!";
    }
    }
    xmlData = new XML();
    xmlData.ignoreWhite = true;
    xmlData.onLoad = loadXML;
    xmlData.load(this.xmlPath);
    [ORPHIC] M E D I A
    A n t h o n y C h a v e z
    S a r a t o g a S p r i n g s , N Y
    U S A
    E A R T H
    r a n d o m @ c h a v e z a r t . n e t

  5. #5
    Junior Member
    Join Date
    Dec 2000
    Posts
    14
    Thanks Steven! your suggestion totally worked. That one line of code was all I needed.
    “Life is not a movie. Good guys lose, everybody lies, and love... does not conquer all.”
    - Buddy Ackerman

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  




Click Here to Expand Forum to Full Width

HTML5 Development Center