search
HomeBackend DevelopmentPHP TutorialDynamically create Flash animations with PHP_PHP tutorial

Dynamically create Flash animations with PHP_PHP tutorial

Jul 21, 2016 pm 04:09 PM
flashphpcompanycreatedynamicanimationbecomenowuseofsoftware

Flash animation software produced by Macromedia has now become a very popular performance tool on Web pages, and website developers use it to arouse the interest of viewers. Unfortunately, just using ActionScript to create animations is very restrictive. Macromedia has announced that it intends to abandon the Flash Generator product and switch to Cold Fusion that supports Flash MX. Where will our website go? Now, we can use the Ming PHP library to easily dynamically create Flash animations and integrate them seamlessly with our code. We can create animations with various effects based on the data in the database.
Ming animation library first appeared in PHP4.05 version, replacing the previous version of LibSwf module. The Ming library is written in C and supports multiple languages. Let's first look at how to use PHP to create animations. The library is easy to use and tightly integrated with PHP. However, the library is still in the experimental stage. The current version is 0.2a. Online tutorials, examples, and help manuals allow us to learn easily. The functions in Ming are well organized. Organized and easy to find for PHP and Flash developers. Using PHP and Ming libraries not only gives our website a gorgeous decoration, but also reduces the cost and complicated labor of developing Flash animations.
There are two ways to use the Ming library. We can embed it into PHP (for Unix platforms), or we can run it as a PHP module. The functions inside support all platforms, and no instance is needed when using it. change. If we run the Ming library as a PHP module, we must explicitly call the Ming library, just like other modules, and then use the functions in the library. Since the module must be loaded before use, there will be a slight performance drop compared to compiling Ming as an internal function.
The Ming library is completely free. We can download it from the creator’s website. The address is: http://www.opaque.net/ming/. The website has detailed user manuals and help. Before use, please First, take a look at the installation and configuration instructions. The address is: http://www.opaque.net/ming/install.html. In addition, there are also user manuals and detailed instructions on the PHP website, the address is: http://www.php.net/ming.
Once we have the Ming library installed and configured correctly, we can create a PHP object, call Ming functions from PHP, and define our animation by calling functions and properties. There are 13 objects in the PHP module, which provide some functions of Flash, and there are also several commands that can control the parameter settings during release. Let's see how to use it to create animations.
Use Macromedia Flash to create animations in SWF format. We first create some symbols. Flash has three types of symbols: graphics, animation clips, and buttons. Once we create these symbols, we can copy them into the scene. Each copy is called an instance, and we can put as many instances into our scene as we want. Next, you can define the behavior of these objects, that is, define the actions and motion trajectories, and also define the parameters of the animation, such as size and background color. If necessary, you can save it as a .SWF file.
Use PHP's Ming library to create Flash animations. Like Macromedia Flash, you must first create some symbols. These symbols are instances of PHP objects, then define the positions and mutual relationships of these objects in the animation scene, and then define the objects in each The action within a frame ultimately defines the animation itself. We can directly output the SWF to the browser, or save it as a file in SWF format for later use. The advantage of Flash is the graphical user interface. Using the Ming library not only allows easier control of objects, but also has unlimited scalability and reusability.
Let’s use a complete example to see how to use the Ming library:


/* First create a symbol and fill it with color*/
$square = new SWFShape();
$sqfill = $square->addFill(0, 0, 0xff);
$square->setRightFill($sqfill);
$square-> movePenTo(-250,-250);
$square->drawLineTo(250,-250);
$square->drawLineTo(250,250);
$square->drawLineTo(-250,250 );
$square->drawLineTo(-250,-250);

/* Use the above symbols in animation clips and add some scripts*/
$sqclip = new SWFSprite ();
$i = $sqclip->add($square);
$i->setDepth(1);
$sqclip->setframes(25);
$ sqclip->add(new SWFAction("stop();"));
$sqclip->nextFrame();
$sqclip->add(new SWFAction("play();") );
for($n=0; $n $i->rotate(-15);
$sqclip->nextFrame();
}

