Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

make Default scrollpane component Smoother

Participant ,
Jan 29, 2013 Jan 29, 2013

hi

i found some manual scrolling content project and tutorial from the web and the scrolling is very smooth and fast ...

in Scrollpane component there are no any setting for changing speed or something like that .

is there any chance to edit setting or add some script to move scrollbar faster and smoother ...

it will be great if the height of scrollbar can be changeable too ...

thanks

TOPICS
ActionScript
2.6K
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines

correct answers 1 Correct answer

Community Expert , Jan 29, 2013 Jan 29, 2013

no, don't change the name of the class.  use:

_scrollbar1 = new Scrollbar();
_scrollbar1.init(content1, contentMask1, track1, slider1);

_scrollbar2 = new Scrollbar();
_scrollbar2.init(content2, contentMask2, track2, slider2);

Translate
Community Expert ,
Jan 29, 2013 Jan 29, 2013

it's almost always easier to make your own custom component than to use the default component, if the default doesn't work the way you want.

in this instance, it will be easier to make your own scrollpane (or use someone else's) than to use the default scrollpane.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Participant ,
Jan 29, 2013 Jan 29, 2013

thanks kglad , but i search around web and must of free scrollbar present as Flash Project and not component

they use mask technics for scrollbar and cant load Dynamic content easy like Scrollpane content

i have many scrollpane in my project now and it will take time and be hard to replace all of them with some new scrollbar

and there is one important problem for me in most of them :

they use a name and instance name for the content as movieclip ( for example must call " content " )

so i dont know how i must use this for more than 1 time in my project !! 

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Jan 29, 2013 Jan 29, 2013

i'm not sure what your last question is.  are you asking how to use more than 1 scrollpane in your project?

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Participant ,
Jan 29, 2013 Jan 29, 2013

yes but not for default scrollpane component ,,,

in all other scrollbar tutorial in other sites i see they define a mask and scrollbar and content in script with special names

so it will be easy to use for one scrollbar project but when you have many you must edit many things and script everytime you want to use ...

cause the duplicate error comes in normal or test movie mode

for example i really love this scrollbar it`s really smooth ...

http://www.freeactionscript.com/2011/07/scroller-dynamic-scrollbar-v2/

he define scrollbar.as and some class folder !!

and i must rename or change objects everytime i want use it ...

--------------------------------------------------------------------------------------

and another thing i found scrollbar.as and scrollpane class in Adobe Flash Cs5 folders , but nothing change when i change it or even Remove all of it !!

what`s them ?  and why the changes not apear in my project ?!

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Jan 29, 2013 Jan 29, 2013

no, don't change the name of the class.  use:

_scrollbar1 = new Scrollbar();
_scrollbar1.init(content1, contentMask1, track1, slider1);

_scrollbar2 = new Scrollbar();
_scrollbar2.init(content2, contentMask2, track2, slider2);

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Participant ,
Jan 30, 2013 Jan 30, 2013

thanks but where i must put this code ?

cause when i add this as script in frame 1 of my project i got error :

1120: Access of undefined property _scrollbar1.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Jan 30, 2013 Jan 30, 2013

If you want the smoothest, you need GPU, so you need Stage3D. Take a look at FeathersUI which wraps Starling and Stage3D and provides GPU accelerated components.

Play with some of these:

http://feathersui.com/examples/components-explorer/

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Participant ,
Feb 01, 2013 Feb 01, 2013

now i solve my problem to use dynamic script scrollbar thanks to kglad ...

but now i have another Problem :

when i use scrollbar in main stage and frames everythings is fine ...

but i need to use and put various scrollbar windows in 1 frame so i need to put my scrollbar in Movieclip ....

after i cut and paste all frames of my scrollbar ( content , mask , scrollbar , ... ) and test movie i got error and the scroller not work any longer

the error is :

TypeError: Error #1009: Cannot access a property or method of a null object reference.

    at com.freeactionscript::Scrollbar/init()

    at Main()

the script in Main.as file is :

/**

* Scrollbar

* ---------------------

* VERSION: 2.0

* DATE: 5/04/2011

* AS3

* UPDATES AND DOCUMENTATION AT: http://www.FreeActionScript.com

**/

package 

{

    import flash.display.MovieClip;

    import flash.events.Event;

    import flash.events.MouseEvent;

   

    import com.freeactionscript.Scrollbar;

   

    public class Main extends MovieClip

    {

        // assets on stage

        public var content:MovieClip;

        public var contentMask:MovieClip;

        public var track:MovieClip;

        public var slider:MovieClip;

       

        // vars

        private var _scrollbar:Scrollbar;

       

        /**

         * Constructor

         */

        public function Main()

        {

            _scrollbar = new Scrollbar();

            _scrollbar.init(content, contentMask, track, slider);

        }

    }

   

}

and the script in scrollbar.as is :

/**

* Scrollbar

* ---------------------

* VERSION: 2.0

* DATE: 5/04/2011

* AS3

* UPDATES AND DOCUMENTATION AT: http://www.FreeActionScript.com

**/

package com.freeactionscript

{

    import flash.display.MovieClip;

    import flash.display.Sprite;

    import flash.display.Stage;

    import flash.events.Event;

    import flash.events.MouseEvent;

    import flash.geom.Rectangle;

   

    import com.greensock.TweenLite;

    import com.greensock.easing.*;

   

    public class Scrollbar extends Sprite

    {

        // scrollbar assets

        private var _content:MovieClip;

        private var _contentMask:MovieClip;

        private var _slider:MovieClip;

        private var _track:MovieClip;

       

        // vars

        private var _scrollSpeed:Number = .5; // seconds to movie to new position

        private var _scrollWheelSpeed:int = 10; // pixels per tick

        private var _root:Stage;

       

        /**

         * Initialize method

         *

         * @param    $content        Main content container

         * @param    $contentMask    Content mask. Masking is set dynamically. Do not set mask on the timeline.

         * @param    $track            The track of the scrollbar

         * @param    $slider            The slider (dragger)

         * @param    $scrollSpeed    The speed at which the content movies

         */

        public function init($content:MovieClip, $contentMask:MovieClip, $track:MovieClip, $slider:MovieClip, $scrollSpeed:Number = .5):void

        {

            // save passed objects and variables

            _content = $content;

            _contentMask = $contentMask;

            _slider = $slider;

            _track = $track;

            _scrollSpeed = $scrollSpeed;

           

            // give content a mask

            _content.mask = _contentMask;

           

            // save a reference to the stage

            _root = _slider.parent.stage;   

           

            // hide scrollbar assets for now

            _slider.visible = false;

            _track.visible = false;

           

            // enable scrollbar interactivity

            enable();

        }

       

        /**

         * Enable Scrollbar interaction

         */

        public function enable():void

        {

            // make dragger a button

            _slider.buttonMode = true;

           

            // add event listeners

            _slider.addEventListener(MouseEvent.MOUSE_DOWN, onMouseDownHandler);

            _root.addEventListener(MouseEvent.MOUSE_WHEEL, onMouseWheelHandler);

            _root.stage.addEventListener(MouseEvent.MOUSE_UP, onMouseUpHandler);

           

            // check if scrollbar is needed

            verifyHeight();

        }

       

        /**

         * Disable Scrollbar interaction

         */

        public function disable():void

        {

            // make dragger not a button

            _slider.buttonMode = false;

           

            // remove event listeners

            _slider.removeEventListener(MouseEvent.MOUSE_DOWN, onMouseDownHandler);

            _root.removeEventListener(MouseEvent.MOUSE_WHEEL, onMouseWheelHandler);

            _root.removeEventListener(MouseEvent.MOUSE_UP, onMouseUpHandler);

        }

       

        /**

         * On mouse wheel handler

         * @param    $event    Takes MouseEvent argument

         */

        private function onMouseWheelHandler($event:MouseEvent):void

        {

            // define parameters

            var scrollDistance:int = $event.delta;

            var minY:int = _track.y;

            var maxY:int = _track.height + _track.y - _slider.height;

           

            // check if there's room to scroll

            if ((scrollDistance > 0 && _slider.y <= maxY) ||

                (scrollDistance < 0 && _slider.y >= minY))

            {

                // move dragger

                _slider.y = _slider.y - (scrollDistance * _scrollWheelSpeed);

               

                // make sure we don't come out of our boundries

                if (_slider.y < minY)

                {

                    _slider.y = minY;

                }

                else if (_slider.y > maxY)

                {

                    _slider.y = maxY;

                }

               

                // move content

                updateContentPosition();

            }

        }

       

        /**

         * On mouse down handler

         * @param    $event    Takes MouseEvent argument

         */

        private function onMouseDownHandler($event:MouseEvent):void

        {

            var newRect:Rectangle = new Rectangle(_track.x, _track.y,

                                                  0, _track.height - _slider.height);

            _slider.startDrag(false, newRect);

            _root.addEventListener(Event.ENTER_FRAME, updateContentPosition);

        }

       

        /**

         * On mouse up handler

         * @param    $event    Takes MouseEvent argument

         */

        private function onMouseUpHandler($event:MouseEvent):void

        {

            _slider.stopDrag();

           

            if (_root != null)

            {

                _root.removeEventListener(Event.ENTER_FRAME, updateContentPosition);

            }

        }

       

        /**

         * Update content position

         * @param    $event    Takes optional Event argument

         */

        private function updateContentPosition($event:Event = null):void

        {

            var _scrollPercent:Number =  100 / (_track.height - _slider.height)  * ( _slider.y - _track.y);

            var newContentY:Number = _contentMask.y + (_contentMask.height - _content.height) / 100 * _scrollPercent;

            TweenLite.to(_content, _scrollSpeed, {y:newContentY, ease:Cubic.easeOut});

        }

       

        /**

         * Position Slider based on where the content is.

         * Use this function if content is being moved by anything outside the scrollbar class

         */

        public function updateSliderPosition():void

        {

            var contentPercent:Number = Math.abs((_content.y - _contentMask.y) / (_content.height - _contentMask.height) * 100);

           

            var newDraggerY:int = (contentPercent / 100 * (_track.height - _slider.height)) + _track.y;

           

            _slider.y = newDraggerY;

        }

       

        /**

         * Check if scrollbar is necessary

         */

        public function verifyHeight():void

        {

            if ( _contentMask.height >= _content.height )

            {

                _slider.visible = false;

                _track.visible = false;

            }

            else

            {

                _slider.visible = true;

                _track.visible = true;

            }

        }

       

        /**

         * Garbage collection method

         */

        public function destroy():void

        {

            // check if dragger is being dragged

            if (_root.hasEventListener(Event.ENTER_FRAME))

            {

                _slider.stopDrag();

                _root.removeEventListener(Event.ENTER_FRAME, updateContentPosition)

            }

           

            // disable interaction

            disable();

        }

    }

}

please help me , i really try many things and no success , this forum is my only hope ...

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Feb 01, 2013 Feb 01, 2013

click file>publish settings>swf and tick "permit debugging".  retest and the problematic line number will be in the error message.  indicate which line of code that is.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Participant ,
Feb 01, 2013 Feb 01, 2013

this is what i got after do what you say :

TypeError: Error #1009: Cannot access a property or method of a null object reference.

    at com.freeactionscript::Scrollbar/init()

    at Main()

the script is :

_scrollbar.init(content, contentMask, track, slider);

_content.mask = _contentMask;

what i must do ?! 

is there need add any movieclip name suffix or prefix to these script ?!

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Participant ,
Feb 02, 2013 Feb 02, 2013

Any hope or idea for solve this ?!

i really need this

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Feb 02, 2013 Feb 02, 2013

which is line 53 in Scrollbar.as?

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Participant ,
Feb 02, 2013 Feb 02, 2013

kglad wrote:

which is line 53 in Scrollbar.as?

_content.mask = _contentMask;

thanks for replaying dear kglad

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Participant ,
Feb 03, 2013 Feb 03, 2013

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Participant ,
Feb 06, 2013 Feb 06, 2013
LATEST

well i solve putting scrollbar in movieclip with some help from Dear philip Radvan

i just add .mc (mc is instance name of my movieclip that containes scrollbars )to my code :




_scrollbar.init(mc.content, mc.contentMask, mc.track, mc.slider);

everything work well when i have only 1 scrollbar ,but when i add more than one scrollbar content with new instance name ( in frame 2,3,4 ) i get error !!

these are errors when i test movie :

Symbol 'mc', Layer 'Layer 10', Frame 2, Line 11120: Access of undefined property _scrollbar.
Symbol 'mc', Layer 'Layer 10', Frame 2, Line 11180: Call to a possibly undefined method Scrollbar.
Symbol 'mc', Layer 'Layer 10', Frame 2, Line 21120: Access of undefined property _scrollbar.
Symbol 'mc', Layer 'Layer 10', Frame 2, Line 21120: Access of undefined property mc.
Symbol 'mc', Layer 'Layer 10', Frame 2, Line 21120: Access of undefined property mc.
Symbol 'mc', Layer 'Layer 10', Frame 2, Line 21120: Access of undefined property mc.
Symbol 'mc', Layer 'Layer 10', Frame 2, Line 21120: Access of undefined property mc.

i just put these script in Layer 10 , frame2 :

_scrollbar = new Scrollbar();

_scrollbar.init(mc.content1, mc.contentMask1, mc.track1, mc.slider1);

whats the Problem ?!?  


Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines