tutorials

I have written many tutorials and this is the place that you will find them. Most of them are in flash, but a few of them are in ColdFusion. Who knows what ind of tutorials I will create in the future?

All of the flash tutorials can be found on my good friends website Graphic Mania who has many such tutorials on many of the topics in Graphic Design. I started writing for the site back in Flash SC 4, and I still do in Flash CS 6, which as been a number of years. Even though of the many changes in flash we try to keep up, with what is popular today. The later tutorials have been on using flash & AIR, and we are working n some gaming features.

Using the Color Picker
How To Create A Flash Login Screen Tutorial
How To Create A Flash Login Screen Tutorial – Part 2
Embedding Fonts for Components in Flash
Checkbox and AS3 in Flash CS4
Making a Guessing Game in Flash CS4
Please refer to:
For a listing of my ColdFusion tutorials
Select like with cfqueryparam
Create Update Delete example

TIOBE Index for May 2014 May Headline

‪#‎Adobe‬ ‪#‎ActionScript‬ enters top 20!

“This month ActionScript entered the TIOBE index top 20. ActionScript is a JavaScript dialect that is mainly used to write Flash programs to show interactive animations and videos. ActionScript’s popularity already peaked in 2008 and 2009, but after Steve Jobs announced to ban Flash from Apple’s devices, it lost popularity rapidly. Flash (and thus ActionScript) is still struggling to get into the mobile market, but it is gaining market share. For (small) web-based games, Flash and ActionScript are still market leader with an installed based of 96%, though.

The TIOBE Programming Community index is an indicator of the popularity of programming languages. The index is updated once a month. The ratings are based on the number of skilled engineers world-wide, courses and third party vendors. Popular search engines such as Google, Bing, Yahoo!, Wikipedia, Amazon, YouTube and Baidu are used to calculate the ratings. Observe that the TIOBE index is not about the best programming language or the language in which most lines of code have been written.

The index can be used to check whether your programming skills are still up to date or to make a strategic decision about what programming language should be adopted when starting to build a new software system. The definition of the TIOBE index can be found here.

‪#‎Actionscript3‬ ‪#‎FlashPlatform‬ ‪#‎AdobeAIR‬

Source – http://www.tiobe.com/index.php/content/paperinfo/tpci/index.html

1 Billion AIR Installations

The AIR team has announced that in April 2014 the number of AIR applications installed around the world (on different devices and desktops, so that does not include updates and installs) surpassed the billion mark (that’s billion with a B, as in 1,000,000,000 ). They also published some usage stats pertaining to OS (over half of the installs are on Android), use (games dominate at over 70%), and more.

Congratulations, Adobe AIR!

Loading and Saving XML

This is a demo I created to demonstrate how to load and save data to an XML file. In the demo below you can add and remove balls as well as change their color. When you are finished you can click on “save” which saves your work into an XML file.

<?xml version="1.0" encoding="UTF-8"?>
<balllist>
	<ball>
	
	<id>0</id>
	<x>80</x>
	<y>50</y>
	<c>0xFF0000</c>
	<m>50</m>
	</ball>
	<ball>
	
	<id>1</id>
	<x>330</x>
	<y>150</y>
	<c>0x00FF00</c>
	<m>100</m>
	</ball>
	<ball>
	
	<id>2</id>
	<x>450</x>
	<y>70</y>
	<c>0x0000FF</c>
	<m>75</m>
	</ball>
</balllist>

The XML file is then loaded using the following AS3 code. The data from the XML file is stored into an array “b” so that it can be easily accesssed and modified within the program.

var b : Array = new Array();
var loader : URLLoader = new URLLoader(); // used to load xml file
var xml : XML; // used to store XML data

loader.addEventListener(Event.COMPLETE, loadXML);
loader.load(new URLRequest("balls.xml"));

