Custom Scroll Bar With Buttons
Still trying to get a handle on Flash, but I'm want to create scroll bar and buttons to control a dynamic text box. I understand the AS of scroll +=1 to control the text through the buttons, but how do I have the scroll bar react to the scroll button activation as well as move the scroll bar to move the dynamic text.
I've searched all over and I want to avoid using the components as I'm trying to fit a certain design parameters.
And a seperate question - custom skinning the component, is that just changing global colors or can I replace them with custom graphics?
Thanks
Ultrashock Forums > Flash > Flash Newbie
Posted on: 2005-09-16
View Complete Forum Thread with Replies
See Related Forum Messages: Follow the Links Below to View Complete Thread
Custom Scroll Buttons
Hi, ok so here is my site, and what i want to do is to create the two triangular buttons and make them scroll the text up and down. Now i could use masks and all that but its dynamic text and i just wandered if there was anything a bit nicer to use than masks, as they can get quite messy.
http://nighthawkgraphics.deviantart....sign-100841332
Custom Scroll Buttons And More
If I have a flash movie with 4 buttons and each button loads an external text file into a dynamic text box with a scrollbar. I get all that to work fine.
My question; Instead of the scrollbar component I make two buttons with scroll up and scroll down capability (they work fine on their own if I just type a message into the text box) but I can't get them to work properly with the external loaded documents.
Also; are there any tutorials on how to create a flash mx expanding, folding menu tree. Vetical or horizontal.
Thank you
Freakin Custom Scroll Buttons
Hello Jake the Arab here:
Ok I need some help! On my website I have a virtual menu, and each button has it’s own MC called let’s say Main (for the main button) and in this MC when the buttons is clicked it slides down to the bottom of the page then over, when the buttons done moving a window fades in. the problem I have is my custom scroll buttons don’t scroll the text box that has imported text in it, in the window. Yet when I put the scroll buttons & text box in the _root. (Or main stage) it works fine. But when I move it into a MC of its own…. It doesn’t work at all. I change the action script to the right targets but still nothing.
So if anyone can help or give me and .fla file it would be greatly appreciated.
Thanks in advance.
-Jake
P.S.
For a better understanding of my site setup go here: Unoriginal Design
on the site that uploaded i just have default scroll bar. all i wanted to do was make my own. But can't. also the text is not imported from an External .txt file.
Having Trouble With Custom Scroll Buttons
I made my own scroll buttons ( just up and down arrows ). Everything worked all nice until i put everything I made into a movieclip. Now the scroll buttons won't work. I've attached the .fla if anyone is interested in helping me.
http://www.clanunf.com/Testing.fla
Custom Buttons For Listbox Scroll
Hi Folks
I was trying to create 2 custom buttons for the Listbox component
The up button scrolls the list up and the Down button scrolls the list down by 1 visible list screen length
Any help would be appreciated
Thanks
RG
I Need A Custom Scroll Bar For An Image With Buttons Going To Specific Parts Of It
I want to make my own HORIZONTAL scrolling scrollbar for an image, with buttons to go to specific parts of the image. A scrollbar I am trying to emulate is on www.towardsthesky.com, click on any of the image porfolios to see an example of what I am trying to do. Can anyone tell me how to make my own or point me to a good tutorial for what I am describing? If anyone could tell me how they think the portfolios on that site where done I would appreciate it to. I have asked the guy who does the site and havn't gotten any response. Thanks.
I Need A Custom Scroll Bar For An Image With Buttons Going To Specific Parts Of It
I want to make my own HORIZONTAL scrolling scrollbar for an image, with buttons to go to specific parts of the image. A scrollbar I am trying to emulate is on www.towardsthesky.com click on any of the image porfolios to see an example of what I am trying to do. Can anyone tell me how to make my own or point me to a good tutorial for what I am describing? If anyone could tell me how they think the portfolios on that site where done I would appreciate it to. I have asked the guy who does the site and havn't gotten any response. Any help will be appreciated. Thanks.
I Need A Custom Scroll Bar For An Image With Buttons Going To Specific Parts Of It
I want to make my own HORIZONTAL scrolling scrollbar for an image, with buttons to go to specific parts of the image. A scrollbar I am trying to emulate is on www.towardsthesky.com click on any of the image porfolios to see an example of what I am trying to do. Can anyone tell me how to make my own or point me to a good tutorial for what I am describing? If anyone could tell me how they think the portfolios on that site where done I would appreciate it to. I have asked the guy who does the site and havn't gotten any response. Any help will be appreciated. Thanks.
I Need A Custom Scroll Bar For An Image With Buttons Going To Specific Parts Of It
I want to make my own HORIZONTAL scrolling scrollbar for an image, with buttons to go to specific parts of the image. A scrollbar I am trying to emulate is on www.towardthesky.com click on any of the image porfolios to see an example of what I am trying to do. Can anyone tell me how to make my own or point me to a good tutorial for what I am describing? If anyone could tell me how they think the portfolios on that site where done I would appreciate it to. I have asked the guy who does the site and havn't gotten any response. Any help will be appreciated. Thanks.
I Need A Custom Scroll Bar For An Image With Buttons Going To Specific Parts Of It
I want to make my own HORIZONTAL scrolling scrollbar for an image, with buttons to go to specific parts of the image. A scrollbar I am trying to emulate is on www.towardthesky.com click on any of the image porfolios to see an example of what I am trying to do. Can anyone tell me how to make my own or point me to a good tutorial for what I am describing? If anyone could tell me how they think the portfolios on that site where done I would appreciate it to. I have asked the guy who does the site and havn't gotten any response. Any help will be appreciated. Thanks.
I Need A Custom Scroll Bar For An Image With Buttons Going To Specific Parts Of It
I want to make my own HORIZONTAL scrolling scrollbar for an image, with buttons to go to specific parts of the image. A scrollbar I am trying to emulate is on www.towardthesky.com click on any of the image porfolios to see an example of what I am trying to do. Can anyone tell me how to make my own or point me to a good tutorial for what I am describing? If anyone could tell me how they think the portfolios on that site where done I would appreciate it to. I have asked the guy who does the site and havn't gotten any response. Any help will be appreciated. Thanks.
Adding Buttons With Instance Names Into A Custom Scroll
I have created a custom scroll to view a list of my portfolio pieces. the action script looks like this with scroller_mc being the instance name of the vertical scroller and printnames_mc the instance of the names of my pieces.
var scrollUpper:Number = 229;
var scrollLower:Number = 374;
var textLower:Number = 229;
var textUpper:Number = 187;
var scrollRange:Number = scrollLower - scrollUpper;
var textRange:Number = textLower -textUpper;
function scroll() {
var moved:Number = scroller_mc._y - scrollUpper;
var pctMoved:Number = moved/scrollRange;
var textMove:Number = pctMoved*textRange;
printnames_mc._y = textLower - textMove;
}
scroller_mc.onPress = function () {
startDrag(scroller_mc,false,this._x, scrollUpper,this._x,scrollLower);
this.onMouseMove = scroll;
}
scroller_mc.onRelease = scroller_mc.onReleaseOutside = function() {
this.stopDrag();
this.onMouseMove = null;
}
the problem with this is when I try to add buttons that use actionscript to load images into a main loader inside the printnames_mc object it does not work? is there a way to create a custom scroll that can scroll through buttons with instance names? Any help would be great!!!!!!!! thanks
Custom Scroll Buttons With Dynamic Text Load
I have a dynamic text box called "news". I also have 2 custom scroll buttons on a different layer labeled "upbutton" and "downbutton".
I applied this action to my "news" text box:
scrollText = function (news) {
about.scroll += news;
};
upbutton.news = -1;
downbutton.news = 1;
upbutton.onRollOver = downbutton.onRollOver =function () {
scrollInt = setInterval (scrollText, 1000/24, this.news);
};
upbutton.onRollOut = downbutton.onRollOut =function () {
clearInterval (scrollInt);
};
What am I doing wrong? It wont scroll. The text I use is called from an external text file called news.txt
Any ideas? I attached my .FLA file and news.txt
Linking Text Buttons In Scroll To Image Outside Scroll Area
Hi,
I am desperately hitting my head against a brick wall - so please help me!
I have created a flash area that is divided up with an image on top and a scroll area under.
I am trying to get the text buttons in the scroll area to each change the image above and cant seem to get it to work because of the masking.
I have tried heaps and heaps of different ways and am going crazy!
PLEASE HELP ME!!!!
thanks,
kova
Custom Scroll Bar
Can anyone tell me how to make a Scrollpane Scroll Bar from scratch??? I'd like to hover the mouse the up/down arrow and make it move that way.
Custom Scroll
Hi,
I've found this code for scrolling a text field and its nice and simple for flash mx but it's too fast is there a way to slow it down?
I tried usign numbers less than 1 but it wont work of course ...
onClipEvent ( enterFrame ) {
if (lPressed) {
_parent.sTextA.scroll += 1;
}
}
Is there a better scrolling solution for dynamic text loaded froma a file??? I found tons of scrolling samples but they mainly use limmited size layers and are hard to customize visually. Please any good ideas or examples would be welcome.(I don't mind if scrollers uses buttons or a scrollbar)
Cheers
Custom Scroll Bar
I'm trying to create a custom scoll bar in Flash 8. I made a copy of the HaloTheme.fla and renamed it. Then I've gone into that and changed colors, sizes etc of various VScrollbar assets. I've had good success changing the top and bottom arrows and some luck with the scroll track.
But I can't find a way to modify the center scroll bar that you drag up and down with the mouse. All I want is a simple white rectangle. I've modified everything in VScrollbar assets and cant make it change.
Any ideas on how to change the look of that?
Thanks!
Custom Scroll
Hi,
I am trying to create something like this at the URL below....go to the work section and then click on logos/icons. Notice how the logos scroll across and come to a stop as you click on the arrow buttons. How is this achieved?
Here is the URL...
http://turnstylestudio.com/
Thanks
Custom Scroll
Hey All,
I am trying to use a custom scroll I found and need some helping tweaking it.
How do I get this scroll to go to direct positions such as;
Top(x=373.1, y=128)
bottom(x=386.8, y=441.2)
Position code:
var scrollHeight:Number = scrollTrack._height;
var contentHeight:Number = contentMain._height;
var scrollFaceHeight:Number = scrollFace._height;
var maskHeight:Number = maskedView._height;
var initPosition:Number = scrollFace._y=scrollTrack._y;
var initContentPos:Number = contentMain._y;
var finalContentPos:Number = maskHeight-contentHeight+initContentPos;
var left:Number = scrollTrack._x;
var top:Number = scrollTrack._y;
var right:Number = scrollTrack._x;
var bottom:Number = scrollTrack._height-scrollFaceHeight+scrollTrack._y;
var dy:Number = 0;
var speed:Number = 10;
var moveVal:Number = (contentHeight-maskHeight)/(scrollHeight-scrollFaceHeight);
Thanks!
Custom Scroll Bar
I want to be able to customize my scroll bar on my site The Apple Book. I have been looking around on a way for a while. I am willing to recreate the scroll bar but it should include the middle track bar.
Thanks in advance
Custom Scroll Bar
Good day,
I have designed a scrollbar in Photoshop and have found a way to use it
here: Test1, as you can see on the first page, the scroll bar goes up and down (for the most part fine). but i dont know how to use the scroll bar to scroll the text box.
here is my code so far (i know its simple, but i am learning), this is on an "actions" layer:
Code:
var bounds = new Rectangle(853,137,0,250)
function StartDrag(e:MouseEvent):void{
e.target.startDrag(false, bounds);
}
function StopDrag(e:MouseEvent):void{
e.target.stopDrag();
}
and this is on the first frame of a "page" (using flagged frames for each page):
Code:
HomeScroll_mc.addEventListener(MouseEvent.MOUSE_DOWN, StartDrag);
HomeScroll_mc.addEventListener(MouseEvent.MOUSE_UP, StopDrag);
HomeScroll_mc.addEventListener(MouseEvent.MOUSE_OUT,StopDrag);
Please Advise, and if i am unclear please feel free to ask questions.
***EDIT: the textbox in the first frame is a movie clip named "HomeContent_mc"
Thanks
-Forestknight
Custom Scroll Bar
I am putting in static text and I want to be able to scroll through it. I've read about putting a mask on it and using the scroll bar component. But I'm wanting to use my own scroll buttons. Is this possible with static text? Or do I need to embed text in a dynamic text field to use the scroll?
Custom Scroll Bar
http://www.motiongerm.com/main.html
can someone help me create this kind of scroll bar. all the tutrorals on this site seem to use the components.
Custom Scroll Bar Help
sorta kinda somethin like this....
arrows make the text or window move up and down and grabing the line does the same thing as a normal window....
no idea how to do it
Custom Scroll Bar TUT?
anyone know of a good place to find a good tutorial on a custom scroll bar in flash.
thanks
AL
Custom Scroll Bar
I have worked a little with flash before, and a lot with Adobe Photoshop. I have made a nice background which I am using for my site, and have the buttons worked out and all. My problem at this point is the scrollbar that flash provides in there component UI looks horrid with the theme I have going. I really just want to have an arrow pointing down and one point up in order to scroll the dynamic text. I have created these images of up and down arrows in photoshop and just don't know how to make them do what I want them to. Pease help!
Custom Scroll BAr
Hello guys i was wondering whether you all can help me out in a custom scroll bar. I know the action script for making the up and down buttons which is:
on (press) {text.scroll+=1 and on (press) {text.scroll-=1
}
}
But i am not sure about the action script for the scroll bar. Can anyone help me with this plz. I thank you in advance.
Custom Scroll Bar
hi,
my aim is to create a custom scroll bar, prefferably one that scrolls movie clips. i have tried a very extensive one but it didnt work at the end of it.
this was ; http://www.tutorialized.com/view/tut...in-Flash/27745
if anyone knows how to make one or how to tweak the action script in this example to make the text scroll with the scroll mc please let me know asap.
thanks alot
chris
Custom Scroll Bar
http://www.motiongerm.com/main.html
can someone help me create this kind of scroll bar. all the tutrorals on this site seem to use the components.
Custom Scroll Bar Help
sorta kinda somethin like this....
arrows make the text or window move up and down and grabing the line does the same thing as a normal window....
no idea how to do it
Custom Scroll Bar
hi everyone.
can anyone help me with this problem i have. i would like to have some dynamic text to scoll down through, but without using the component already in flash. i would like to customise it myself. i would really like the actionscript for this please. can anyone help me?
thnkas tristan
How Do I Make A Custom Scroll Bar
i want to be able to have a scroll bar (of my design and response) that scrolls through body text within a MC. is it as simple as embeding another MC with in my current (primary) movie-clip?
any suggestions would help.
\thanks
drew
Custom Scroll Pane
Can anyone tell me how to make a custom scroll pane in MX, cause I don't like the lined border on the premade one in MX.
Please explane it step by step cause I'm not very bright when it comes to these things.
Thanks in advance!
Custom Scroll Bar Issue
I'm trying to build a scroll bar (and a scroll pane) because I was having difficulty customizing the built-in scroll bar component.
I'm trying to make one of the arrow buttons continually move the slider as it is pressed, i.e. you hold the mouse button down and the content scrolls.
I tried to do it like this:
sliderBar.rightArrow.onPress = function() {
sliderBar.rightArrow.active = true;
while (sliderBar.rightArrow.active) {
sliderBar.slide._x++;
if (sliderBar.slide._x > 380) {
sliderBar.slide._x = 380;}
updateAfterEvent;
}
}
sliderBar.rightArrow.onRelease = function() {
sliderBar.rightArrow.active = false;
}
sliderBar.rightArrow.onReleaseOutside = function() {
sliderBar.rightArrow.active = false;
}
But the while statement hangs the movie, despite releasing the mouse buttons. Is there another way?
Custom Scroll Bars?
how do you make your own scroll bar?... and do all the scroll bars in flash, are you not able to use the scrolly wheel instead of dragging the bar? like on this window you can use the scroll wheel(on some mouses) and it seems like all the ones made in flash you cant, or can you make one that does... or can you use html to create a colored scroll bar in flash. i know how to create colored html scroll bars, but is there a way to put those in swf movies and make it so you can use the little wheel?
anyone know? =)
itll help a lot for my web site www.bigdogcrew.com
Custom Scroll Bar Question
hey guys, i made a custom scroll bar but i dont know actionscript at all and the tutorials are only confusing me more. i just want to have a button that when you click and drag it down it will move a graphic down, and up also. can anyone explain this to me, like the actionscripts and where to put them?
Regards,
Travis
Custom Scroll Bars
I have a part on my website that contains some information. I have more info than space. I need to put the text in a scrolling window but I don't want to use the basic one that Flash already provides. How do I create a custom scrolling window? I have a book that shows one way to do it, but there's tons of action scripting... is there a simpler method?
Custom Scroll Bars
i cant seem to figure out how to create custom scroll bars. Is there a good tutorial on how to do it? if there is PLEASE tell me.
Custom Scroll Bars.
is there a simple way to just edit the scroll bars in a scrollPlane? i know older versions of flash made it really easy, but i cant see to figure it out now.
Custom Scroll Pane
Is there someone kind enough to point me to a right direction to build a custom scroll pane?
Usually seen in some portfolio sites, where they list all the projects inside a scroll pane...
thanx =)
Custom Scroll Bar That Should Work
so i have made a few horizontal custom slider bars quite easily. by making 2 movie clips. setting the "bar's" x and y values as the bounds and everything works great. but for some reason i can't get it to work vertically. i use the same code and even try switching the x and y values....but nothing. the scroller movie clip jumps all over the screen and can barely move. my code is below. thanks for any help.
Code:
var sliderbounds:Rectangle = new Rectangle(scrollTrackMC.y, scrollTrackMC.x, scrollTrackMC.width, 12);
sliderMC.addEventListener(MouseEvent.MOUSE_DOWN, startdrag)
sliderMC.addEventListener(MouseEvent.MOUSE_UP, stopdrag)
function startdrag(myevent:MouseEvent):void{
myevent.target.startDrag(false, sliderbounds);
}
function stopdrag(myevent:MouseEvent):void{
myevent.target.stopDrag();
}
[F8]custom Scroller Needs To Scroll A Mc
The custom scroller worked fine scrolling a text box but now I need it to scroll a movie clip (as I want seperate boxes pulling in a picture, text, etc. from an xml file).
Any help in what I need to change is appreciated.
Here's the scroller actionscript:
#initclip 1
/*
FScrollBarClass
EXTENDS FUIComponentClass
*/
FScrollBarClass = function()
{
if (this._height==4) {
return;
}
this.init();
this.minPos = this.maxPos = this.pageSize = this.largeScroll = 0;
this.smallScroll = 1;
this.width = (this.horizontal) ? this._width : this._height;
this._xscale = this._yscale = 100;
this.setScrollPosition(0);
this.tabEnabled = false;
if ( this._targetInstanceName.length > 0 ) {
this.setScrollTarget(this._parent[this._targetInstanceName]);
}
this.tabChildren = false;
this.setSize(this.width);
}
FScrollBarClass.prototype = new FUIComponentClass();
// ::: PUBLIC METHODS
FScrollBarClass.prototype.setHorizontal = function(flag)
{
if (this.horizontal && !flag) {
this._xscale = 100;
this._rotation = 0;
} else if (flag && !this.horizontal) {
this._xscale = -100;
this._rotation = -90;
}
this.horizontal = flag;
}
// updates the thumb, turns the bar on and off
FScrollBarClass.prototype.setScrollProperties = function(pSize, mnPos, mxPos)
{
if (!this.enable) {
return ;
}
this.pageSize = pSize;
this.minPos = Math.max(mnPos, 0);
this.maxPos = Math.max(mxPos,0);
this.scrollPosition = Math.max(this.minPos, this.scrollPosition);
this.scrollPosition = Math.min(this.maxPos, this.scrollPosition);
if (this.maxPos-this.minPos<=0) { // turn it off
this.scrollThumb_mc.removeMovieClip();
this.upArrow_mc.gotoAndStop(3);
this.downArrow_mc.gotoAndStop(3);
this.downArrow_mc.onPress = this.downArrow_mc.onRelease = this.downArrow_mc.onDragOut = null;
this.upArrow_mc.onPress = this.upArrow_mc.onRelease = this.upArrow_mc.onDragOut = null;
this.scrollTrack_mc.onPress = this.scrollTrack_mc.onRelease = null;
this.scrollTrack_mc.onDragOut = this.scrollTrack_mc.onRollOut = null;
this.scrollTrack_mc.useHandCursor = false;
} else { // turn it on
var tmp = this.getScrollPosition();
this.upArrow_mc.gotoAndStop(1);
this.downArrow_mc.gotoAndStop(1);
this.upArrow_mc.onPress = this.upArrow_mc.onDragOver = this.startUpScroller;
this.upArrow_mc.onRelease = this.upArrow_mc.onDragOut = this.stopScrolling;
this.downArrow_mc.onPress = this.downArrow_mc.onDragOver = this.startDownScroller;
this.downArrow_mc.onRelease = this.downArrow_mc.onDragOut = this.stopScrolling;
this.scrollTrack_mc.onPress = this.scrollTrack_mc.onDragOver = this.startTrackScroller;
this.scrollTrack_mc.onRelease = this.stopScrolling;
this.scrollTrack_mc.onDragOut = this.stopScrolling;
this.scrollTrack_mc.onRollOut = this.stopScrolling;
this.scrollTrack_mc.useHandCursor = false;
this.attachMovie("ScrollThumb", "scrollThumb_mc", 3);
this.scrollThumb_mc._x = 0;
this.scrollThumb_mc._y = this.upArrow_mc._height;
this.scrollThumb_mc.onPress = this.startDragThumb;
this.scrollThumb_mc.controller = this;
this.scrollThumb_mc.onRelease = this.scrollThumb_mc.onReleaseOutside = this.stopDragThumb;
this.scrollThumb_mc.useHandCursor=false;
this.thumbHeight = this.pageSize / (this.maxPos-this.minPos+this.pageSize) * this.trackSize;
this.thumbMid_mc = this.scrollThumb_mc.mc_sliderMid;
this.thumbTop_mc = this.scrollThumb_mc.mc_sliderTop;
this.thumbBot_mc = this.scrollThumb_mc.mc_sliderBot;
this.thumbHeight = Math.max (this.thumbHeight, 6); // 6 is the smallest a thumb should be
this.midHeight = this.thumbHeight - this.thumbTop_mc._height - this.thumbBot_mc._height;
this.thumbMid_mc._yScale = this.midHeight * 100 / this.thumbMid_mc._height;
this.thumbMid_mc._y = this.thumbTop_mc._height;
this.thumbBot_mc._y = this.thumbTop_mc._height + this.midHeight;
this.scrollTop = this.scrollThumb_mc._y;
this.trackHeight = this.trackSize - this.thumbHeight;
this.scrollBot = this.trackHeight + this.scrollTop;
tmp = Math.min(tmp, this.maxPos);
this.setScrollPosition(Math.max(tmp, this.minPos));
}
}
FScrollBarClass.prototype.getScrollPosition = function ()
{
return this.scrollPosition;
}
FScrollBarClass.prototype.setScrollPosition = function(pos)
{
this.scrollPosition = pos;
if (this.scrollThumb_mc!=undefined) {
pos = Math.min(pos, this.maxPos);
pos = Math.max(pos, this.minPos);
}
this.scrollThumb_mc._y = ((pos-this.minPos) * this.trackHeight / (this.maxPos-this.minPos)) + this.scrollTop;
this.executeCallBack();
}
FScrollBarClass.prototype.setLargeScroll = function(lScroll)
{
this.largeScroll = lScroll;
}
FScrollBarClass.prototype.setSmallScroll = function(sScroll)
{
this.smallScroll = sScroll;
}
FScrollBarClass.prototype.setEnabled = function(enabledFlag)
{
var wasEnabled = this.enable;
if (enabledFlag && !wasEnabled) {
this.enable = enabledFlag;
//if (this.textField!=undefined) {
//this.setScrollTarget(this.textField);
} else {
this.setScrollProperties(this.pageSize,
this.cachedMinPos, this.cachedMaxPos);
this.setScrollPosition(this.cachedPos);
}
this.clickFilter = undefined;
} else if (!enabledFlag && wasEnabled) {
this.textField.removeListener(this);
this.cachedPos = this.getScrollPosition();
this.cachedMinPos = this.minPos;
this.cachedMaxPos = this.maxPos;
if (this.clickFilter==undefined) {
this.setScrollProperties(this.pageSize,0,0);
} else {
this.clickFilter=true;
}
this.enable = enabledFlag;
}
}
// stretches the track, creates + positions arrows
FScrollBarClass.prototype.setSize = function(hgt)
{
if (this._height==1) return;
this.width = hgt;
this.scrollTrack_mc._yscale = 100;
this.scrollTrack_mc._yscale = 100 * this.width / this.scrollTrack_mc._height;
if (this.upArrow_mc==undefined) {
this.attachMovie("UpArrow", "upArrow_mc", 1); //1 is arbitrary
this.attachMovie("DownArrow", "downArrow_mc", 2); //2 is arbitrary
this.downArrow_mc.controller = this.upArrow_mc.controller = this;
this.upArrow_mc.useHandCursor = this.downArrow_mc.useHandCursor = false;
this.upArrow_mc._x = this.upArrow_mc._y = 0;
this.downArrow_mc._x = 0;
}
this.scrollTrack_mc.controller = this;
this.downArrow_mc._y = this.width - this.downArrow_mc._height;
this.trackSize = this.width - (2 * this.downArrow_mc._height);
if (this.textField!=undefined) {
this.onTextChanged();
} else {
this.setScrollProperties(this.pageSize, this.minPos, this.maxPos);
}
}
// ::: PRIVATE METHODS
FScrollBarClass.prototype.scrollIt = function (inc, mode)
{
var delt = this.smallScroll;
if (inc!="one") {
delt = (this.largeScroll==0) ? this.pageSize : this.largeScroll;
}
var newPos = this.getScrollPosition() + (mode*delt);
if (newPos>this.maxPos) {
newPos = this.maxPos;
} else if (newPos<this.minPos) {
newPos = this.minPos;
}
this.setScrollPosition(newPos);
}
FScrollBarClass.prototype.startDragThumb = function()
{
this.lastY = this._ymouse;
this.onMouseMove = this.controller.dragThumb;
}
FScrollBarClass.prototype.dragThumb = function()
{
this.scrollMove = this._ymouse - this.lastY;
this.scrollMove += this._y;
if (this.scrollMove<this.controller.scrollTop) {
this.scrollMove = this.controller.scrollTop;
}
else if (this.scrollMove>this.controller.scrollBot) {
this.scrollMove = this.controller.scrollBot;
}
this._y = this.scrollMove;
var c = this.controller;
c.scrollPosition = Math.round( (c.maxPos-c.minPos) * (this._y - c.scrollTop) / c.trackHeight) + c.minPos;
this.controller.isScrolling = true;
updateAfterEvent();
this.controller.executeCallBack();
}
FScrollBarClass.prototype.stopDragThumb = function()
{
this.controller.isScrolling = false;
this.onMouseMove = null;
}
FScrollBarClass.prototype.startTrackScroller = function()
{
this.controller.trackScroller();
this.controller.scrolling = setInterval(this.controller, "scrollInterval", 500, "page", -1);
}
FScrollBarClass.prototype.scrollInterval = function(inc,mode)
{
clearInterval(this.scrolling);
if (inc=="page") {
this.trackScroller();
} else {
this.scrollIt(inc,mode);
}
this.scrolling = setInterval(this, "scrollInterval", 35, inc, mode);
}
FScrollBarClass.prototype.trackScroller = function()
{
if (this.scrollThumb_mc._y+this.thumbHeight<this._ymo use) {
this.scrollIt("page",1);
} else if (this.scrollThumb_mc._y>this._ymouse) {
this.scrollIt("page",-1);
}
}
FScrollBarClass.prototype.stopScrolling = function()
{
this.controller.downArrow_mc.gotoAndStop(1);
this.controller.upArrow_mc.gotoAndStop(1);
clearInterval(this.controller.scrolling);
}
FScrollBarClass.prototype.startUpScroller = function()
{
this.controller.upArrow_mc.gotoAndStop(2);
this.controller.scrollIt("one",-1);
this.controller.scrolling = setInterval(this.controller, "scrollInterval",500, "one", -1);
}
FScrollBarClass.prototype.startDownScroller = function()
{
this.controller.downArrow_mc.gotoAndStop(2);
this.controller.scrollIt("one",1);
this.controller.scrolling = setInterval(this.controller, "scrollInterval", 500, "one", 1);
}
//
// Begin Special text scroller functions
//
FScrollBarClass.prototype.setScrollTarget = function(tF)
{
if (tF == undefined) {
this.textField.removeListener(this);
delete this.textField[ (this.horizontal) ? "hScroller" : "vScroller" ];
if (!(this.textField.hScroller==undefined) && !(this.textField.vScroller==undefined)) {
this.textField.unwatch("text");
this.textField.unwatch("htmltext");
}
}
this.textField = undefined;
if (!(tF instanceof TextField)) return;
this.textField = tF;
this.textField[ (this.horizontal) ? "hScroller" : "vScroller" ] = this;
this.onTextChanged();
this.onChanged = function()
{
this.onTextChanged();
}
this.onScroller = function()
{
if (!this.isScrolling) {
if (!this.horizontal) {
this.setScrollPosition(this.textField.scroll);
} else {
this.setScrollPosition(this.textField.hscroll);
}
}
}
this.textField.addListener(this);
this.textField.watch("text", this.callback);
this.textField.watch("htmlText", this.callback);
}
FScrollBarClass.prototype.callback = function(prop, oldVal, newVal)
{
clearInterval(this.hScroller.synchScroll);
clearInterval(this.vScroller.synchScroll);
this.hScroller.synchScroll = setInterval(this.hScroller, "onTextChanged", 50);
this.vScroller.synchScroll = setInterval(this.vScroller, "onTextChanged", 50);
return newVal;
}
FScrollBarClass.prototype.onTextChanged = function()
{
if (!this.enable || this.textField==undefined) return;
clearInterval(this.synchScroll);
if (this.horizontal) {
var pos = this.textField.hscroll;
this.setScrollProperties(this.textField._width, 0, this.textField.maxhscroll);
this.setScrollPosition(Math.min(pos, this.textField.maxhscroll));
} else {
var pos = this.textField.scroll;
var pageSize = this.textField.bottomScroll - this.textField.scroll;
this.setScrollProperties(pageSize, 1, this.textField.maxscroll);
this.setScrollPosition(Math.min(pos, this.textField.maxscroll));
}
}
FScrollBarClass.prototype.executeCallBack = function()
{
if (this.textField==undefined) {
super.executeCallBack();
} else {
if ( this.horizontal ) {
this.textField.hscroll = this.getScrollPosition();
} else {
this.textField.scroll = this.getScrollPosition();
}
}
}
Object.registerClass("FScrollBarSymbol", FScrollBarClass);
#endinitclip
Custom Scroll Bar Approaches
I’m in the middle of creating a flash application and am creating a custom scroll bar for dynamically loaded text boxes. In previous applications I just used the available components but now I’m going for more of a custom design. Here is my situation…
Linking up textbox.scroll property to the up and down buttons is no problem. Furthermore, linking the scroll thumb to the textbox.scroll property, so the thumb moves with the text, is also easy with textBox.onScroller. The problem is in linking the textbox.scroll to move when the thumb is dragged. The only successful way I can manage this, is to use setInterval when the thumb is being dragged. This works but it seems a poor use of resources.
Would it be best to just learn how to customize a flash scrollbar component, or perhaps use the broadcaster/listener model. I’d like to make my own scrollbar for various reasons, and the broadcaster/listener model makes the most sense to me though I have little experience with them aside from onLoad listeners and a few tutorials I’ve read. I can’t seem to figure out how to broadcast the _y position of the thumb while dragging it.
Any ideas? Am I on the right track?
Creating A Custom Scroll Bar
Hi, what I want is to add a custom made scroll bar to a text box. Using components shows very bad style. How can I do this?
Thanks
Custom Scroll Bar Class
It's a simple thing, for the most part, but for you other newbies out there, like me, here's a scroll bar class for you. Hope this saves you some time!
It assumes you have a target Display Object that is being masked by another display object. Generally, these would both be rectangular or square but this code could be adapted for non-rectangular (or horizontal) requirements.
ActionScript Code:
//Place this function in your parent class.
private var scroller:Scroller;
private function spawnScroller():void {
scroller = new Scroller(theContainer); //theContainer == The target Display Object that you want to scroll.
addChild(scroller);
}
ActionScript Code:
//Scroller.as
package customclass{
import flash.display.Sprite;
import flash.display.DisplayObject;
import flash.display.Shape;
import flash.events.MouseEvent;
import flash.geom.Rectangle;
public class Scroller extends Sprite {
private var containerTarget:DisplayObject;
private var containerMask:DisplayObject;
private var containerOrigin:Number;
private var scrollHandle:Sprite;
private var theLine:Shape;
private var bounds:Rectangle;
public function Scroller(containerObj:DisplayObject):void {
containerTarget = containerObj;
containerMask = containerObj.mask;
containerOrigin = containerTarget.y;
spawnScroller();
this.x = containerMask.x + containerMask.width + scrollHandle.width/2;
this.y = containerMask.y;
}
private function spawnScroller():void {
theLine = new Shape();
theLine.graphics.lineStyle(2, 0x550000);
theLine.graphics.moveTo(0,0);
theLine.graphics.lineTo(0, containerMask.height-1);
addChild(theLine);
scrollHandle = new Sprite();
scrollHandle.graphics.lineStyle(1, 0x550000);
scrollHandle.graphics.beginFill(0x000000, 1);
scrollHandle.graphics.drawRect(0, 0, 20, 20);
scrollHandle.x = 0 - scrollHandle.width/2;
scrollHandle.buttonMode = true;
scrollHandle.mouseChildren = false;
addChild(scrollHandle);
bounds = new Rectangle(scrollHandle.x, scrollHandle.y, 0, containerMask.height - scrollHandle.height);
scrollHandle.addEventListener(MouseEvent.MOUSE_DOWN, beginDrag);
}
private function beginDrag(event:MouseEvent):void {
scrollHandle.removeEventListener(MouseEvent.MOUSE_DOWN, beginDrag);
scrollHandle.startDrag(false, bounds);
scrollHandle.stage.addEventListener(MouseEvent.MOUSE_UP, endDrag);
scrollHandle.stage.addEventListener(MouseEvent.MOUSE_MOVE, executeScroll);
}
private function executeScroll(evt:MouseEvent):void {
var targetPosition = -((scrollHandle.y * (containerTarget.height - containerMask.height)) / (containerMask.height - scrollHandle.height) - containerOrigin);
containerTarget.y = targetPosition;
}
private function endDrag( event:MouseEvent ):void {
scrollHandle.stage.removeEventListener(MouseEvent.MOUSE_MOVE, executeScroll);
scrollHandle.stage.removeEventListener(MouseEvent.MOUSE_UP, endDrag);
scrollHandle.stopDrag();
scrollHandle.addEventListener(MouseEvent.MOUSE_DOWN, beginDrag);
}
}
}
Enjoy!
How Do I Build A Custom Scroll Bar?
OR is there a way to customize the scroll bar flash already provides? Ive heard nasty things about building them, like people would rather kill themselves but I need to know... PLEASE HELP. -UA
Custom Scroll Question
Hello guys,
I am fairly new at Flash and I am totally stressing out because I have to make a presentation in Flash anyways I don't have a loty yet but I have this problem that I would like to fix before moving on to other things. Don't laugh at me cause it's really easy to fix probably ...
I made my custom scroll with one of the tutorials on this site, (thanks for that, it's really easy to follow and to make) but now I want to change something. I now have to push on the button and the text will scroll down or up. I would like to make it so that you can just roll over the text and it scrolls automatic. I thought that it would just work if I changed the script a little, but now I get all these errors.
on (press, release, keyPress "<Up>") {
currentScroll = scrollableText.scroll;
if (Number(currentScroll)>1) {
scrollableText.scroll = currentScroll-1;
}
}
--> I thought that press, release, keyPress could just be replaced with rollover or something.
Thanks in advance for the help!
[MX2004] Custom Scroll Bar
I'm trying to create a custom scrollbar with the thumb bar in between the two scroll arrows (up and down). I've tried to find the code for getting the size/position of the thumb bar relative to the amount of text in a dynamic text field, but have been unsuccessful.
Can anyone point me in the right direction?
|