A Flash Developer Resource Site

Results 1 to 7 of 7

Thread: AS2 XML: need to go to specific frame if...

  1. #1
    Junior Member
    Join Date
    Apr 2002
    Posts
    10

    Question AS2 XML: need to go to specific frame if...

    Hi, I'm using Flash CS3 but AS2 -- I'm primarily a designer / animator and rarely deal with XML and such.

    I need to do 2 things:
    I have a rotator piece I'm working on where I need to be able to go to a specific named frame (promotions) if the XML I search for (http://websitenamehere.com/promo_sign_feed) has the tag <promo>.

    I also need to be able to have a button on that frame link to a URL that is pulled from a tag in the same XML, called <promoURL>.


    I have no idea how to do this and would love some help.

  2. #2
    Junior Member
    Join Date
    Apr 2002
    Posts
    10
    This seems like it would be simple to people who work with XML a lot. I could really use some help.
    Last edited by nuclearfish; 12-18-2009 at 04:11 PM.

  3. #3
    Junior Member
    Join Date
    Apr 2002
    Posts
    10
    I'm sorry to bother anyone but this has been up a week and no one has offered any help, and I'd really appreciate some.

  4. #4
    Senior Member somlemeg's Avatar
    Join Date
    Aug 2000
    Posts
    171

    Post

    I don't get a XML file when I go to the link you posted.

    Its been a few years since I did a lot of AS, but anyway, this could give you a start. I think it could go about like this, but I recommend using the AS reference for futher guideline.

    First you need to load the XML file:
    (this code is attached to a movie on stage)
    PHP Code:
        // make a XML object
        
    var dataXML:XML = new XML();
        
    // this parameter takes away white spaces in your XML
        
    dataXML.ignoreWhite true;
        
    _root.createEmptyMovieClip("tekstMov",2);
        
    // Laste load the xml into the dataXML object
        
    menyXML.load("file.xml"); 
    Since you want something to happen when the XML loads you put this in under:

    PHP Code:
    var totalNodes:Number;
        
    menyXML.onLoad = function(success) {
            
    // When the xml file loads complete this happens:
            // this code will problably be a bit different depending on how your XML file looks
            // Cycle the XML trough to find number of nodes:
            
    nodeTemp "";
            while (
    nodeTemp != undefined) {
                
    totalNodes++;
                
    nodeTemp dataXML.firstChild.childNodes[journalAnt];
            }
            
            
    // Need to cycle thou the dataXML object to find the node named promoURL

            
    for (i=0i<=totalNodesi++) {
                
    nodeName klientXML.firstChild.childNodes[journalNummer].name;
                if (
    nodeName == "promoURL") {
                    
    // remember the name of the node for use later
                    
    _root.frameName nodeName;
                }
            }        
        } 

    Then you want a button that takes you to the frame, this one is placed on stage:

    PHP Code:
    on (release) {
        
    gotoAndStop(frameName);


  5. #5
    Senior Member somlemeg's Avatar
    Join Date
    Aug 2000
    Posts
    171
    Last edited by somlemeg; 12-18-2009 at 06:04 PM. Reason: more spesific text

  6. #6
    Junior Member
    Join Date
    Apr 2002
    Posts
    10
    Thank you.


    I was using that as a general "yourwebsitehere" web address.

    This is the location of the xml file:
    http://avenuenashville.com/promo_sign_feed

    I don't know if I can be more specific about what I'm trying to do, but
    I'm using actionscript 2.


    I have a rotator piece I'm working on where I need to be able to go to a specific named frame (promotions) if the XML I search for (http://avenuenashville.com/promo_sign_feed) has the tag <promo>.

    Everything is taking place on the main timeline.
    You can see the working rotator here:
    http://avenuenashville.com
    *
    I also need to be able to have a button on that frame link to a URL that is
    pulled from a tag in the same XML, called <promoURL>.
    *

  7. #7
    Senior Member somlemeg's Avatar
    Join Date
    Aug 2000
    Posts
    171

    solution

    You can do like this:
    PHP Code:
    // make a XML object
    var promoXML:XML = new XML();
    // this parameter takes away white spaces in your XML
    promoXML.ignoreWhite true;
    // load the xml into the dataXML object
    promoXML.load("http://avenuenashville.com/promo_sign_feed");
    var 
    totalNodes:Number;
    promoXML.onLoad = function(success) {
        var 
    promoChild:XMLNode promoXML.firstChild.firstChild;
        if (
    promoChild.nodeName == "promo") {
            
    gotoAndStop("promotions");
        }
    }; 
    Note: If the structure of the xml file is very changed (if the promo node is not placed on that location in the xml three), the script will not work.


    You owe me a

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