// gets executed when xml data has been loaded
function loadXML(e : Event) : void {

	var i : int;
	var n : int;
	
	xml = new XML(e.target.data);
	xml.ignoreWhitespace = true;
	n = xml.ball.length(); // # of balls in XML file
	// load xml data into ball array
	for (i = 0; i < n; i++) {
		b[i].x = xml.ball[i].x;
		b[i].y = xml.ball[i].y;
		b[i].c = xml.ball[i].c;
		b[i].m = xml.ball[i].m;
	}
}

To save the file, I just created a big string containing the XML code and sent it to a PHP routine via the “POST” method:

// saves the xml
function saveXML(e : Event) : void {

	var s : String; // string containing XML
	var h : String; // string to create a hexadecimal value for colours
	var i : int;
	
	// create xml as a string
	s = '<balllist>n';
	for (i = 0; i < b.length; i++) {
			s = s + "t<ball>n";
			s = s + "tt<id>" + i + "</id>n";
			s = s + "tt<x>" + b[i].x + "</x>n";
			s = s + "tt<y>" + b[i].y + "</y>n";
			h = b[i].c.toString(16);
			while (h.length < 6) {
				h = "0" + h;
			}
			s = s + "tt<c>0x" + h + "</c>n";
			s = s + "tt<m>" + b[i].m + "</m>n";
			s = s + "t</ball>n";	
	}
		s = s + "</balllist>";
		
		// pass string to php routine which saves the data, using POST method
		var req : URLRequest = new URLRequest();
		var loader : URLLoader = new URLLoader();
		
		req.data = s;
		req.contentType = "text/xml";
		req.method = URLRequestMethod.POST;
		req.url = "SaveXML.php";
		loader.load(req);
}

Finally I created a really simply PHP routine and saved it in a file called “SaveXML.php”. It simply dumps all of the text which was passed to it from Flash into the “balls.xml” file. Here is the code:

<?php

// simple routine to save xml file
// passed a large string from flash using post method

if (isset($GLOBALS["HTTP_RAW_POST_DATA"])) {
	$xml = $GLOBALS["HTTP_RAW_POST_DATA"];
	$file = fopen("balls.xml","wb");
	fwrite($file, $xml);
	fclose($file); 
}

?>

Why ActionScript 3.0 should be your first programming language

 ActionScript 3.0, is the best programing language for somebody just learning programing!

ActionScript sounds like a weird choice, right? It’s client-side, not server-side. You can’t connect to a database or create files on the fly without some sort of middleware (like java or ColdFusion).  ActionScript 3.0 can also create AIR applications that can be deployed everywhere, the desktop, iOS, and Android! ActionScript 3.0 is write once deploy everywhere.

I think ActionScript 3.0 is worth learning, and that it’s a great starter language for budding developers. Here’s why.

  • ActionScript 3.0 is syntactically similar to other C-style languages.
    Curly braces rule! Semi-colons are awesome! Getting comfortable with how AS3 looks and works will make Java less intimidating.
  • ActionScript 3.0 is strongly-typed.
    Strongly typed languages enforce rules for variable behavior. It’s particularly useful when debugging, and will help you understand what different variable types are and how they work across languages.
  • ActionScript 3.0 is Object oriented.
    Objects are at the heart of several programming languages, and supported in several more. Getting comfortable with how OOP works in AS 3 means it is easier to understand how it works in Java and other programming languages. In fact, ActionScript is in some ways similar to Java in how it’s structured.
  • ActionScript 3.0 is a dialect of ECMAScript.
    You can treat ECMA Script as a kind of subset that defines the basic language structure, syntax and semantics. Then ECMA is only a subset of ActionScript. The language adds a wide range of features to this subset.
  • ActionScript 3.0 supports Local Shared Objects
     Yep. Local storage “super cookies” have been available in Flash for years now. What’s more, key-value datastores are the next wave of databases.
  • ActionScript 3.0 supports event-driven programming.
    Event listening and handling is critical to game development or interactive experiences in which the sequence of user input can’t be (or shouldn’t be) controlled. Knowing how to generate, add and remove elements from the stage, or when an item can be safely garbage collected are portable concepts that you can learn with ActionScript.

Flash Player 12 & Adobe AIR 4 are now in beta

