Building and Running AS3 Bible Examples

I’ve received several emails from readers who have had trouble running code from the ActionScript 3.0 Bible. You can find a step-by-step guide to running example code in the Introduction to that book. We all know that a picture is worth a thousand words, but friends, we are living in the HD age, and pictures are boring us to tears. Today’s sophisticated audience demands excitement, explosions, underwater scenes, bullet time, pole dances, and THX certified sound! So to provide a gripping emotional connection with my readers, I here provide video tutorials on how to build examples from the book (in under 5 minutes!). First, using Flash CS3, then using Flex Builder 3. Pow! Boom! Kachow!

FLFX

See how to run example code using Flash | See how to run example code using Flex Builder

This entry was posted in AS3, Flash, Tutorial and tagged . Bookmark the permalink.

11 Responses to Building and Running AS3 Bible Examples

  1. Jason says:

    Those seem like they would be really helpful for new developers. You should do more instructional videos if you have the time. You’re good at it.

  2. Thanks Jason!

    In the Flash video, the dialog that comes at 3:43 up warns us that Flash couldn’t find the definition of the class Example. This happens because it can’t find com/wiley/as3bible/Example.as, because we haven’t yet saved the FLA to the right location. If you saved the FLA to the right place before entering anything in the Document class field, you would not see that warning when entering it in, because it would find the corresponding file right away.

    In the Flex video, if you are really attentive you might notice that I changed some of the code. I did not resize the textfield to be the same size as the stage, because the stage property is not available in AS3 display objects until the Event.ADDED_TO_STAGE event is fired, an idiosyncrasy that at one point trips up everyone new to AS3, myself included. Remember that stage is now a property of each display object and not global, and that you can’t be guaranteed a non-null value until after Event.ADDED_TO_STAGE is fired. Beware!

  3. Todd Hamilton says:

    Great Book but,

    Is there anywhere where we can get the miles of source code published in the book but not available in the download source.
    Chapter 33 is a good example.

    It’s frustrating that long examples have to be typed in by hand.

  4. Mims Wright says:

    Todd,
    The code samples are available on the wiley website.
    Check this post: http://mimswright.com/blog/?p=196

    Furthermore, Wiley has linked to this blog post on the book site but you probably know that since you’re reading this.

  5. Mike says:

    Thanks this video helped out a lot but I have a question about the code. I have another question about running some of the code. In the files for Chap 12_2 and Chap 12_3 how are we suppose to run these? What links them together?

    Many Thanks!!
    Mike

  6. Jeremiah says:

    The code in chapter27 exercise is giving me multiple errors.

    will you please double check, triple check that coding I have copy and followed your steps, but I still can not get the app to execute.

    Thanks

    J.

  7. Steve Harris says:

    My comment is the same as Mike.
    I can follow the video but don’t know how to incorporate the code from 12_2 and 12_3.

  8. Mims Wright says:

    Hi Steve, Mike, Jeremiah,

    I’m forwarding your concerns to our publisher who can help coordinate with the author of that chapter to get things straightened out. In the meantime, the best thing you can do is fill out an Errata form on the Wiley website.

    http://www.wiley.com/WileyCDA/WileyTitle/productCd-0470135603,descCd-ERRATA.html

    Thanks!
    Mims

  9. Rob says:

    Regarding code for Chap 12_2 and 12_3 (I think you’re referring to the StageListenerSprit and StageTestProject scripts?)

    It isn’t too clear in the text. I was able to get it to work by saving the StageTestProject class as a package in the same directory as the StageListenerSprite package. I had to add the fully qualified path and that it extends Sprite to the beginning of the file. Both packages then reside in the same com.wiley.as3bible folder:

    So for example, StageListenerSprite’s code would begin with:

    package com.wiley.as3bible
    {
    import flash.display.Sprite;
    import flash.events.Event;

    public class StageListenerSprite extends Sprite
    …etc…

    and the StageTestProject package/class would begin with:

    package com.wiley.as3bible
    {
    import flash.display.Sprite
    // you need this because StageTestProject extends Sprite

    public class StageTestProject extends Sprite
    …etc…

    Then, in your FLA file, in the Document Class field, you would enter:
    com.wiley.as3bible.StageTestProject
    as your document class, so it will be the first thing to run when you run your movie. StageTestProject will look for the StageListenerSprite class in the same directory (com.wiley.as3bible) to access its function.

    The output once it all is hooked up would be:

    after the constructor is called the stage = null
    (since nothing was added to the stage yet, so the stage/display list is null)
    0
    (since adding an item to the display list now creates a stage so it is no longer null)
    0
    (since removing an item doesn’t remove the display list so the stage still exists)

    I got to this conclusion because both StageListenerSprite and StageTestProject are listed as public classes so they would need to reside in separate packages (files) because including them in the same file produces the error:

    5006: An ActionScript file can not have more than one externally visible definition: com.wiley.as3bible.StageListenerSprite com.wiley.as3bible.StageTestProject

  10. Satish says:

    Hi Roger,
    Happy X’mas and Happy New Year to all of you!!

    I had been working with AS2.0, till recently. But now I have been reading your book and trying the AS3Bible – examples as per the instructions.

    I am storing class files in com.wiley.ac3bible and flash documents outside com, but for every program that i run i get only blank swf file, when debugged it gives only message that
    “A definition for the document class could not found in the ckasspath, so one will automatically generated in the SWF file upon export”
    I have flash player 9 (debug version) only flash files work but class files dont.
    Is it required to set the classpath? How??

    Kindly help me out.

    You have written the book nicely, the language is so down-to-earth, easy to understand and you have made tedious topics quite interesting to read !!

    Hope I will get the required hints from you.

    Regards to Mims and Joushua too.

    Satish
    Bangalore/India.

  11. Mitch says:

    Hi everybody! Im at the page 13 (Overriding variables) and i have no idea to run this code:

    package {
    public class Local {
    public var a:String = “instance”;
    public var b:String = “instance”;
    public function method():void {
    var a:String = “function”;
    b = “function”;
    trace(a);
    trace(b);
    }
    }
    }

    Please help me run this (i can’t run any code in this book except the Hello World example – same problem with the downloaded codes)

    Please HEEEELP!!!

    Can anyone explain step-by-step how to accomplish it?

    Thank you!!

Leave a Reply

Your email address will not be published. Required fields are marked *

*

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>

Spam Protection by WP-SpamFree