Flash Player 10
May, 29 2008On May 15 2008 a new Flash player version 10 was released. It is a beta version so it is not final. There are a number of new features and new Actionscript including 3D support. Below there is an example of a rotating textfield. Lee Brimlow from gotoandlearn.com has a very nice video tutorial. However I have been experiencing some problems, which are outlined below.
Getting started
You can either follow the links on the intro to player 10 or I will present all the links here. To get started you need to install the Flash Player 10 from the Adobe website. If it was successful you should see above a rotating textfield. In order to develop for player 10 you need to use the Flex 3 SDK or you can use Flex 3 if you have it, since there is currently no support in Flash CS3. You can download the Flex 3 SDK here. You need a nightly build of the SDK dated after May 15. Place it on the desktop. Now you need to make some changes in the file in the folder frameworks - flex-config.xml. This is described on a Adobe page. There is, however, one change, which I found out after a long search and not described there. It can happen that you cannot load any textfiles and when you test using try and catch you will get a security error #2148. To avoid this open again the flex-config.xml and change "true" in the following line: <use-network>true</use-network> to "false". Now the error should disappear. You are now ready to write your first script for player 10. I will present the script for the above movie.
The first player 10 script
We place an empty .as file in the flex_sdk_3 folder. Name the file "Start.as". Open the file using a texteditor or as I usually do using Flash CS3. The file is very similar to a regular AS3 file with a few additions.
NOTE: it is important to add return type of a function also if void or there will be an error.
package
{
import flash.display.*;
import flash.events.*;
import flash.text.TextField;
/*
/ Setting the movie parameters.
*/
[SWF(width="400",height="400",backgroundColor="0xF1F5F9", frameRate="24")]
public class Start extends Sprite
{
private var bitmap:TextField;
public function Start ():void
{
/*
/ We create a textfield and position it.
*/
bitmap=new TextField;
bitmap.mouseEnabled=false;
bitmap.multiline=true;
bitmap.autoSize="left";
bitmap.x=175;
bitmap.y=200;
addChild(bitmap);
bitmap.text="You have installed Flash Player 10.\n";
/*
/ We add an eventlistener to have continous rotations.
*/
addEventListener (Event.ENTER_FRAME,downHandler);
}
private function downHandler (event:Event):void
{
/*
/ We add new AS for rotating in all directions.
*/
bitmap.rotationX+= 5;
bitmap.rotationY+= 1;
bitmap.rotationZ+= 3;
}
}
}
Instructions for Flex-SDK users
This is not required if you have Flash CS4. Once you wrote your script you want to compile it. I describe the procedure for the Mac but for PC it should be similar. Open the Terminal window and enter this code:
cd Desktop/flex_SDK_3/bin/
then press return. Then enter this code followed by the name of the class file:
./mxmlc ../Filename.as
Then press return and the script will be compiled. Any errors will be shown. And this concludes this tutorial.
Other resources
Mail Form
Leave any comments here. Please enter a valid email.