Flash Player 12 beta is ready for download – http://labs.adobe.com/downloads/flashplayer.html

Adobe AIR 4  beta is ready for download – http://labs.adobe.com/technologies/flashruntimes/air/

The new betas are code-named “Jones“. With this release, we introduce a new numbering scheme for our product versions, we will simply update the major version number with each subsequent release, doing away with minor releases altogether. In other words, beginning with the release of “Jones“, Flash Player will become Flash Player 12. With each new release, roughly every 3 months, that number will increase by one.

To use the new Flash Player, you will need to target SWF version 23

 

New and Updated Features

  • Mac .pkg Installation Support – Deploying Flash Player and keeping it up to date is a critical task for system administrators worldwide.In Flash Player 11.9 we added .pkg support for ease of deployment. In Flash Player 12 we’ve incorporated public beta feedback fromsystem administrators to improve the workflow and UI.
  • Internet Explorer 11 on Windows 7 Support – Microsoft has released IE 11 on Windows 7 and we plan to officially support this in Flash  Player 12
  • Safe Mode in Safari 6.1 and higher – Safari 6.1 includes an updated version of Safari with Safe Mode, which implements new securityrestrictions on the operation of browser plug-ins. To the extent possible, we’ve adapted Flash Player to transparently handle these changes. A small number of behaviors will change in the context of Safe Mode and are explained in the Known Issues section below.
  • 64-Bit PPAPI Flash Player for Chrome – We’d like to encourage those interested in 64-bit Flash Player for Chrome to please downloadthe latest build available in the Chrome Canary Channel.
  • Graphics: Buffer Usage flag for Stage3D – We’ve added a new enum Class called Context3DBufferUsage which defines twoconstants, STATIC_DRAW (default) and DYNAMIC_DRAW. These constants specify how buffers will be used in Stage3D. We’ve alsoadded a new parameter, called “bufferUsage”, to the constructors of VertexBuffer and IndexBuffer. This “bufferUsage” parameter uses one of the constants form Context3DBufferUsage one of the constants form Context3DBufferUsage, which will allow you to select the appropriate buffer type according to your needs.
  • Android Workers – Introduced as a beta feature in AIR 3.9, we’re continuing to improve this feature based on your feedback inpreperation for an official release in AIR 4.

Apache Flex 4.11 Released!

The Apache Flex project, the all-volunteer group of developers, and stakeholders in the development framework, today announced the release of Apache Flex 4.11.0. This release makes some important improvements over previous versions of Apache Flex and Adobe Flex including new and improved components and performance enhancements.

What’s new in Apache Flex v4.11.0?

The Apache Flex 4.11.0 SDK allows application developers to build expressive web and mobile applications using MXML for layout and ActionScript 3, an ECMAScript based language for client-side scripting.

The Apache Flex 4.11.0 release contains many improvements that professional software development teams will appreciate. This advances the framework forward. It is truly one of the best cross-platform programming languages used to write applications that are testable and can be compiled to run on multiple technology platforms from a single set of code.

Apache Flex 4.11.0 highlights include:

    • Support Flash Player 11.9.
    • Support for AIR 3.9.
    • 120 and 640 dpi mobile resolution/skin support, fixes to 480dpi skins.
    • mx:AdvancedDataGrid and mx:DataGrid speed improvements.
    • Added column sort type access to the datagrid columns in mx:Datagrid, s:Datagrid, and mx:AdvancedDataGrid.
    • Able to easily change mx:AdvancedDataGrid row and column item renderer spanning.
    • s:DataGridEditor will now be visible in ASDocs and be visible in the Tag inspector.
    • Minor changes to make SDK compile with Falcon compiler.
    • Added access to imageDecodingPolicy in BitmapImage.
    • Changed UIComponent removedFromStageHandler from private to protected to allow override
    • New experimental mobile spark datagrid.
    • Updated OSMF swc to latest version (2.0)
    • Renamed experimental supportClazzes package to be supportClasses.
    • Mobile Callout moved to spark and can be used in Desktop and Browser apps.
    • Support for [Experimental] metadata tag.
    • Over 50 bugs/issues were closed with this release

