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

Flex Skinning

I just went through a tutorial on flexcf and have discovered that you can skin a flex app! This opens a whole new set of doors! A project that I am putting together here locally is using flash CS 3 with ColdFusion, and one of the reasons was that flash CS 3 is easier to modify for a custom look, you know the design aspects, but now I see you can add wonderful designs to flex as well`-`

I checked out AsFusion as well as fill colors, does anybody know of other examples?

Setting up Remoting with Flex & ColdFusion

To get Coldfusion and flash to talk to each other is just as easy in Flex as it is in flash. Remember Flex is just the tool, and nothing more. When you compile flex you are just created a swf! To start this out I am just setting up the remoting call, later I will write a full app, which I have been meaning to do, but I have been too busy with school lately. You can check out flexcf Which as so many great examples of using this technology. It is run by Paul who has helped me a great deal in CF in the past! You can check out his blog too.

The mxml file


<?xml version="1.0" encoding="utf-8"?>

<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" creationComplete="initApp()" layout="absolute" pageTitle="Remoting Example" backgroundColor="White">

    <mx:Script>

        <![CDATA[

            import mx.rpc.events.ResultEvent;

            import mx.utils.ObjectUtil;

            import mx.controls.Alert;



            [Bindable]

            public var cfcResponse:String;



            //this gets called when the application is done being created

            public function initApp():void{

                //this calls the confirmCFC method in remoting.cfc

                cfc_ro.confirmCFC();

            }



            public function loadConfirm(event:ResultEvent):void{

                //this binds the cfcResponse var to the result of the RO call

                cfcResponse = event.result as String;

            }



        ]]>

    </mx:Script>



    <mx:RemoteObject id="cfc_ro" destination="ColdFusion" source="com.flex.remoting" showBusyCursor="true">

        <mx:method name="confirmCFC" result="loadConfirm(event)" fault="Alert.show(ObjectUtil.toString(event))"/>

    </mx:RemoteObject>

    <mx:Label text="{cfcResponse}" width="100%" />



</mx:Application>

the cfc


<cfcomponent output="false">



	<cffunction name="confirmCFC" returntype="any" access="remote">

		<cfreturn "This is a test to see if Flex is conecting to ColdFusion, from the file remoting.cfc">

	</cffunction>



</cfcomponent>

Setting up Flash Remoting with ColdFusion

I would like very much to thank Eric Meyer from curious minds

for helping me figure this out`-` I had started to try to convert a actionscript 2 remoting app to actionscript 3, but got really confused towards the end. I saw a post on his blog, and he was nice enough to work with me over e-mail fixing all my confusion!

Check out his blog, lots of great information.

Setting up flash remoting with actionscript 3.0 and flash CS 3.
Create a fla, call it remoting(or something that makes sense to you).

In the actions, type the following code


import flash.net.*;
var gateway:NetConnection = new NetConnection();

var responder:Responder=new Responder(onResult,onFault);





function onResult(responds:Object):void {

	trace("cfc result"+":"+" "+responds.toString());

}



function onFault(responds:Object):void {

	//loop over the fault structure

	for (var i:String in responds) {

		trace( i + ":" + responds[i] );



	}

}



// name the default cf test server on this machine

gateway.connect("http://localhost/flashservices/gateway/");



// name of the cfc and the function in it that you want to hit in dot notation

gateway.call("com.cfcs.getTest.getTestConn", responder/*this is where any arguments to the remote call go*/);



The cfc lives on my localhost/com/cfcs/gettestConn.cfc

The cfc will look like this


<cfcomponent displayName="getTest">

  <!--- Establish a Flash Remoting Connection --->

  <cffunction name="getTestConn" access="remote" returnType="string" output="true">

    <cfreturn "....connection successful">

   </cffunction>

 </cfcomponent>

This is just the set up, and yep just returns the string from the cfc. Once set up, you can use remoting the way that it is meant to be used`-`

Any question, problems? Let me know I will try to help.

I will posting another example on how to display the results from your cfc, and later how to pull database results into your flash movie as well.

happy coding`-`

Flash User Group in Hawaii ?

Flash User Group Here in Honolulu?

I just send the application to start a Flash User Group here in Hawaii.

I have joined many other groups, but they never offered recordings of their meetings, and so I was never able to participate in the discussions. I am hoping that something like this can happen here in Hawaii, there is a strong Multimedia presents here, and so I am hopeful.

I hope to have a place where people interested in flash, and the flash platform can hang out, meet and talk about flash and learn about flash and actionscript, and what direction flash is going.

I can see creating a place for designers as well as developers!

Now I am not too advanced, but I would love for this to work out, I think that it would be wonderful to have here in Hawaii.

Linking buttons in AS 3

Since this is just a movie for a button, make the stage 100 px by 35 px, as we don’t need any more room that that for this button.

Create a Layer, called “visuals” this is where all the visuals will go, and will be the layer for the button.

drag a button on the the stage(window>common libraries>buttons) pick any button you like, and place it on the stage that you just created. If you double click the button, you can get into the movie clip so that you can create new text on the button. In the button movie clip you will see many layers, but you want to concentrate on the text layer. On this text layer, double click on the text on the button, and change the text. This is not necessary at all, but I doubt you want your button to say “Enter.” However, there are situations for this.

Give the button an instance name “visit_btn”

The reason why you want to use this instance name is so that you can communicate the button with actionscript.

create a new layer called “actions”, this is where all your actionsctipt you go. To get to the actions panel right click on this layer, and picks actions, or go to Window>Actions

Type the following code in the actions window


visit_btn.addEventListener(MouseEvent.CLICK, visit);

function visit(e:MouseEvent):void {

	var request:URLRequest=new URLRequest("http://hfug.net");

 	navigateToURL(request, "_self");

}

Here is my completed swf

[kml_flashembed fversion=”9.0.0″ movie=”http://hfug.net/wp-content/uploads/2010/03/myButton.swf” targetclass=”flashmovie” publishmethod=”static” width=”100″ height=”35″]

Get Adobe Flash player

[/kml_flashembed]

If you are un sure about any of this, please leave a comment, so I can help you through this. This post was motivated from a friend that says linking in actionscript 3 takes too much code, but as you can see it is straight forward, and very easy.

Color Code final working!

Here is a simple actionscript 3.0 preloader to demostrate that the code with color hightlighting is finally working!

I am using CodeColorer This is a great plugin, which allows you to color your code, provides links to the docs for keywords, and also allows lin numbers.


stop();



this.loaderInfo.addEventListener(ProgressEvent.PROGRESS, onProgress);

this.loaderInfo.addEventListener(Event.COMPLETE, onComplete);



function onProgress(e:ProgressEvent):void{

	var loaded:Number = e.target.bytesLoaded;

	var total:Number = e.target.bytesTotal;

	var pct:Number = loaded/total;

	loader_mc.scaleX = pct;

	loaded_txt.text = "Loading... " + (Math.round(pct * 100)) + "%";

}



function onComplete(e:Event):void{

	nextFrame();

}

Foundation ColdFusion 8 for Flash CS4

Foundation ColdFusion 8 for Flash is the only book on the market that teaches designers and developers alike how to combine these two powerhouse programs to create dynamic Web sites and Rich Internet Applications (RIAs). This book covers the latest version of these two programs. It is a must have for Flash professional who want to extend their skills to cover the complete cycle of Web design.

Continue reading Foundation ColdFusion 8 for Flash CS4