#lang scheme/base
(require (planet bzlib/base)
(planet bzlib/shp) (planet bzlib/file)
(planet bzlib/os)
xml
"mxml.ss"
"util.ss"
)
(define mxml-base-path (make-parameter "/mxml"))
(define (mxml->string mxml)
(xexpr->string mxml))
(define (mxml-path path)
(build-path* ($htdocs) (mxml-base-path) path))
(define (compile! path)
(sys/call "c:\\downloads\\flexsdk\\bin\\mxmlc"
(path->string (mxml-path path))
"-output"
(path->string (flash-path (string-append path ".swf")))))
(define (mxml path #:id (id #f) #:height (height 400) #:width (width 400)
. widgets)
(define (helper)
(let ((app (apply mx:app widgets)))
(call-with-output-file
(mxml-path path)
(lambda (out)
(display (mxml->string app) out))
#:exists 'replace)
(compile! path) (flash (string-append path ".swf") #:id id #:height height #:width width)))
(if (file-exists? (flash-path (string-append path ".swf")))
(if (> (mtime (__PATH__)) (mtime (flash-path (string-append path ".swf")))) (helper)
(flash (string-append path ".swf") #:id id #:height height #:width width))
(helper)))
(provide/contract
(mxml-base-path (parameter/c path-string?))
(mxml (->* (path-string?)
()
#:rest (listof any/c)
any/c))
)