Namespaces in Actionscript 3.0

Well it seems like I made a common newbie mistake with namespaces in my last post! Thanks Rich for pointing out my error. Eventhough I made a mistake, because I did not understand the namespaces and why or where you will want to use each of the four namespaces, this has lead me to my current learning quest for today!

the four Namespaces are:

public – specifies a property or method that is visible to all classes

private – specifies a property or method that is visible only within the current class

protected – specifies a property or method that is visible within the class, or other classes in the package

internal -specifies a property or method that is visible only within the same package!

If you find any error with the Namespaces above, please let me know!

That is I plan to figure out when to use the four different name spaces in AS 3. My first starting point is of course the Adobe Live Docs

My first clue is pointed out on this page,

Namespaces give you control over the visibility of the properties

and methods that you create.

Actionscript & Shared functioins

I am working with some AS classes trying to become more OOP in nature, and so I am testing keeping everything organized in separate folders according to tasks. You know the drill I like to keep the AS classes in my com folder and inside their separate different classes by what they might do. Shapes in one folders, text in another and so on.

I have been trying this shapes example I came up with with calls another AS class. This works fine when they are both in com, but when they are bother in their own separate folder I get an error.

This is the example when everything is in the same folder

package {

	import flash.display.Sprite;

	import flash.filters.GlowFilter;

	import flash.filters.DropShadowFilter;

	import flash.filters.BlurFilter;

	import Triangles;

	public class InheritingClasses extends Triangles {

		public function InheritingClasses() {

			triangle1.filters = [new GlowFilter(0xFF6699, .75, 25, 25, 2, 2, false, false)];

			triangle2.filters = [new DropShadowFilter(5, 45, 0x666666, 1, 5, 5, 1, 1, false, false, false)];

			triangle3.filters = [new BlurFilter(5, 5, 2)];




package {

	import flash.display.Sprite;

	import flash.display.Shape;

	public class Triangles extends Sprite{

		internal var triangle1:Shape = new Shape();

		internal var triangle2:Shape = new Shape();

		internal var triangle3:Shape = new Shape();

		public function Triangles(){, 0x000000);, 1);, 100);, 100);, 225);, 225);;

			addChild(triangle1);, 0x000000);, 1);, 50);, 50);, 50);, 175);;

			addChild(triangle2);, 0x000000);, 1);, 375);, 375);, 250);, 350);;





of course I set the doc class to “InheritingClasses”

Now when I create the com folder, and put the in “classes and in “Shapes” I got a weird error.

Attempted access of inaccessible property triangle1 through a reference with static type com.classes:InheritingClasses.

Attempted access of inaccessible property triangle2 through a reference with static type com.classes:InheritingClasses.

Attempted access of inaccessible property triangle3 through a reference with static type com.classes:InheritingClasses.

Now why would this fail when I separate the as files into com/shapes for and com/classes for the main class? Of course I updated everything to reflect this change.

I asked this question on Linkedin and Jeff Fall tells me to use public static in the function,and I will try this tonight.

Context Menu


import flash.ui.ContextMenu;

var menu:ContextMenu = new ContextMenu();

var credit:ContextMenuItem = new ContextMenuItem( "Created by Johnny" );

var site:ContextMenuItem = new ContextMenuItem( "Vist my web-site" );

credit.addEventListener( ContextMenuEvent.MENU_ITEM_SELECT, visit_johnny );

site.addEventListener( ContextMenuEvent.MENU_ITEM_SELECT, visit_johnny );

/*site.separatorBefore = false;*/


menu.customItems.push(credit, site);

this.contextMenu = menu;

function visit_johnny(e:Event){

	var johnny_link:URLRequest = new URLRequest( "" );

	navigateToURL( johnny_link, "_parent" );


Hawaii Flash User Group!

I am so happy to let you know that the “Hawaii Flash User Group” is forming!

The URL is Hawaii Flash User Group
I am really having troubles with the system at adobe, but I am hoping to figure out everything this weekend`-`

To Join:

go to Adobe Groups
You will see

Click on Edit your profile

If you have an Adobe ID, sign in, if you don’t create one(it is easy)

go back to Adobe Groups

Then click on Join group,and go to the Hawaii Group URL and join, you should see a join button, I hope.

Please let me know if there are any problems

ActionScript Books

I am reading Learning ActionScript 3.0: A beginner’s guide by Rich Shupe and Zevan Rosser.

If you are looking for a great book to get you up to speed with AS 3, or you would like to learn how to program in AS 3, this is a must read!

In my opinion the best book written on ActionsScript, EVER!

ASDoc in Flex Builder 3.2

I just recently found out that you can create AS Docs in Flex Builder, and here is how I set it up on my Mac OS X Environment.

Open Flex Builder.

Go to Run -> External Tools -> Open External Tools Dialog…

Step 1

Right click, or click on the page icon to create a new program. afterward select New

step 2

Afterwards you will get this window, which I already configured.

step 2

Lets just name our configure file in the Name field.

Name: MyASDocs (This can be anything that makes sense to you)

This is save the setting in the programs field. So you can just use Run MyASDocs

Next we want to browse to the asdoc executable file in the Flex Builder SDK. Click on Browse File System… under the Location field.

Location: /Applications/Adobe Flex Builder 3/sdks/3.2.0/bin/aasdoc

After that we need to use our library as the working directory. This will be where the project is located. Mine is in my home direcoty.

Working Directory: /Users/myUserName/HelloWorld (replace myUserName with your account name)

You can to add in your compiler options in the Arguments field.

Arguments: -source-path . -doc-sources ./ -window-title “HelloWorld” -main-title “My HelloWorld Greeter Package”

Note: the “./” is the current directory in UNIX writing(same as Mac OS X). You can also write the full path, which is the same as above in the “Working Directory” You can give it a window title, and the main title will be a title in the header of the html file. The docs will be written in HelloWorld in a folder called docs.

Click Apply, this will also save this perspective.

Click Run to generate the AS Docs.

Your documentation will be in /HelloWorld/docs The main file index.html will show you your docs.

Next I am hoping to find a more general solution, as this has to be changed each time your project changes, or you will need many different perspectives.

This is an incribale find, and I am stoked!

Happy Coding.

ASDocs on Mac

I am trying to figure out how to get AS Docs on my mac to work. I just spend the last four hours trying to get this working. I finally got it, and it seems like you need a “SRC” folder like what gets created when you have a flex project, but this is really for flash. I was able to figure this out from the command error, I guess I am learning after-all`-`

I am trying to document some actionscript 3.0 code, like that is seen in the adobe documentation.
Using terminal change location to the bin directory of the flex skd. The asDoc tool only seems to work from this location.

cd /Applications/Adobe Flex Builder 3/sdks/3.2.0/bin/

./asdoc -doc-sources=/Users/johnbarrett/Documents/Flex Builder 3/HelloWorld/

-source-path=/Users/johnbarrett/Documents/Flex Builder 3/HelloWorld/

The first line tells the compiler where your application is, and the second line tells where you want the compiler to output your docs.

Now lets run this using the src folder structure that the AS Docs Tool wants

./asdoc -doc-sources=/Users/johnbarrett/Documents/Flex Builder 3/HelloWorld/src

-source-path=/Users/johnbarrett/Documents/Flex Builder 3/HelloWorld/src