Download Apache Flex 4.11.0

Java vs AS3

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) {
        }
    }
}

Typewriter Text Effect with AS3

1. Create a new flash file (Actionscript 3.0) and save it as typewriter.fla.

2. Rename “layer 1″ to “actions”. Open the actions panel.
Declare the following variables:

var myText:String;
var counter:int = 0;

3. Create a TextFormat object in order to format our text.

var format : TextFormat = new TextFormat();
format.size = 16;
format.font = "Verdana";
format.bold = true;
format.color = 0xFFFFFF;

4. Create a TextField, set its properties as follow and add it to the display list.

var textField : TextField = new TextField();
textField.width = 600;
textField.height = 350;
textField.selectable = false;
textField.wordWrap = true;
textField.defaultTextFormat = format;
textField.x = textField.y =10;
addChild(textField);

5. Next create an initText function that set the “myText” variable to the string passed as argument. Also add an ENTER_FRAME event listener.

function initText(string:String):void{
   myText = string;
   addEventListener(Event.ENTER_FRAME, writeText);
}

6. The writeText function checks whether the counter variable is inferior or equal to the length of “myText”.
While it’s true, we use the substr method that returns a substring consisting of the characters that start at index 0 and with a length specified by counter. When it becomes false, we remove the ENTER_FRAME listener.

function writeText(e:Event):void{
   if (counter <= myText.length){
           textField.text = myText.substr(0,counter);
           counter++;
   }
   else{
      removeEventListener(Event.ENTER_FRAME,writeText);
   }
}

7. The text to be display is stored inside a text file. So create your text file, type your own text and save it as text.txt inside the same directory of your fla file. Then load the file. When the load is complete, it simply calls the initText function.

var textLoader:URLLoader = new URLLoader(new URLRequest("text.txt"));
textLoader.addEventListener(Event.COMPLETE, function(e:Event){initText(e.target.data);});

8. Here’s the final code, test your movie to see in action.

var myText:String;
var counter:int = 0;

var format : TextFormat = new TextFormat();
format.size = 16;
format.font = "Verdana";
format.bold = true;
format.color = 0xFFFFFF;

var textField : TextField = new TextField();
textField.width = 600;
textField.height = 350;
textField.selectable = false;
textField.wordWrap = true;
textField.defaultTextFormat = format;
textField.x = textField.y =10;
addChild(textField);

var textLoader:URLLoader = new URLLoader(new URLRequest("text.txt"));
textLoader.addEventListener(Event.COMPLETE, function(e:Event){initText(e.target.data);});

function initText(string:String):void{
   myText = string;
   addEventListener(Event.ENTER_FRAME, writeText);
}

function writeText(e:Event):void{
   if (counter <= myText.length){
           textField.text = myText.substr(0,counter);
           counter++;
   }
   else{
      removeEventListener(Event.ENTER_FRAME,writeText);
   }
}

To Download right-click, and save to your computer.

download_btn

Adobe roadmap for the Flash runtimes

Say Hello to “Irving” and  “Jones” and Flash Player releases!

Flash Player and AIR “Irving” and “Jones”

Adobe is planning its next two releases for late 2013 and early 2014. These releases continue to focus on premium video, gaming, security, and stability.

Some of the features being worked on for these releases include the following:

  • OSX Mavericks support for desktop Flash Player and AIR
  • Significant reduction in iOS packaging times
  • ActionScript concurrency for mobile (beta)
  • iOS 7 support (depends upon Apple schedule)
  • Support for Windows 8.1 PlayTo
  • Support for Windows 8.1 tab suspension improvements
  • Support for Windows Internet Explorer 11 back navigation caching
  • XXHDPI icon support for AIR Android
  • pkg installer bundle for Mac OSX (vs .dmg)

Read more on Adobe’s site about the Flash Runtimes Roadmap – http://www.adobe.com/devnet/flashplatform/whitepapers/roadmap.html