Category Archives: Actionscript 3.0

Flash & Version Control

The Hawaii Flash User Group is hosting a meeting on version conrtol for flash and AS 3 projects. Please RSVP on the Adobe groups site if you are planing to come!

The meeting will be viewable on-line through Adobe Connect,and will be at 1:00 pm Hawaii Time

http://groups.adobe.com/posts/eecc3ef4ac

AS 3 Must Visit Events

Using Twitter?
If you are and you are a Flasher Myself(@hfug) and Marvin from Beautify Code(@beautifycode) has started a hash tag series on twitter.

The idea is simple, which Marvin deserves Full Credit, he just thought of a calendar which shows every Actionscript- Event/Conference/Meeting worth visiting in 2010. Whenever you know anything you can simply post it via Twitter! and we’ll add it (later surely automatically) to the calendar. The more people adding dates the more events will become well visited. So don’t shy to tweet !

For example the Latest Hawaii Flash User Group Meeting is on the calendar and you can mention it on twitter this way
Adobe mobileMax 1/27/10 Honolulu, Hawaii #as3mustvisit

You can view the Calendar at http://hawaiiflash.net/calendar

Besides we’ve got following ideas for that:

  • As WordPress Plugin
  • Widget
  • “Upcoming events””shown as list for month
  • Filtering

java Vs. AS 3

java


package abc ;

public class C1 extends c2 {
    private int v1;
    public c1() {
        this.v1 = 5;
    }

    int method(int 1) {
        return v1;
    }
}

Actionscript 3.0


package abc{
    public class c1 extends c2 {
       
        private var v1:int;
        public function c1() {
            this.v1 = 5;
        }
        function method(v1:int):int {
            return v1;
        }
    }
}

In a java application, the main class has to have a main method,
public static void main(String{} args) to start the program.


public class Test {
    public static void main(String[] args) {
        //starting point
    }
}

In a Actionscript 3.0 application, the main class starts the program from its non-arg consructor.

Moreover, the class must inherit MovieClip or Sprite from the flash.display package, otherwise, compile error will occur


package {
    import flash.display.*;
    public class Example extends MovieClip {
        public function Example() {
            //the starting point of the program
        }
        public function Example(args:int) {
        }
    }
}

DataGrid Example

I love using FDT now, but in doing so I am also trying to use AS 3, and not use the Flash IDE. Today after going through just hell trying to get web services working, which I can’t get to, I decided to try something else.

I am trying to make a very simple datagride example, now in the Flahs IDE I drag the dataGrid component in the library, and add the actionscript, and everything is cool. However, FDT does not have a library like the Flash IDE and therefore I am trying to get it working just in FDT. I am wondering if it is possible?


package {
    import flash.display.MovieClip;
    import fl.controls.DataGrid;
    import fl.data.DataProvider;

    public class DG extends MovieClip {

        //set variables
        var myDataProvider:DataProvider = new DataProvider();
        var myDataGrid:DataGrid = new DataGrid();

        public function DG():void {
            
            myDataProvider.addItem({ID:"01", Name:"Johnny", Email:"johnbarr@hawaii.edu", Web:"hfug.net"});
            myDataProvider.addItem({ID:"02", Name:"Snoopy", Email:"snoopy@snoopy.com", Web:"snoopy.com"});
            myDataProvider.addItem({ID:"03", Name:"Bugs Bunny", Email:"bugs@bunny.com", Web:"bugsbunny.com"});

            myDataGrid.addColumn("ID");
            myDataGrid.addColumn("Name");
            myDataGrid.addColumn("Email");
            myDataGrid.addColumn("Web");
            myDataGrid.dataProvider = myDataProvider;
            myDataGrid.width = 530;
            myDataGrid.move(10, 10);
            addChild(myDataGrid);
        }
    }
}



Favorite Actionscript 3.0 Editor

So I started a Poll on my Twitter account over the last 2 days. I was curious on which editor did flash developers perfer to use. I did not promote any editor, or tell people how to vote in any way, below is what people voted on.

(1) FDT – Clearly the choice of Flash Developers!
(2) Flash Develop (windows only)
(3) Flash Builder
(4) Other (Text Mate, and Note Pad) I don’t understand this one, maybe so can explain to me?
(5) The Flash IDE - okay nobody likes to code in the Flash IDE, so this dude is last!

