You can embed images in ActionScript through the use of the Embed metadata tag. (Read Embedding metadata with Flash for more information.) Once they're embedded, you can create an instance of the class and attach it to the display list, as in ActionScriptBlittingPart1.as.
ActionScriptBlittingPart1.as (Example 1)
------------------------------------------------------------------
package
{ import flash.display.Sprite;
[SWF(width=480, height=320, frameRate=24, backgroundColor=0xE2E2E2)]
public class ActionScriptBlittingPart1 extends Sprite
{
public function ActionScriptBlittingPart1()
{
addChild(new BrownCollector());
}
[Embed(source="spritesheets/browncollector.png")]
public var BrownCollector:Class;
}
}
---------------------------------------------------------------------
To run the first example, follow these steps:
In the Package Explorer, right-click ActionScriptBlittingPart1.as and select Run Application.
When your browser opens, you should see the entire PNG image from browncollector.png with all the tiles (Example 1).
Close the browser window.
Read more...
Wednesday, 24 August 2011
Embedding a sprite sheet with ActionScript
Posted by
Flex Application Developer
at
02:29
0
comments
Email This
BlogThis!
Share to X
Share to Facebook
Wednesday, 17 August 2011
How to setting a ActionScript for blitting techniques and Flash Builder 4
For games with lots of animations on the screen that can be pre-rendered into a bitmap image, a technique known as blitting can provide a solution. Blitting is not the answer to every performance problem but it will be smooth, uniform, the speed of animation frames in a wide range of machines. The term comes from BitBLT blitting routine created for the Xerox Alto. BitBLT, pronounced "blit bit" block average (images) transfer, a technique that takes several bitmaps and combines them into a single bitmap. In Flash Player, it is faster to copy the pixels in a bitmap representation of a bitmap that make every DisplayObject separately.
What is a sprite sheet?
A set consists of graphic elements, such as a car on a circuit or a tree in a forest. For this article, these assets will be bitmaps. A group of bitmaps together in an image file called a sprite sheet. For example, a sheet of sprites can contain all the frames in an animation of a nature walk. The term derives from the sprites, which, in the world of computer graphics, image or animation embedded in a big stage. Although the technique can be used blitting bitmap data from different sources, this article will focus on the sprite sheets.
What is a sprite sheet?
A sprite sheet may be a combination of all sorts of bitmap sizes. Assembling all the graphics in one (or few) large file image to reduce load times (which is faster to open and read a large file containing 100 images to open and read smaller files 100) and provides the benefits of compression. Sprite Sheets bitmaps typically the same size as the form of a sequence or an animation around a particular set of assets. For example, the sprite sheet used in this tutorial consists of five columns and four rows of tiles 40 x 40 pixels, each with a coffee picker
Setting ActionScript
Before you can try the sample code, follow these steps to create the project in Flex Builder 4:
Download and unzip the sample files for this tutorial.
Select File> New> ActionScript plan to set up a project.
Sign ActionScriptBlitting the project name and click Finish.
Copy files and folders of files displayed in the default package of the project. The folder contains files used by the PNG spritesheets ActionScript examples.
In the Package Explorer, right-click the project you just created ActionScriptBlitting and select Properties.
In the Properties dialog box, click Applications ActionScript.
Click Add, select the sample, then click OK.
Repeat step 7 for the other sample.
Click OK.
Now you have all the code examples in Flash Builder 4, and you will be able to run all examples.
Read more...
What is a sprite sheet?
A set consists of graphic elements, such as a car on a circuit or a tree in a forest. For this article, these assets will be bitmaps. A group of bitmaps together in an image file called a sprite sheet. For example, a sheet of sprites can contain all the frames in an animation of a nature walk. The term derives from the sprites, which, in the world of computer graphics, image or animation embedded in a big stage. Although the technique can be used blitting bitmap data from different sources, this article will focus on the sprite sheets.
What is a sprite sheet?
A sprite sheet may be a combination of all sorts of bitmap sizes. Assembling all the graphics in one (or few) large file image to reduce load times (which is faster to open and read a large file containing 100 images to open and read smaller files 100) and provides the benefits of compression. Sprite Sheets bitmaps typically the same size as the form of a sequence or an animation around a particular set of assets. For example, the sprite sheet used in this tutorial consists of five columns and four rows of tiles 40 x 40 pixels, each with a coffee picker
Setting ActionScript
Before you can try the sample code, follow these steps to create the project in Flex Builder 4:
Download and unzip the sample files for this tutorial.
Select File> New> ActionScript plan to set up a project.
Sign ActionScriptBlitting the project name and click Finish.
Copy files and folders of files displayed in the default package of the project. The folder contains files used by the PNG spritesheets ActionScript examples.
In the Package Explorer, right-click the project you just created ActionScriptBlitting and select Properties.
In the Properties dialog box, click Applications ActionScript.
Click Add, select the sample, then click OK.
Repeat step 7 for the other sample.
Click OK.
Now you have all the code examples in Flash Builder 4, and you will be able to run all examples.
Read more...
Posted by
Flex Application Developer
at
21:51
0
comments
Email This
BlogThis!
Share to X
Share to Facebook
Labels:
ActionScript,
Blitting Techniques,
Flesh Builder 4,
Flex Application developer,
Flex Developer,
flex development

