View Full Version : Controls overflow height of the stage...
Pettt[cz]
01-13-2009, 10:38 PM
Hi all FLASHers...
I have a script that generates controls (comboBoxes, radio, inputboxes) dynamicaly based on content read from XML file.
There is no way to know in advance how many there will be, but its possible the content will overflow height of the clip. What is the "general" aproach to a situation like that. I was hoping for a control like VS panel that would generate VScrollBar dynamicly based on content... no such control :O-
...any advice welcome :confused:
zeebee
01-18-2009, 07:09 PM
there are several scroll functions for several data types (currently, I remember TextField, Shape and Sprite classes).
Basically, you define two button-like objects on the stage and set events for both of them, one for scrolling up and one for scrolling down.
import flash.events.MouseEvent;
import flash.geom.Rectangle;
// Define the initial viewable area of the TextField instance:
// left: 0, top: 0, width: TextField's width, height: 350 pixels.
bigText.scrollRect = new Rectangle(0, 0, bigText.width, 350);
// Cache the TextField as a bitmap to improve performance.
bigText.cacheAsBitmap = true;
// called when the "up" button is clicked
function scrollUp(event:MouseEvent):void
{
// Get access to the current scroll rectangle.
var rect:Rectangle = bigText.scrollRect;
// Decrease the y value of the rectangle by 20, effectively
// shifting the rectangle down by 20 pixels.
rect.y -= 20;
// Reassign the rectangle to the TextField to "apply" the change.
bigText.scrollRect = rect;
}
// called when the "down" button is clicked
function scrollDown(event:MouseEvent):void
{
// Get access to the current scroll rectangle.
var rect:Rectangle = bigText.scrollRect;
// Increase the y value of the rectangle by 20, effectively
// shifting the rectangle up by 20 pixels.
rect.y += 20;
// Reassign the rectangle to the TextField to "apply" the change.
bigText.scrollRect = rect;
}
up.addEventListener(MouseEvent.CLICK, scrollUp);
down.addEventListener(MouseEvent.CLICK, scrollDown);
excerpt from the official Adobe Actionscript 3.0 tutorial that's included in Flash CS3 found here:
http://livedocs.adobe.com/flash/9.0/main/00000155.html#wp159589
Pettt[cz]
01-22-2009, 07:48 AM
Hey txh for help zeebee....
I have already used the ScrollPane. The only thing I dont like is teh extra 20k that it adds to my compiled movie. I may have to revisit the issue...
:rolleyes:
|
vBulletin® v3.8.5, Copyright ©2000-2012, Jelsoft Enterprises Ltd.