Take the vote below on TweetPoll, and voice your opinion!

Setting up Flash Remoting with AS 3 & ColdFusion

Setting up flash remoting with actionscript 3.0 and ColdFusion
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>

When you run your flash file you should see this in the output window

download project

Move com folder to your ColdFusion localhost host, if you are running the default set up you will need to change the port to 8500. Then run the fla file, you should be fine, with flash & ColdFusion working together!

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.

loading external images

to load an image in flash is easy and only take a few lines of actionscrit

var myLoader:Loader = new Loader();
myLoader.contentLoaderInfo.addEventListener(Event.COMPLETE, onLoaded);
var fileRequest:URLRequest = new URLRequest("myImage.jpg");
myLoader.load(fileRequest);
function onLoaded(e:Event) {    
      // the image is now loaded, so let's add it to the display list!    
      addChild(myLoader);
}

I used the above image, but you can use any image at all, If you don’t use Snoopy just make sure to change the movie size to at least match the size of your image.

checking your actionscript version

Here is a script to check which version of actionscript your swf is


var request:URLRequest=new URLRequest("project.swf");
var loader:Loader=new Loader();
loader.contentLoaderInfo.addEventListener(Event.COMPLETE,onComplete);
loader.load(request);
function onComplete(evt:Event):void {
    evt.target.removeEventListener(Event.COMPLETE,onComplete);
    trace("actionscript version - "+evt.target.actionScriptVersion);
}

Flash Guru to Speak at UH

Sam Rivello of Los Angeles-based Rivello Multimedia Consulting will lead two days of presentations beginning tomorrow for the Hawaii Flash User Group. The first, free night will cover Massively Multiplayer Online (MMO) environments and augmented reality. Tuesday’s “Premium Night” will cover more advanced topics relating to the PureMVC framework for Flash and Flex development.

Rivello has designed, developed or managed the development of over 400 Flash and Shockwave games and applications, many for Fortune 1000 companies. He is an Adobe Certified Designer and Developer for Flash, an Adobe Flex Champion, an international public speaker, and a university professor.

The sessions will be held in Room 219 of the Agricultural Sciences Building (1955 East-West Rd.) at the University of Hawaii at Manoa. To attend the free MMO and augmented reality session, RSVP at the Adobe Groups event page. Tickets for the advanced “Premium Night” session are $149, and can be purchased via PayPal through Sam’s RMC Roadshow blog post.

AS3 Debug Issues!

I have been making progress on getting the AS 3 debugger working in Flash CS 3.

I have a remoting project(it could be anything I want to debug)

Here is my actions panel, with the break point

debug

When I try to debug movie I get this error:


Attemping to launch and connect to Player using URL /Users/johnbarrett/Desktop/downloads/remoting_debug.swf

[SWF] Users:johnbarrett:Desktop:downloads:remoting_debug.swf - 1635 bytes after decompression

Warning: Domain 127.0.0.1 does not specify a meta-policy.  Applying default meta-policy 'all'.  This configuration is deprecated.  See http://www.adobe.com/go/strict_policy_files to fix this problem.

Warning: Domain localhost does not specify a meta-policy.  Applying default meta-policy 'all'.  This configuration is deprecated.  See http://www.adobe.com/go/strict_policy_files to fix this problem.

before running this I change the file FlashAuthor.cfg to include User

# FlashAuthor.cfg

#

# This file was automatically installed with one or more

# Macromedia applications. This file directs Macromedia Flash

# Player to provide alternate messaging for violations of the

# security rules for local .SWF files. The alternate messaging

# is designed for users who are authors of .SWF files rather

# than only consumers of them.

#

# If you are creating .SWF files for deployment as local files

# rather than for Web delivery, and you need to simulate the

# end-user experience for local security problems, try changing

# the value of "LocalSecurityPrompt" below to "User" rather

# than its default of "Author".

#

# For more information, see:

# http://www.macromedia.com/go/flashauthorcfg

#
LocalSecurityPrompt=User

now in the crossdomain.xml I have


<?xml version="1.0"?>

<!-- http://127.0.0.1/crossdomain.xml -->

<cross-domain-policy>

    <allow-access-from domain="127.0.0.1" to-ports="507" />

    <allow-access-from domain="*" to-ports="*" />

 </cross-domain-policy>