Welcome, Guest
  • Author Topic: scrollpane - dynamic load of buttons  (Read 1075 times)

    fh

    • Server what's that
    • *
    • Posts: 16
      • View Profile
      • Email
    scrollpane - dynamic load of buttons
    « on: 11/20/03, 08:28 »
    Hi
    I have a scrollpane and I load a movieclip from library using Scroll Content parameter. No problem.
    The problem is inside the the movieclip I load.
    I want to load a lot of buttons/movieclips and then dynamically set up text, onRelease and more. But I can't make it work.  You can see the code I want to use in the for-loop:

    Because it does not work I code it testing if the buttons/movieclips exists and then set them up. Then it is working. Only problem is that the screen don't refresh first. I must find the code for refreshing the pane?

    OK here is the code. If you have suggestion please answer me with specific help.

    Thanks
    AS - Code:


    menuXml = new XML();
    //menuXml._parent=this;
    menuXml.ignoreWhite = true;
    menuXml.onLoad = function(success) {   
       if (success) {
          menuItem = new Array();
          menuItem = this.firstChild.childNodes;      
          knap1_mc0._x+=2.5;
          knap1_mc0._y+=2;
          knap1_mc0.text_txt.text=menuItem[0].attributes.name;;      
          knap1_mc0.sub_btn.onRollOver=function() {   
             knap1_mc0.menu_mc.gotoAndPlay("over");
          };
          knap1_mc0.sub_btn.onRollOut=function() {
             knap1_mc0.menu_mc.gotoAndPlay("out");
          };
          knap1_mc0.sub_btn.onRelease=function() {
             getURL(menuItem[0].attributes.url,"_blank");
          };
          //I=5;
          //knap1_mc0.duplicateMovieClip("knap1_mc"+i);
          //knap1_mc5._x=knap1_mc0._x;
          //knap1_mc5._y=knap1_mc0._y+23;
          //we accept 10 subbuttons no more
          if (menuItem.length>1) {
             for (var i=1; i<menuItem.length; i++) {
                //duplicate button knap1_mc and put release code on
                knap1_mc0.duplicateMovieClip("knap1_mc"+i,i);
    //here is code I want to have to work!!!!!!!!!!!
                //this["knap1_mc"+i]._x=knap1_mc0._x;
                //this["knap1_mc"+i]._y=knap1_mc0._y+(23*1);
                //this["knap1_mc"+i].text_txt.text=menuItem.attributes.name;
                //this["knap1_mc"+i].onRollOver=function() {
                //   this["knap1_mc"+i].gotoAndPlay("over");
                //};
                //and so on for other functions - what is wrong?
             }//end for
             if (knap1_mc1 != null) {
                   knap1_mc1._x=knap1_mc0._x;
                   knap1_mc1._y=knap1_mc0._y+(23*1);
                   knap1_mc1.text_txt.text=menuItem[1].attributes.name;      
                   knap1_mc1.sub_btn.onRollOver=function() {   
                      knap1_mc1.menu_mc.gotoAndPlay("over");
                   };
                   knap1_mc1.sub_btn.onRollOut=function() {
                      knap1_mc1.menu_mc.gotoAndPlay("out");
                   };
                   knap1_mc1.sub_btn.onRelease=function() {
                      getURL(menuItem[1].attributes.url,"_blank");
                   };
                   
                   if (knap1_mc2 != null) {
                   knap1_mc2._x=knap1_mc0._x;
                   knap1_mc2._y=knap1_mc0._y+(23*2);
                   knap1_mc2.text_txt.text=menuItem[2].attributes.name;      
                   knap1_mc2.sub_btn.onRollOver=function() {   
                      knap1_mc2.menu_mc.gotoAndPlay("over");
                   };
                   knap1_mc2.sub_btn.onRollOut=function() {
                      knap1_mc2.menu_mc.gotoAndPlay("out");
                   };
                   knap1_mc2.sub_btn.onRelease=function() {
                      getURL(menuItem[2].attributes.url,"_blank");
                   };
                   if (knap1_mc3 != null) {
                   knap1_mc3._x=knap1_mc0._x;
                   knap1_mc3._y=knap1_mc0._y+(23*3);
                   knap1_mc3.text_txt.text=menuItem[3].attributes.name;      
                   knap1_mc3.sub_btn.onRollOver=function() {   
                      knap1_mc3.menu_mc.gotoAndPlay("over");
                   };
                   knap1_mc3.sub_btn.onRollOut=function() {
                      knap1_mc3.menu_mc.gotoAndPlay("out");
                   };
                   knap1_mc3.sub_btn.onRelease=function() {
                      getURL(menuItem[3].attributes.url,"_blank");
                   };
                   if (knap1_mc4 != null) {
                   knap1_mc4._x=knap1_mc0._x;
                   knap1_mc4._y=knap1_mc0._y+(23*4);
                   knap1_mc4.text_txt.text=menuItem[4].attributes.name;      
                   knap1_mc4.sub_btn.onRollOver=function() {   
                      knap1_mc4.menu_mc.gotoAndPlay("over");
                   };
                   knap1_mc4.sub_btn.onRollOut=function() {
                      knap1_mc4.menu_mc.gotoAndPlay("out");
                   };
                   knap1_mc4.sub_btn.onRelease=function() {
                      getURL(menuItem[4].attributes.url,"_blank");
                   };
                   if (knap1_mc5 != null) {
                   knap1_mc5._x=knap1_mc0._x;
                   knap1_mc5._y=knap1_mc0._y+(23*5);
                   knap1_mc5.text_txt.text=menuItem[5].attributes.name;      
                   knap1_mc5.sub_btn.onRollOver=function() {   
                      knap1_mc5.menu_mc.gotoAndPlay("over");
                   };
                   knap1_mc5.sub_btn.onRollOut=function() {
                      knap1_mc5.menu_mc.gotoAndPlay("out");
                   };
                   knap1_mc5.sub_btn.onRelease=function() {
                      getURL(menuItem[5].attributes.url,"_blank");
                   };
                   }//end if knap1_mc5
                   }//end if knap1_mc4
                   }//end if knap1_mc3
                   }//end if knap1_mc2
                }//end if knap1_mc1
          }//end if menuItem.length>1
          
       }else {//else not success
          knap1_mc._visible=false;
       }
    }
    menuXml.load("menuknap5.xml");//load xml or php page
    stop();

    Jorge Solis

    • Global Moderator
    • Systems Administrator
    • *****
    • Posts: 14616
      • View Profile
    Re:scrollpane - dynamic load of buttons
    « Reply #1 on: 11/20/03, 13:39 »
    Hi Michael. welcome to the boards !!

    Try myScrollPane.refreshPane()

    Jorge
    « Last Edit: 11/20/03, 13:40 by Jorge Solis »

    fh

    • Server what's that
    • *
    • Posts: 16
      • View Profile
      • Email
    Re:scrollpane - dynamic load of buttons
    « Reply #2 on: 11/21/03, 03:55 »
    Thanks, anybody have an idea about the dynamic buttons and the code for them?
    Michael

    Ronald Wernecke

    • Global Moderator
    • Systems Administrator
    • *****
    • Posts: 6203
      • View Profile
      • Professional Support
      • Email
    Re:scrollpane - dynamic load of buttons
    « Reply #3 on: 11/21/03, 04:05 »
    Have a look at my sample "Menue fed by XML".
    You'll find it in the technical reference area.
    happy flashing
    8)
    Ronald

    fh

    • Server what's that
    • *
    • Posts: 16
      • View Profile
      • Email
    Re:scrollpane - dynamic load of buttons
    « Reply #4 on: 11/21/03, 07:44 »
    thanks again
    If you look at my code you can see that I am using a little more advanced code than the basic stuff from technical area, so please help with the scrollpane - not the buttons. I don't understand why it can't be completely dynamic.
    Now it is working with 10 buttons and it is very nice, but if it was dynamic I could have 10 or hundred buttons.
    Okay, I will try again in the weekend -maybe something will happen.
    By the way - jorge gave me code for the scrollpane.refreshPane(). It was working, but only from outside the scrollpane, so I had to call a function in the upper movieclip to make it work.

    Thanks Michael