/* Create button below*/

function rect($r, $g, $b) {
$s = new SWFShape();
$s- >setRightFill($s->addFill($r, $g, $b));
$s->drawLine(500,0);
$s->drawLine(0,500);
$s->drawLine(-500,0);
$s->drawLine(0,-500);
return $s;
}

$ b = new SWFButton();
$b->addShape(rect(0xff, 0, 0), SWFBUTTON_UP | SWFBUTTON_HIT);
$b->addShape(rect(0, 0xff, 0), SWFBUTTON_OVER);
$b->addShape(rect(0, 0, 0xff), SWFBUTTON_DOWN);
$b->addAction(new SWFAction("setTarget('/box'); gotoandplay(2 );"), SWFBUTTON_MOUSEDOWN);

/* Create the animation below and add the above symbols and buttons*/

$m = new SWFMovie();
$m-> ;setDimension(4000,3000);

$i = $m->add($sqclip);
$i->setDepth(3);
$i->moveTo (1650, 400);
$i->setName("box");

$i = $m->add($b);
$i->setDepth (2);
$i->moveTo(1400,900);

/* Finally, we output it to the browser*/

header('Content-type : application/x-shockwave-flash');
$m->output();
?>

Okay, run it on your machine and see if it works Just like those created with Flash! For more function descriptions, please refer to the operating manual.

www.bkjia.comtruehttp: //www.bkjia.com/PHPjc/314632.htmlTechArticleThe Flash animation software produced by Macromedia has now become a very popular performance tool on Web pages, and website developers use it Arouse the viewer's interest. Unfortunately, just...
Statement
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
How does PHP type hinting work, including scalar types, return types, union types, and nullable types?How does PHP type hinting work, including scalar types, return types, union types, and nullable types?Apr 17, 2025 am 12:25 AM

PHP type prompts to improve code quality and readability. 1) Scalar type tips: Since PHP7.0, basic data types are allowed to be specified in function parameters, such as int, float, etc. 2) Return type prompt: Ensure the consistency of the function return value type. 3) Union type prompt: Since PHP8.0, multiple types are allowed to be specified in function parameters or return values. 4) Nullable type prompt: Allows to include null values ​​and handle functions that may return null values.

How does PHP handle object cloning (clone keyword) and the __clone magic method?How does PHP handle object cloning (clone keyword) and the __clone magic method?Apr 17, 2025 am 12:24 AM

In PHP, use the clone keyword to create a copy of the object and customize the cloning behavior through the \_\_clone magic method. 1. Use the clone keyword to make a shallow copy, cloning the object's properties but not the object's properties. 2. The \_\_clone method can deeply copy nested objects to avoid shallow copying problems. 3. Pay attention to avoid circular references and performance problems in cloning, and optimize cloning operations to improve efficiency.

PHP vs. Python: Use Cases and ApplicationsPHP vs. Python: Use Cases and ApplicationsApr 17, 2025 am 12:23 AM

PHP is suitable for web development and content management systems, and Python is suitable for data science, machine learning and automation scripts. 1.PHP performs well in building fast and scalable websites and applications and is commonly used in CMS such as WordPress. 2. Python has performed outstandingly in the fields of data science and machine learning, with rich libraries such as NumPy and TensorFlow.

Describe different HTTP caching headers (e.g., Cache-Control, ETag, Last-Modified).Describe different HTTP caching headers (e.g., Cache-Control, ETag, Last-Modified).Apr 17, 2025 am 12:22 AM

Key players in HTTP cache headers include Cache-Control, ETag, and Last-Modified. 1.Cache-Control is used to control caching policies. Example: Cache-Control:max-age=3600,public. 2. ETag verifies resource changes through unique identifiers, example: ETag: "686897696a7c876b7e". 3.Last-Modified indicates the resource's last modification time, example: Last-Modified:Wed,21Oct201507:28:00GMT.

