6 Replies Latest reply on Sep 20, 2011 3:47 PM by Ned Murphy

    scrollbar problem

    melas076 Level 1

      Dear,

       

      i have 2 scrollbars in each MC. when i scroll with mouse it scrolls all scrollbars and not the one i select..

       

      anyone has idea???

       

      regards,

      MELAS

        • 1. Re: scrollbar problem
          Ned Murphy Adobe Community Professional & MVP

          Do you have any code to show that relates to using the mouse to control the scrollbars?

          • 2. Re: scrollbar problem
            melas076 Level 1

            Dear Ned,

             

            This is the code of Mc2  and the same for Mc1 but removes 2 in"content_mc2", "mask_mc2" and "scroll_mc2"

             

             

            stop();

            import com.greensock.*;

            var newsXML:XML = new XML();

            newsXML.ignoreWhite = true;

            newsXML.load("xml/Profile.xml");

            var output:String = "";

             

            newsXML.onLoad = function(success) {

                if (success) {

                    var ref = _root.prohome;

                    ref.content_mc2.ProfileHome.autoSize = true;

                     ref.content_mc2.ProfileHome.multiline = true;

                    ref.content_mc2.ProfileHome.wordWrap = true;

                    var news:Array = newsXML.childNodes[0].childNodes[0].firstChild;

                    //var hlink = news[i].attributes.links;

                    //trace(news);

             

                    ref.content_mc2.ProfileHome.htmlText = news;

                    ref.content_mc2.setMask(ref.mask_mc2);

            //trace(newsheight);

            //this.content_mc._height =  _root.content_mc.newsTXT._height;

            //trace( );

            if(ref.mask_mc2._height<ref.content_mc2._height)

            {   

             

                var scroll_c2 = ref.attachMovie("ScrollBar","scroll_mc2",1,{_x:ref.mask_mc2._x+ref.mask_mc2._width-10,_y: ref.mask_mc2._y});

                    scroll_c2.setHeight(ref.mask_mc2._height);

             

                    scroll_c2.PageSize  = ref.mask_mc2._height;

                    scroll_c2.McHeight  = ref.content_mc2._height+40;

                    scroll_c2.Chunks = ref.content_mc2._height+40-ref.mask_mc2._height;

             

                    scroll_c2._parent.onScroll = function()

                    {

                        TweenLite.to(ref.content_mc2, 1, {_y:ref.mask_mc2._y - this.scroll_mc2.getScrollPos()});

            }

                        //ref.content_mc._y = ref.mask_mc._y - this.scroll_mc.getScrollPos();

            //        }

             

                    scroll_c2.init();   

             

                    scroll_c2.onPress = function(){}

            }

            var mouseListener2 = new Object();

            mouseListener2.onMouseWheel = function( wheelMotion2 ){

            scroll_c2.scr_pos -= wheelMotion2 *2;

            scroll_c2.Update();

            }

             

            Mouse.addListener( mouseListener2 );

             

                }else{

                    ref.content_mc2.ProfileHome.htmlText = "Data file did not load.";

                    }

            }

             

            thanks in advance...

             

            MELAS

            • 3. Re: scrollbar problem
              melas076 Level 1

              Dear Ned,

               

              Any idea for this issue??

               

              Regards,

              Melas

              • 4. Re: scrollbar problem
                melas076 Level 1

                i forget to post this code of scrollbar in ScrollBar.as in folder "com/go4flash/ScrollBar.as".

                 

                 

                class com.go4flash.ScrollBar extends MovieClip

                {

                    public var enabled;

                    public var scr_pos;

                    public var McHeight;

                    public var PageSize;

                    public var FullBarMc;

                    public var McScaledStep;

                    public var step;

                    public var ArrowDown;

                    public var height;

                    public var Chunks;

                 

                    public function ScrollBar()

                    {

                        this.enabled    = true;

                        this.scr_pos    = 0;

                 

                        this.createInterface();

                        this.init();

                    }

                 

                    public function init()

                    {

                            if(this.McHeight > this.PageSize)

                                this.enabled = true;

                            else

                            {

                                this.FullBarMc.Slider._visible = false;

                                this.enabled = false;

                            }

                 

                            if(this.enabled)

                            {

                                var trg_coef        = this.PageSize/this.McHeight;

                                this.McScaledStep    = (this.McHeight-this.PageSize)/(this.Chunks-1);

                                var sh                = this.FullBarMc.Bar._height*trg_coef;

                 

                                if(sh < 10)            this.FullBarMc.Slider.SliderMc._height = 10;

                                else                 this.FullBarMc.Slider.SliderMc._height = sh;

                 

                                var scr_coef    = this.FullBarMc.Slider._height/this.FullBarMc.Bar._height;

                                var trg_h        = (this.McHeight-this.PageSize);

                                var scr_h        = (this.FullBarMc.Bar._height-this.FullBarMc.Slider._height);

                 

                                this.step        = scr_h/(this.Chunks-1);

                 

                                if(!this.FullBarMc.Slider._visible)

                                    this.FullBarMc.Slider._visible = true;               

                            }

                 

                            this.Update();

                    }

                 

                    public function onMoveSlider()

                    {

                      if(this.enabled)

                        {

                         this.scr_pos = this.setRanges(Math.round((this.FullBarMc.Bar._ymouse-this.FullBarMc.Slider.yOffset)/this .step),0,this.Chunks-1);

                         this.Update();

                        }

                    }

                 

                    public function getScaledStep()

                    {

                        return this.McScaledStep;

                    }

                 

                    public function Update()

                    {

                            this.scr_pos                = this.getScrollPos();

                            this.FullBarMc.Slider._y    = this.scr_pos*this.step;

                            this._parent.onScroll();

                    }

                 

                    public function getScrollPos(){

                            return this.setRanges(this.scr_pos,0,this.Chunks-1);

                    }

                 

                    public function setScrollPos(nPos){

                            this.scr_pos = this.setRanges(nPos,0,this.Chunks-1);

                            this.Update();

                    }

                 

                    public function setRanges(x,l,r)

                    {

                            if(x <= l)    return l;

                            if(x >= r)    return r;   

                                        return x;

                    }

                 

                    public function setHeight(sz){

                        if(sz > 25)

                        {

                         this.FullBarMc.Bar.BarBgrMc._height    = sz-this.ArrowDown._height*2;

                         this.ArrowDown._y                        = sz;//-this.ArrowDown._height;

                         this.init();

                        }

                    }

                 

                    public function setEnabled(boolVal)

                    {

                        this.enabled = boolVal;

                    }

                 

                    public function createInterface()

                    {

                        var h = this._height;

                 

                        this._xscale = 100;

                        this._yscale = 100;

                 

                        if(this.height!=undefined)    this.setHeight(this.height);

                        else                        this.setHeight(h);

                    }

                 

                }

                 

                to download this free scrollbar : http://blog.go4flash.com/downloads/sources/SimpleScrollBar.zip

                 

                 

                please help!!!!!

                • 5. Re: scrollbar problem
                  melas076 Level 1

                  Mr. Ned,

                   

                  are you there?

                   

                  did you see this issues?

                   

                  any ideas for this?

                   

                  regards,

                  MELAS

                  • 6. Re: scrollbar problem
                    Ned Murphy Adobe Community Professional & MVP

                    The key to finding the problem likely lies in comparing the code you have for 1 and 2 to see how/where they end up sharing the same objects.

                     

                    If you have any provision for making all of the files involved with this available for download, that might prove helpful, though I might not be able to open them.