Saturday, May 5, 2007

Insert a movie clip from the library in Flash

As I've posted before, our project has a quiz part which requires loading external image files to the Flash. However, the disadvantage of loading an external bitmap file in Flash 8 is the loaded pictures become jaggy.

Jaggy picture (the "ra" hiragana symbol)

Although hiragana symbols are originally vector images (they are drawn in Illustrator), they become bitmap images when we exported them into jpeg files and Flash 8 doesn't have the anti-aliasing function for bitmap images.

To avoid this problem, the solution is to make each hiragana symbol to be a movie clip. This will keep the image at vector format and get rid of the the jaggy problem.

Firstly, we have to make movie clips for hiragana symbols. They are just simple 1-frame movie clips with the content are Hiragana characters. However, we have to set the identifier in the linkage property of the movie clip.

The identifier of the movie clip of the "a" hiragana symbol

After that, we just have to put the action script into frame 1 of the Flash.

// attach the movie clip onto the stage
_root.attachMovie("a","canvas",1);
// position the new movie clip
setProperty("canvas",_x,"300");
setProperty("canvas",_y,"150");
// stop the movie
stop();

And the result is the appearance of the movie clip on the stage without creating any instances.

No comments: