- Adding Graphics and Text

This section provides a tutorial example on how to draw graphics and add texts to the default frame of a movie clip using ActionScript 3 script.

In this section, I want to show you a tutorial example of ActionScript code for creating graphics and text:

// Copyright (c) 2014,, All Rights Reserved.
package com.herongyang {
   import flash.display.*;
   import flash.text.*;
   public class MyMovieClip extends MovieClip {
      private var green:uint = 0x00ff00;
      private var black:uint = 0x000000;

// Building my first frame in the constructor
      public function MyMovieClip() {

// Building a shap object
      private function addCircle():void {
         graphics.lineStyle(5, black);
         graphics.drawCircle(75, 75, 50);

// Building a text object
      private function addText():void {
         var object:TextField = new TextField();
         object.text = "Green";
         object.x = 50;
         object.y = 50;


A few things I learned from this example:

Compile and generate the HTML code:

C:\herong>\local\SWFTools\as3compile -X 150 -Y 150

C:\herong>\local\SWFTools\swfdump.exe -E MyMovieClip.swf 
   > MyMovieClip.html

Open MyMovieClip.html in a Web browser. You will see:
AS3Compile - My MoiveClip

Cool. I am able to do some drawing and texting with ActionScript 3 now.

I tried to add more frames and failed. Adobe does not provide any ActionScript 3 API for you to manage the animation timeline or frames.

Last update: 2014.

Table of Contents

 About This Book

 Introduction of Adobe Flash

 Adobe Flash Player Plugin for Firefox

 Adobe Flash Player Plugin for Chrome

 Adobe Flash Player Plugin for Safari

 Adobe Flash Player ActiveX for IE

 Using "object" Elements for Flash Files

 Using "embed" Elements for Flash Files

 "mp3player" - MP3 Music Player

 SWFObject - Hidding "object" behind JavaScript

 Flash Player Projector

 SWFTools - SWF File Manipulation Tools

 SWFC Script to Generate Flash SWF Files

 ActionScript Embedded in SWFC Script

AS3Compile - ActionScript 3 Compiler

 What Is AS3Compile? - First ActionScript 3 Example - Adding Graphics and Text - Showing System Properties

 Adobe Flex SDK 4

 SWF File Struture and Tags

 SWF File Processing Rules

 SWF Files for Video and Audio Streams

 Outdated Tutorials


 PDF Printing Version