A Flash Developer Resource Site

Results 1 to 15 of 15

Thread: [RESOLVED] xml links loaded into a button within a MC

  1. #1
    Junior Member
    Join Date
    Jan 2008
    Posts
    15

    resolved [RESOLVED] xml links loaded into a button within a MC

    Hi, im currently settig up a simple (well i thought it would be simple) navigation panel that has a button within a MC, im loading the links for the buttons from XML and they load into buttons that are on the main timeline no problem. But when i try and load those links to the same buttons that are nexsted within a MC they dont work. Any ideas? Heres the code im using to just get buttons on the main time line working

    _xml = new XML();
    _xml.ignoreWhite = true;
    _xml.load("balloonxml.xml");

    _xml.onLoad = function(success){
    if(!success){
    trace("XML FAILED TO LOAD");
    }else{
    trace("XML LOADED");
    linksArray = this.firstChild.childNodes;
    for (var n=0;n!=linksArray.length;n++){
    trace("linksArray["+n+"] - "+linksArray[n].childNodes);
    }}
    };
    myButton1.onRelease = function(){
    trace(linksArray[1].childNodes);
    getURL(linksArray[1].childNodes, "_self");
    };

    -------------------------------------------------
    Heres the XML
    ---------------------------------------------------
    <?xml version="1.0" encoding="iso-8859-1"?>
    <links>
    <link>http://www.google.com</link>

    </links>

  2. #2
    FK'n_dog a_modified_dog's Avatar
    Join Date
    Apr 2003
    Location
    "aaarf"
    Posts
    9,176
    where your movieclip has the instance name on stage of - mc1

    mc1.myButton1.onRelease = function(){
    // your xml file as posted has only one node
    // so you need to access - linksArray[0]

    trace(linksArray[0].childNodes);
    getURL(linksArray[0].childNodes, "_self");
    };

  3. #3
    Junior Member
    Join Date
    Jan 2008
    Posts
    15
    Hi Dog, many thanks for replying. I did try that but with no success ie.
    panel1_mc.myButton1.onRelease = function(){
    trace(linksArray[1].childNodes);
    getURL(linksArray[1].childNodes, "_self");
    };

  4. #4
    Junior Member
    Join Date
    Jan 2008
    Posts
    15
    sorry, yes i take your point on the linksArray[0], but just tried that and still no success.

  5. #5
    Junior Member
    Join Date
    Jan 2008
    Posts
    15
    the button in question within that movie clip is located on frame 18 of that movieclip, would that make a difference?

  6. #6
    FK'n_dog a_modified_dog's Avatar
    Join Date
    Apr 2003
    Location
    "aaarf"
    Posts
    9,176
    here is my test file. using instances - mc1, myButton1 - it works
    please compare to your files
    Attached Files Attached Files

  7. #7
    Junior Member
    Join Date
    Jan 2008
    Posts
    15
    great that works, thankyou. Re my note that within my movie clip (eg. mc1) the button appears at frame 18, because i have the button dropping down from beind a panel, so would that still work using the code you supplied or would i need to do something else?

  8. #8
    Junior Member
    Join Date
    Jan 2008
    Posts
    15
    so on your example you kindly sent would it be as this to access frame 18 on the mc1 and load the link

    mc1.myButton1.gotoAndStop(18).onRelease = function(){

  9. #9
    Junior Member
    Join Date
    Jan 2008
    Posts
    15
    Hi Dog, ive managed to get all that working but only by stripping out some other parts of this movie, all the parts which i need in there to make my buttons work. If you have time could you possibly take a look at the attached file to see if you could shed some light on how i can achieve what i need ie. all the buttons in the balloon movieclips having their links loaded from the xml.
    I would gladly pay for your time, if you send over your Paypal details!!
    Attached Files Attached Files

  10. #10
    FK'n_dog a_modified_dog's Avatar
    Join Date
    Apr 2003
    Location
    "aaarf"
    Posts
    9,176
    i cannot open Flash version 9 fla files
    please use Save As .. Flash 8 file

    attached is a Flash 8 file.

    a variable is declared and attached to the movieclip within the onLoad function
    the code for myButton1 is now placed on frame#8 of the movieclip.
    Note: code on frame#1(main timeline) cannot scope to frame#8 (movieclip)
    Attached Files Attached Files

  11. #11
    Junior Member
    Join Date
    Jan 2008
    Posts
    15
    Hi Dog thanks for your file, heres my file saved as Fla8 so you can see where my problems lie. Any advice on the attached is most welcome
    Attached Files Attached Files

  12. #12
    FK'n_dog a_modified_dog's Avatar
    Join Date
    Apr 2003
    Location
    "aaarf"
    Posts
    9,176
    pretty much implemented my test file structure into your file
    all tested and working for panel1 here
    Attached Files Attached Files

  13. #13
    Junior Member
    Join Date
    Jan 2008
    Posts
    15
    Hi Dog, that is great!!, ive tested it in flash and works great, ie. i see the links coming through on the Output viewer. Ive loaded the files in to my pages click on the links and nothing happens, thought it might be linkage issue with the XML doc but checked and rechecked and all looks correct, any ideas??

  14. #14
    FK'n_dog a_modified_dog's Avatar
    Join Date
    Apr 2003
    Location
    "aaarf"
    Posts
    9,176
    i take it that you have uncommented the getURL line ?

    // = comment the line

    for correct testing you must upload all files to a server and test online

  15. #15
    Junior Member
    Join Date
    Jan 2008
    Posts
    15
    what a dummy!!, didnt spot that, all working fine now, many many thanks, you have saved me bacon on this.

Tags for this Thread

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