A Flash Developer Resource Site

Results 1 to 17 of 17

Thread: XML + URLS: Carousel

  1. #1
    Bmcc*81 bmcc81's Avatar
    Join Date
    Jul 2007
    Location
    Montreal
    Posts
    299

    Unhappy XML + URLS: Carousel

    Hi,

    I'm having some trouble with my carousel.

    They all link to the same place. I have different links but they go to the same spot.

    Here's my xml.load function:

    PHP Code:
    xml.onLoad = function() {
        var 
    nodes this.firstChild.childNodes;
        
    numOfItems nodes.length;
        for (var 
    0i<numOfItemsi++) {
            var 
    home.attachMovie("item""item"+ii+1);
            
    t.angle i*((Math.PI*2)/numOfItems);
            
    t.onEnterFrame mover;
            
    t.toolText nodes[i].attributes.tooltip;

            
    t.urlRef nodes[i].attributes.link;

            
    t.content nodes[i].attributes.content;
            
    t.icon.inner.loadMovie(nodes[i].attributes.image);
            
    t.r.inner.loadMovie(nodes[i].attributes.image);
            
    t.icon.onRollOver over;
            
    t.icon.onRollOut out;
            
    t.icon.onRelease released;
        }
    }; 
    Launch URL Button:

    PHP Code:
    launch_magazine_mc.onRelease = function() {
       
    // trace(this._parent.urlRef);
        
    getURL(this._parent.urlRef"_self");
    }; 
    and they all launch the same URL all the time.
    Can someone Help?

    DOWNLOAD FILE HERE (if needed)

    Thanks,
    Bmcc81
    Flash Designer / Web Developer
    -----------------------------------
    http://www.webinkgraphics.com

  2. #2
    Bmcc*81 bmcc81's Avatar
    Join Date
    Jul 2007
    Location
    Montreal
    Posts
    299
    Can anyone tell me why it launches the same page from my XML FILE

    This is the last thing I need to finish my project, the help would be appreciated.

    Thanks,
    Bmcc81
    Flash Designer / Web Developer
    -----------------------------------
    http://www.webinkgraphics.com

  3. #3
    Senior Member
    Join Date
    Nov 2005
    Location
    dante's inferno
    Posts
    904
    you need to store the info in an Array. I may be wrong, but it looks like you are just looping through your xml. So your variable will always equal the last URL in your xml.

    IMS

  4. #4
    Bmcc*81 bmcc81's Avatar
    Join Date
    Jul 2007
    Location
    Montreal
    Posts
    299

    Thanks

    Would I just make the array like this?

    var urlRef:Array = new Array();

    Thanks
    Bmcc81
    Flash Designer / Web Developer
    -----------------------------------
    http://www.webinkgraphics.com

  5. #5
    Senior Member
    Join Date
    Nov 2005
    Location
    dante's inferno
    Posts
    904
    yes

  6. #6
    Bmcc*81 bmcc81's Avatar
    Join Date
    Jul 2007
    Location
    Montreal
    Posts
    299
    This is what I ended up doing. I made the array at the top.

    PHP Code:
    var urlRef = new Array();

    var 
    xml:XML = new XML();
    xml.ignoreWhite true;

    xml.onLoad = function() {
        var 
    nodes this.firstChild.childNodes;
        
    numOfItems nodes.length;
        for (var 
    0i<numOfItemsi++) {
            var 
    home.attachMovie("item""item"+ii+1);
            var 
    home.attachMovie("item""item"+ii+1);
            
    t.angle i*((Math.PI*2)/numOfItems);
            
    t.onEnterFrame mover;
            
    t.toolText nodes[i].attributes.tooltip;
            
            
    urlRef[i] = nodes[i].attributes.URLREF;
            
    /*for (var j = 0; j=numLinks; j++){
            }*/
            
    links urlRef;
            
            
    //var url = xml.firstChild.firstChild.childNodes[i].attributes.URLREF;
            
            
    t.content nodes[i].attributes.content;
            
    t.icon.inner.loadMovie(nodes[i].attributes.image);
            
    t.r.inner.loadMovie(nodes[i].attributes.image);
            
    t.icon.onRollOver over;
            
    t.icon.onRollOut out;
            
    t.icon.onRelease released;
        }
    };

    launch_magazine_mc.onRelease = function() { 
       var 
    _index 0// this is the (zero-based) index of the url you need. for the second url set this to 1, the next would be 2 etc...
       
    trace(urlRef[_index]); 
       
    getURL(urlRef[_index], "_self"); 
    }; 
    This now gives me the first url in the array. I need it to recognize which icon is selected and what url that's selected.

    Thanks,
    Bmcc81
    Flash Designer / Web Developer
    -----------------------------------
    http://www.webinkgraphics.com

  7. #7
    Senior Member
    Join Date
    Nov 2005
    Location
    dante's inferno
    Posts
    904
    this is going to be hard to explain, I tried to oopen your file, but got a zip error.

    So basically, you are setting up a bunch of buttons, and depending on what button you push, an image changes, and you are sent to a specific link? Are the buttons being created dynamicaly, or are they all static on the stage?

  8. #8
    Bmcc*81 bmcc81's Avatar
    Join Date
    Jul 2007
    Location
    Montreal
    Posts
    299
    Hi and thanks,

    there is one button on the stage that is static it is called
    launch_magazine_mc
    Basically your right with everything else. If you could help me figure this out it would be excellent.


    DOWNLOAD FILES HERE

    Thanks,
    Bmcc81
    Flash Designer / Web Developer
    -----------------------------------
    http://www.webinkgraphics.com

  9. #9
    Senior Member
    Join Date
    Nov 2005
    Location
    dante's inferno
    Posts
    904
    Ok, so if you click the button, you will go to the first link, if you click it again, you will go to the second, and so on?

    you are almost there, try:

    PHP Code:

    var _index 0;

    launch_magazine_mc.onRelease = function() { 
          
    trace(urlRef[_index]); 
          
    getURL(urlRef[_index], "_self");
          
    _index ++; 

    you want to put your variable outside of the button code. the way you have it, everytime you press the button, _index is going to equal 0. I added _index++ to the button code. everytime you press the button, this will increase _index by 1, therfore scrolling through your array.
    Last edited by IMS; 02-24-2009 at 05:22 PM.

  10. #10
    Bmcc*81 bmcc81's Avatar
    Join Date
    Jul 2007
    Location
    Montreal
    Posts
    299

    Nope it depends what Icons is selected

    Not really it really depends on what icon is selected. The code that yo gave me just goes through like a picture gallery.

    It has to know what numOfItems it is on.
    Thanks,
    Bmcc81
    Flash Designer / Web Developer
    -----------------------------------
    http://www.webinkgraphics.com

  11. #11
    Senior Member
    Join Date
    Nov 2005
    Location
    dante's inferno
    Posts
    904
    If there is only one button, how do we set what Icon is showing?

  12. #12
    Bmcc*81 bmcc81's Avatar
    Join Date
    Jul 2007
    Location
    Montreal
    Posts
    299

    Set icons with this...

    It works with using this

    PHP Code:
    for (var 0i<numOfItemsi++) {
    var 
    t:MovieClip home["item"+i]; 
    I use it in the released(); of my code:

    PHP Code:
    function released() {
        
    //BONUS Section
        
    var sou:Sound = new Sound();
        
    sou.attachSound("sdown");
        
    sou.start();

        
    home.tooltip._alpha 0;
        for (var 
    0i<numOfItemsi++) {
            var 
    t:MovieClip home["item"+i];
            
    t.xPos t._x;
            
    t.yPos t._y;
            
    t.theScale t._xscale;
            
    delete t.icon.onRollOver;
            
    delete t.icon.onRollOut;
            
    delete t.icon.onRelease;


            
    delete t.onEnterFrame;


            if (
    != this._parent) {
                var 
    tw:Tween = new Tween(t"_xscale"Strong.easeOutt._xscale01true);
                var 
    tw2:Tween = new Tween(t"_yscale"Strong.easeOutt._yscale01true);
                var 
    tw3:Tween = new Tween(t"_alpha"Strong.easeOut10001true);

            } else {

                var 
    tw:Tween = new Tween(t"_xscale"Strong.easeOutt._xscale1001true);
                var 
    tw2:Tween = new Tween(t"_yscale"Strong.easeOutt._yscale1001true);
                var 
    tw3:Tween = new Tween(t"_x"Strong.easeOutt._x731true);
                var 
    tw4:Tween = new Tween(t"_y"Strong.easeOutt._y1951true);
                var 
    tw5:Tween = new Tween(theText"_alpha"Strong.easeOut01001true);

                var 
    tw:Tween = new Tween(launch_magazine_mc"_xscale"Strong.easeOut01001true);
                var 
    tw2:Tween = new Tween(launch_magazine_mc"_yscale"Strong.easeOut01001true);
                var 
    tw5:Tween = new Tween(launch_magazine_mc"_alpha"Strong.easeOut01001true);

                
    theText.text t.content;
                var 
    s:Object this;
                
    tw.onMotionStopped = function() {
                    
    s.onRelease unReleased;
                };
            }
        }

    Hope that explains
    Bmcc81
    Flash Designer / Web Developer
    -----------------------------------
    http://www.webinkgraphics.com

  13. #13
    Senior Member
    Join Date
    Nov 2005
    Location
    dante's inferno
    Posts
    904
    not really, It's hard to visualize without seeing it. Is there a way to find out what the image is?

  14. #14
    Bmcc*81 bmcc81's Avatar
    Join Date
    Jul 2007
    Location
    Montreal
    Posts
    299
    I think it's...

    PHP Code:
    var t:MovieClip home["item"+i]; 
    That tells you what Item your on.

    You can download the files now I've fixed the link
    Bmcc81
    Flash Designer / Web Developer
    -----------------------------------
    http://www.webinkgraphics.com

  15. #15
    Senior Member
    Join Date
    Nov 2005
    Location
    dante's inferno
    Posts
    904
    I think I got this:

    replace the following: (I commented what I added with my initials so it is easy to find)

    (added: myCurrentCover = t.myLink
    PHP Code:
    function released() {
        
    trace('released')
        
    //BONUS Section
        
    var sou:Sound = new Sound();
        
    sou.attachSound("sdown");
        
    sou.start();

        
    home.tooltip._alpha 0;
        for (var 
    0i<numOfItemsi++) {
            var 
    t:MovieClip home["item"+i];
            
    t.xPos t._x;
            
    t.yPos t._y;
            
    t.theScale t._xscale;
            
    delete t.icon.onRollOver;
            
    delete t.icon.onRollOut;
            
    delete t.icon.onRelease;


            
    delete t.onEnterFrame;


            if (
    != this._parent) {
                var 
    tw:Tween = new Tween(t"_xscale"Strong.easeOutt._xscale01true);
                var 
    tw2:Tween = new Tween(t"_yscale"Strong.easeOutt._yscale01true);
                var 
    tw3:Tween = new Tween(t"_alpha"Strong.easeOut10001true);

            } else {

                var 
    tw:Tween  = new Tween(t"_xscale"Strong.easeOutt._xscale1001true);
                var 
    tw2:Tween = new Tween(t"_yscale"Strong.easeOutt._yscale1001true);
                var 
    tw3:Tween = new Tween(t"_x"Strong.easeOutt._x731true);
                var 
    tw4:Tween = new Tween(t"_y"Strong.easeOutt._y1951true);
                var 
    tw5:Tween = new Tween(theText"_alpha"Strong.easeOut01001true);

                var 
    tw:Tween = new Tween(launch_magazine_mc"_xscale"Strong.easeOut01001true);
                var 
    tw2:Tween = new Tween(launch_magazine_mc"_yscale"Strong.easeOut01001true);
                var 
    tw5:Tween = new Tween(launch_magazine_mc"_alpha"Strong.easeOut01001true);

                
    theText.text t.content;
                var 
    s:Object this;
                
                
    myCurrentCover t.myLink;  //this will set what mag cover was clicked. IMS
                
                
    tw.onMotionStopped = function() {
                    
    s.onRelease unReleased;
                };
            }
        }

    replace:
    (added: t.myLink = nodes[i].attributes.URLREF; )
    PHP Code:
    xml.onLoad = function() {
        var 
    nodes this.firstChild.childNodes;
        
    numOfItems nodes.length;
        for (var 
    0i<numOfItemsi++) {
            var 
    home.attachMovie("item""item"+ii+1);
            var 
    home.attachMovie("item""item"+ii+1);
            
    t.angle i*((Math.PI*2)/numOfItems);
            
    t.onEnterFrame mover;
            
    t.toolText nodes[i].attributes.tooltip;
            
    t.myLink nodes[i].attributes.URLREF;  // set link to specified movie clip (t) IMS
            
    t.content nodes[i].attributes.content;
            
    t.icon.inner.loadMovie(nodes[i].attributes.image);
            
    t.r.inner.loadMovie(nodes[i].attributes.image);
            
    t.icon.onRollOver over;
            
    t.icon.onRollOut out;
            
    t.icon.onRelease released;
            
    trace('link: 't.myLink);
        }
        
    //trace('urlRef: '+ urlRef);

    REPLACE:
    PHP Code:
    launch_magazine_mc.onRelease = function() { 
       
    trace('myCurrentCover: 'myCurrentCover); // this should be the cover that was clicked.. IMS
       
    getURL(myCurrentCover"_self"); 

    Hopefully this works. I basically started tracing everyting to see how it all worked. then set a variable after you click a cover. then I new what cover was clicked. then I just placed that variable in the URL.

    IMS

  16. #16
    Bmcc*81 bmcc81's Avatar
    Join Date
    Jul 2007
    Location
    Montreal
    Posts
    299
    Wow,

    You made it look so simple. It makes perfect sense. Thanks, I got it working.
    You da man!!!
    Bmcc81
    Flash Designer / Web Developer
    -----------------------------------
    http://www.webinkgraphics.com

  17. #17
    Senior Member
    Join Date
    Nov 2005
    Location
    dante's inferno
    Posts
    904
    No problem.

    Glad it worked.

    IMS

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