21st Century Smalltalk

February 18, 2007

Flash “Accordion” Control Demo

Filed under: Adobe, Lisp — pfisk @ 7:13 pm

lisptest10
Vista Smalltalk Site

This demonstation opens a window with an “accordion” of multiple sub-windows. To run it, evaluate “(@open AccordionDemo1)” in any Lisp workspace window (open Vista Smalltalk in your browser by clicking this link).

As the Lisp interpreter improves, I am able to use it to dynamically create the Flash components. In this example, the child window titles, content and colors are read from a list structure in a “dolist” statement and the parent window’s width is set to be 50% larger than it’s default size.

The Lisp code is below:

(add-method (class-of AccordionDemo1) 'open
  (lambda()
  (let ((ac nil) (box nil) (ta nil) (w nil))
    (setq ac (@new Accordion))
    (dolist (item '(("One" "This is ONE" "#FF0000")
                   ("Two" "This is TWO" "#00FF00")
                   ("Three" "This is THREE" "#0000FF")
                   ("Four" "This is FOUR" "#FF00FF")
                   ("Five" "This is FIVE" "#FFFF00")))
      (setq box (@new VBox))
      (@label- box (car item))
      (setq ta (@new TextArea))
      (@htmltext- ta (string-cat "<b><i><font size='40' color='"
                                 (car (cdr (cdr item)))
                                 "' size='40'>"

                                 (cadr item)
                                 "</font></i></b>"))
      (@addchild- box ta)
      (@addchild- ac box))
      (setq w (@open- SizeableTitleWindow "Accordion Demo 1"))
      (@width- w (* 1.5 (@width w)))
      (@addchild- w ac)
      w)))

Blog at WordPress.com.