Contact Yart for a relaxed conversation
Your Name * Message *
Your Email *  
Your Phone   
Our Phone:        03 8685 8718 (within Australia)
61 3 8685 8718 (outside Australia)
Contact Yart

Melbourne Content Management and Flash developers

 

for designers, agencies and your website

Resources / Flash / Coding in Flash Develop
Writing AS3 using Flash Develop and integrating it with Flash CS3

Flash Develop is a much better AS3 editor than Flash CS3. This tutorial tells you how you can use Flash Develop (v 3.0.0 RC2) to code the ActionScript 3 to be used in your Flash CS3 file.

Setting up Flash Develop the first time (optional)

This is to set the path of a Flex SDK. I'm not sure what it is for actually.
You may skip this and just start creating a new project.

  1. Download Flex 2 SDK or Flex 3 SDK (google it)
  2. Open Flash Develop, go to Tools - Program Settings...
  3. Under Plugins, select AS3Context.
    Then on the right, change the Flex SDK Location to whereever your Flex SDK is.

 

Create a new Flash IDE project in Flash Develop

First we will create a new project in Flash Develop, prior to creating the .fla and .as files.

  1. In Flash Develop, go to Project - New Project...
  2. Select "Flash IDE project".
    Type in the project name (eg. Test)
    Remember the location you pick, we will create a Flash project in the same location later.

    Click OK
  3. Now let us create an .as file.
    Right click on the new project (Test) and select Add - New Class

    Give it a name "Test.as". Remember this name as this will be the document class of your Flash file.
    The file Test.as would be created and opened, and there is some code there pregenerated for you.
  4. Now we need to inherit this class from either Sprite or MovieClip.
    The intellisense will automatically import flash.display.MovieClip as you type "extends MovieClip".
  5. Save this file for now and let us open Flash.

Create a new Flash file

  1. Start Adobe Flash CS3, create a new Flash File (ActionScript 3.0)
  2. File - Save As...
    Save it to the same folder as your ActionScript project above, and give it the same filename ("Test.fla" for this tutorial).
  3. (Optional) Go to File - Publish Settings, and uncheck HTML, because we don't need it.

    Click OK to close the settings.
  4. Now in the Properties window of the document (if you can't see it, hit Ctrl + F3), type in the document class "Test".

    Note that this class name is the same as the ActionScript filename we created (which is Test.as).
    Flash will automatically check if you have a file called Test.as, and would give you a warning if it doesn't exist.
    So now we have Test.as and Test.fla in the same folder.
  5. Hit Ctrl+Enter. It should create a SWF file and run it without any errors/warnings. (It will be just blank)

Doing the coding

Now Test.as contains the ActionScript code that is used in Test.fla. Let's see it working.

  1. Back to Flash Develop, let's put in some code into the Test.as file.
    Type in this code in the constructor:
    trace("Welcome to Yart!");
  2. Hit Ctrl+Enter to run it. If it doesn't work from Flash Develop then save the .as file, go to your Flash (test.fla) and hit Ctrl+Enter there.
    You should see the output

More complex example

Here we will look at how to create a symbol and creating our custom class for it.

  1. In Flash, let's create a Dynamic Text on the stage, and give it a name "test_txt"
  2. Try running it (Ctrl+Enter)
    You would probably get an error that the type TextField is not found.
  3. To fix that, go to Flash Develop (Test.as) and in the import section on the top, type:
    import flash.text.*;
    It should now compile without errors.
  4. In FlashDevelop, create a new .as file for the symbol we are going to create.
    (Right click the project, Add - New Class...)
  5. Name it CustomText.as, because we are going to name our symbol "CustomText"
  6. Back in Flash CS3 (Test.fla), right click your text field and convert it to symbol.
  7. Name the symbol, same as the .as file you just created (eg. CustomText)
    Tick Export for ActionScript because we are going to create a custom ActionScript class for this symbol.
    Note that the class name is automatically put there, the same as the symbol name (ie. CustomText)

    Click OK.
    Flash automatically detects if there is an ActionScript file for this class (CustomText.as). You shouldn't get any warning because you've already created the file.
  8. Try running it (Ctrl+Enter) and you should get 2 errors:
  9. To fix it, in CustomText.as, import flash.text.* (because this symbol contains a TextField) and extend the class from MovieClip (because this symbol is a MovieClip)

    It should now compile without errors
  10. Now put in your custom code for your symbol, eg.
     package
    {
    import flash.display.MovieClip;
    import flash.events.MouseEvent;
    import flash.text.*;

    public class CustomText extends MovieClip
    {
    public function CustomText()
    {
    addEventListener(MouseEvent.ROLL_OVER, OnMouseOver);
    addEventListener(MouseEvent.ROLL_OUT, OnMouseOut);
    }

    public function OnMouseOver(e:MouseEvent): void
    {
    test_txt.text = "Hello";
    }
    public function OnMouseOut(e:MouseEvent): void
    {
    test_txt.text = "";
    }
    }
    }

Congratulations! You can now build a Flash SWF file and do the coding using Flash Develop!

The latest at Yart
Search: