Skip to Main Content
PHP in a Nutshell
book

PHP in a Nutshell

by Paul Hudson
October 2005
Intermediate to advanced content levelIntermediate to advanced
372 pages
11h 35m
English
O'Reilly Media, Inc.
Content preview from PHP in a Nutshell

Actions

Through its powerful ActionScript language, Flash provides a flexible scripting environment to allow developers to take more direct control over the operation and flow of their script. For example, you can call stop() to stop playing the movie, then play() to continue; gotoFrame() allows you to jump to a particular part of your movie, and getURL() allows you to browse to a new web page. There is a large collection of actions available to you, and the PHP documentation has some very good (if long) examples on how to make use of various functions.

This next script gives you a quick start in using ActionScript:

    function MakeActionBox($red, $green, $blue){
            $shape = new SWFShape();
            $shape->setLeftFill($shape->addFill($red, $green, $blue));
            $shape->movePenTo(-100,-20);
            $shape->drawLineTo(100,-20);
            $shape->drawLineTo(100,20);
            $shape->drawLineTo(-100,20);
            $shape->drawLineTo(-100,-20);
            return $shape;
    }

    $button = new SWFButton();
    $button->setUp(MakeActionBox(0xff, 0, 0));
    $button->setOver(MakeActionBox(0xff, 0xff, 0));
    $button->setDown(MakeActionBox(0, 0, 0xff));
    $button->setHit(MakeActionBox(0, 0, 0));
    $button->addAction(new SWFAction("getURL('http://www.slashdot.org',
            'slashdot');"), SWFBUTTON_MOUSEUP);

    $movie = new SWFMovie();
    $movie->setDimension(200,200);

    $displayitem = $movie->add($button);
    $displayitem->moveTo(100,100);

    header("Content-type: application/x-shockwave-flash");
    $movie->output();

That script uses a custom function, MakeActionBox(), to handle some of the grunt work ...

Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

PHP Cookbook

PHP Cookbook

Eric A. Mann
Programming PHP

Programming PHP

Rasmus Lerdorf, Kevin Tatroe
Learning PHP

Learning PHP

David Sklar

Publisher Resources

ISBN: 0596100671Errata Page