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

AS3: ScrollPane component and scrollbar position

Guest
Dec 18, 2007 Dec 18, 2007

Hi there:

I'm using AS3 to import, add and populate a scrollbar with textfields. I'd like to position the vertical scrollbar on the left side rather than the right side. How do I go about this using AS3?

I've searched in these and other forums, not to mention the Flash help, to no avail. If I'm missing something obvious, anyone is welcome to point it out... :)

Thanks!

Patrick
TOPICS
ActionScript
6.5K
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

Advisor , Dec 18, 2007 Dec 18, 2007
oh okay. if you would like to adjust the position of the scrollbar in a ScrollPane, it may be possible with a bit of work. just from some experimentation then, i found that you can reference the vertical scrollbar in a ScrollPane with the property verticalScrollBar, and use this to move it, with something like:
scroller.verticalScrollBar.x=-20;

however, you'll need to wait for the content to render and the scrollbars to become active before trying to move the scrollbar. i used the 'added' even...
Translate
Advisor ,
Dec 18, 2007 Dec 18, 2007
which scroll component are you using? you can place a UIScrollBar anywhere on screen and by specifying its scrollTargetName, control a symbol such as a textfield elsewhere on screen. so the scroller could be on the left, right, or even rotated 180 degrees if you really want to confuse your users!
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
Guest
Dec 18, 2007 Dec 18, 2007
Hi Craig:

Sorry, my subject line said ScrollPane, the body of my post said scrollbar...

I understand I can add ScrollBars willy nilly to content on the screen & adjust their position. I'm currently using a ScrollPane component, and would like to set the ScrollPane's Scrollbar to the left side.

Do you know the easies way to do that?

I'm creating everything via AS3, rather than setting things 'physically' on the stage and referencing them.

Thanks!
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
Advisor ,
Dec 18, 2007 Dec 18, 2007
oh okay. if you would like to adjust the position of the scrollbar in a ScrollPane, it may be possible with a bit of work. just from some experimentation then, i found that you can reference the vertical scrollbar in a ScrollPane with the property verticalScrollBar, and use this to move it, with something like:
scroller.verticalScrollBar.x=-20;

however, you'll need to wait for the content to render and the scrollbars to become active before trying to move the scrollbar. i used the 'added' event like so:(see attached code below)

the only problem is that the background of the scrollbar still exists, but you may be able to remove this with skins or fudge a graphic over the top of it to hide it.
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
Guest
Dec 19, 2007 Dec 19, 2007


Craig, it works! ...but you already knew that. Thanks for taking the time to tinker.

I had been playing with the BaseScrollPane.as, thinking that would affect the ScrollPane component, but altering drawLayout() had no effect.

From perusing BaseScrollPane, I'd been trying to target "_ verticalScrollBar"... Argh!

I would have never come up with listening for the event "added". That is not exactly obvious, from the Flash Help documentation, as being an available event for the ScrollPane.

I'll attach my current working code below.

Thanks again, and

Cheers,

Patrick

ps: I don't seem to have the issue with the scrollbar background -- the entire thing moves around for me.
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
Advisor ,
Dec 19, 2007 Dec 19, 2007
no problem - glad its working sufficiently for you.

a little tip with flash help also - when you're looking at the methods, properties, events, styles for a class, click on 'Show Inherited ...' to see the complete list for this class. this is how you could have discovered 'added' for ScrollPane for example.
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
Guest
Dec 20, 2007 Dec 20, 2007
LATEST
Hi Craig:

Thanks for the tip!

I wish I could set all those "Show Inherited" toggles to be down by default. :)

Cheers,

Patrick

ps: not sure how to edit the code above, but my code's got an error in it:

myScrollPane.removeEventListener(scrollbarAdded);

should be:

myScrollPane.removeEventListener("added",scrollbarAdded);
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