dcsimg
A Flash Developer Resource Site

Results 1 to 4 of 4

Thread: looking for simple script importing XML and making buttons link

  1. #1
    Member
    Join Date
    Jan 2003
    Location
    Dallas
    Posts
    48

    looking for simple script importing XML and making buttons link

    I am pretty rusty when it comes to action script. I am using CS3 and want to have an XML file that has the links like www.mydomain.com imported into the flash so when a button is clicked it will go there...

    I have looked at numerous examples but all are too complicated for what i want to do.
    I will pay someone via paypal if they want to do this quick fix for me... I can send the file... should be strait forward for someone knowing waht they are doing

    Thanks

    TM
    Peace be the journey and Beyond

  2. #2
    Senior Member
    Join Date
    Aug 2001
    Location
    Aus land
    Posts
    204
    ok
    your xml file, links.xml
    Code:
    <links>
       <link button='myButton' url='www.google.com' />
    </links>
    say on _root you have ab button called myButton
    Code:
    var myXML=new XML();
    myXML.onLoad=function(){
    
       var theButton:MovieClip= _root[this.firstNode.childNodes[0].attributes.button];
       var theURL:String=this.firstNode.childNodes[0].attributes.url;
    
       theButton.gotoURL=theURL;
       theButton.onPress=function(){
           getURL(this.gotoURL, "_blank");
       }
    
    }
    myXML.load("links.xml");
    so this loads he XML file in, gets the name of the button and the URL that you want to go to, then passes the URL to the button's onPress event, where the URL is used in getURL() method to go to a web page.


    hope this helps

  3. #3
    Member
    Join Date
    Jan 2003
    Location
    Dallas
    Posts
    48
    Thank you so much
    this is a huge help..
    for me most times its the simple things that are hard

    Thanks Again

    Tm
    Peace be the journey and Beyond

  4. #4
    Member
    Join Date
    Jan 2003
    Location
    Dallas
    Posts
    48

    still bangin my head a little

    thanks for your help...
    i dont know why this is not working for me

    I am using actionscript 2.0

    I tried the code on the button itself and did not work..

    my xml is called links.xml
    <?xml version="1.0" encoding="utf-8"?>
    <links>
    <link button='button_taps' url='www.tidalwaves.com' />
    <link button='button_drills' url='www.tidalwave.com' />
    <link button='button_end_mills' url='www.bubble.com' />
    <link button='button_tools' url='www.obama.com' />
    <link button='button_guages' url='www.georgebush.com' />
    <link button='button_dies' url='www.hank.com' />
    </links>

    the code on my button looks like this

    on (release) {
    var myXML=new XML();
    myXML.onLoad=function(){

    var theButton:MovieClip= _root[this.firstNode.childNodes[0].attributes.button];
    var theURL:String=this.firstNode.childNodes[0].attributes.url;

    theButton.gotoURL=theURL;
    theButton.onPress=function(){
    getURL(this.gotoURL, "_blank");
    }

    }
    myXML.load("links.xml");

    }




    what am i doing wrong

    thanks for all your help

    Terry Mallory
    Peace be the journey and Beyond

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