| Example |
//create pseudo.ScrollPane instance
var spane:pseudo.ScrollPane = pseudo.ScrollPane.create(_root, "spane", 1);
//set ScrollPane movie clip size
spane.setSize(400, 300);
//set the movie content for the ScrollPane instance
//where the image will be displayed. Function setContent() returns the
//reference to that content
var pict:pseudo.BaseMovie = spane.setContent();
// Create image movie clip using the image that was imported to the library
//in our example image graphic is stored in the library with the id "pict"
var img:MovieClip = pict.attachMovie("pict", "pict", 2);
// add the listener to the content that would be handling the "size event"
pict.addListener("size", _root, function(){ pict.setSize(img._width, img._height); });
//Apply the skin to the scroll pane
spane.setLook(pseudo.look.XPLook.getInstance())
//Create the button that will be zooming the image
var btnPlus:pseudo.PushButton = pseudo.PushButton.create(_root, "btnPlus", 2);
btnPlus.setSize(20, 20);
var lbl:pseudo.Label = pseudo.Label(btnPlus.addItem(pseudo.Label));
lbl.setText("+");
lbl.setAlign("center");
btnPlus.setLook(pseudo.look.XPLook.getInstance());
btnPlus.update();
btnPlus.draw();
btnPlus.addListener("mouseRelease", _root, function()
{
img._xscale = img._yscale = img._xscale + 10;
spane.setUpdated(false);
spane.update();
spane.draw();
}
);
//Create the button that will be zooming out the image
var btnMinus:pseudo.PushButton = pseudo.PushButton.create(_root, "btnMinus", 3);
btnMinus.setSize(20, 20);
var lbl:pseudo.Label = pseudo.Label(btnMinus.addItem(pseudo.Label));
lbl.setText("-");
lbl.setAlign("center");
btnMinus.setLook(pseudo.look.XPLook.getInstance());
btnMinus.update();
btnMinus.draw();
btnMinus.addListener("mouseRelease", _root, function()
{
img._xscale = img._yscale = Math.max(5, img._xscale - 10);
spane.setUpdated(false);
spane.update();
spane.draw();
}
);
//Position the minus button
btnMinus._y = btnPlus._y + btnPlus.getH();
//Calling these functions will finally draw the component
spane.update();
spane.draw();
// This code will draw the ScrollPane using XP look and feel skin.
// Please notice that you should always use some skin to create the component,
// this can be done like in this example, and the skin will be complied into the swf file,
// or you can use another technique and load the skin at a run time.
|