Explain secure password hashing in PHP (e.g., password_hash, password_verify). Why not use MD5 or SHA1?Explain secure password hashing in PHP (e.g., password_hash, password_verify). Why not use MD5 or SHA1?Apr 17, 2025 am 12:06 AM

In PHP, password_hash and password_verify functions should be used to implement secure password hashing, and MD5 or SHA1 should not be used. 1) password_hash generates a hash containing salt values ​​to enhance security. 2) Password_verify verify password and ensure security by comparing hash values. 3) MD5 and SHA1 are vulnerable and lack salt values, and are not suitable for modern password security.

PHP: An Introduction to the Server-Side Scripting LanguagePHP: An Introduction to the Server-Side Scripting LanguageApr 16, 2025 am 12:18 AM

PHP is a server-side scripting language used for dynamic web development and server-side applications. 1.PHP is an interpreted language that does not require compilation and is suitable for rapid development. 2. PHP code is embedded in HTML, making it easy to develop web pages. 3. PHP processes server-side logic, generates HTML output, and supports user interaction and data processing. 4. PHP can interact with the database, process form submission, and execute server-side tasks.

PHP and the Web: Exploring its Long-Term ImpactPHP and the Web: Exploring its Long-Term ImpactApr 16, 2025 am 12:17 AM

PHP has shaped the network over the past few decades and will continue to play an important role in web development. 1) PHP originated in 1994 and has become the first choice for developers due to its ease of use and seamless integration with MySQL. 2) Its core functions include generating dynamic content and integrating with the database, allowing the website to be updated in real time and displayed in personalized manner. 3) The wide application and ecosystem of PHP have driven its long-term impact, but it also faces version updates and security challenges. 4) Performance improvements in recent years, such as the release of PHP7, enable it to compete with modern languages. 5) In the future, PHP needs to deal with new challenges such as containerization and microservices, but its flexibility and active community make it adaptable.

Why Use PHP? Advantages and Benefits ExplainedWhy Use PHP? Advantages and Benefits ExplainedApr 16, 2025 am 12:16 AM

The core benefits of PHP include ease of learning, strong web development support, rich libraries and frameworks, high performance and scalability, cross-platform compatibility, and cost-effectiveness. 1) Easy to learn and use, suitable for beginners; 2) Good integration with web servers and supports multiple databases; 3) Have powerful frameworks such as Laravel; 4) High performance can be achieved through optimization; 5) Support multiple operating systems; 6) Open source to reduce development costs.

See all articles

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

AI Hentai Generator

AI Hentai Generator

Generate AI Hentai for free.

Hot Article

R.E.P.O. Energy Crystals Explained and What They Do (Yellow Crystal)
1 months agoBy尊渡假赌尊渡假赌尊渡假赌
R.E.P.O. Best Graphic Settings
4 weeks agoBy尊渡假赌尊渡假赌尊渡假赌
R.E.P.O. How to Fix Audio if You Can't Hear Anyone
1 months agoBy尊渡假赌尊渡假赌尊渡假赌
R.E.P.O. Chat Commands and How to Use Them
1 months agoBy尊渡假赌尊渡假赌尊渡假赌

Hot Tools

ZendStudio 13.5.1 Mac

ZendStudio 13.5.1 Mac

Powerful PHP integrated development environment

DVWA

DVWA

Damn Vulnerable Web App (DVWA) is a PHP/MySQL web application that is very vulnerable. Its main goals are to be an aid for security professionals to test their skills and tools in a legal environment, to help web developers better understand the process of securing web applications, and to help teachers/students teach/learn in a classroom environment Web application security. The goal of DVWA is to practice some of the most common web vulnerabilities through a simple and straightforward interface, with varying degrees of difficulty. Please note that this software

SublimeText3 English version

SublimeText3 English version

Recommended: Win version, supports code prompts!

WebStorm Mac version

WebStorm Mac version

Useful JavaScript development tools

SublimeText3 Linux new version

SublimeText3 Linux new version

SublimeText3 Linux latest version