Creating a Hello World iPhone Application Using Flash CS5
By Blue_Chi | Flash CS5 | Beginner
This tutorial will teach you how to create a simple HelloWorld iPhone Application using Flash CS5 and have it exported and installed on your device for testing purposes. This tutorial does not assume any AS3 knowledge as no ActionScript is required to export or install the application on your iPhone.
Exporting an iPhone application can be a lengthy process for a first timer as it will require you to generate a valid certificate and a provisioning profile from Apple and then have it all configured in your application and on your device. We will try to provide you with all the resources you need to be able to achieve all the needed certificates.
Basic Requirements to Create an iPhone Application using Flash
In order to be able to create an iPhone Application using Flash you will need the following:
- Flash Professional CS5 or higher – Previous versions of Flash CS cannot be used to make iPhone Applications.
- iTunes – iTunes is needed to get your iPhone UDID, it is also needed to install the Provisioning Profile and your application on your iPhone.
- A $99 dollar iOS Developer Program membership – This is necessary to generate the certificate and provisioning profile required to export your iPhone application. Without a valid certificate you will not be able to export your application, and without a profiling file you will not be able to test your application of your iPhone.
This tutorial will guide you through the process necessary to acquire all the necessary items in order to export your first iPhone application.
Create a Hello World iPhone Application
We are going to start off by creating a very simple Hello World Application, our application will not do anything other than display the message “Hello World” on the screen.
Start off Flash CS5, go through File>New and select iPhone OS as the type of file you want to create, click on OK when done.
Once you movie is create you will have to save it, go through File>Save and save your movie anywhere on your computer. Name your flash file as HelloWorld.
Inside this movie you can put anything just for the sake of seeing it work on the iPhone, we suggest that you grab the Text Tool and write Hello World on the stage.
The content of our HelloWorld app is ready, we now need to acquire a certificate and provisioning profile from Apple for our application.
Acquiring the Developer Certificate
You can test your movie inside the Flash authoring tool by going through Control>Test Movie and you should be able to see your movie running, but if you want to test your application on an actual iPhone or if you want to submit your application to the iTunes Store you will have to export your application using a valid certificate and a provisioning profile.
You only need to have one certificate for all your applications as it is needed to identify you as an authorized developer, while you will need a provisioning profile for each application as it will have application specific details and testing device specific details.
The first step to acquire your certificate would be to subscribe the Apple iOS Developer Program. this will require you to make a $99 payment and it’s valid for a year.
Once you are a member of the iOS Developer Program you must generate a certificate for your program. For Mac users this is a straight forward process explained clearly on Apple’s website. Windows users on the other hand will not find any instructions on how to do this on Apple’s website and must instead follow the instructions on Adobe’s website.
Regardless of the platform you use, you will have to convert the certificate your acquire from Apple’s website into a format a P12 file so that Flash understands it. To do this you must follow the instructions on Adobe’s website regardless of the platform you use.
Once you have your certificate ready you will have to save it somewhere on your desktop until we generate our provisioning profile.
Acquiring the Provisioning Profile
The next step is to acquire a provisioning profile for your application, there are two types of provisioning profiles, one for development (testing purposes) and the other one is for distribution (submitting your application to the iTunes Store). We are going to create one for testing purposes as that is the purpose of this tutorial.
You can acquire your provisioning profile from the iOS Provisioning Portal. This will involve doing the following:
This will require you to do the following:
- Creating an application ID.
- Creating a device ID for devices you wish to test.
- Creating a provisioning profile.
You should not have trouble generating a provisioning profile, in order to acquire your device ID you will have to plug your device and access iTunes on your machine to note down its UDID number. Check the Summary tab in the device window, and click on Serial Number to uncover your UDID.
Use the keyboard shortcut to copy this reference then head back to the Apple to get your Provisioning Profile.
You should not find it difficult to follow the instructions on the iOS Provisioning Portal to acquire your provisioning profile, once you have your Provisioning Profile file ready save it somewhere on your machine and move to the next section.
Exporting the iPhone Application
Once you have all your certificates ready, you can export your iPhone application by going through File>iPhone OS Settings, from here you can configure your application and locate your certificates in order to generate the app. The General tab has some self-explanatory settings, the one you need to worry about for our purposes is the Deployment tab. From here you can select your certificate and provisioning profile. You may also configure the icons for your application from the Icon window if you want to do that.
Once you are ready simply click on the Publish button to create your iPhone application, this should take a bit longer than your regular Flash movies so do not worry if takes a few minutes to complete the publishing process.
Installing the Application on your iPhone
The final stage of this tutorial will be completed in iTunes, first thing you will have to do is install the provisioning profile on your iPhone. To do this go through File>Add To Library and browse for your provisioning file. Once you add it to the library you will have to Sync your phone. This should install the provisioning file on your device. To check on your iPhone if the Profile has been installed you can go through Settings>General>Profiles (On your iPhone) and look for the profile there.
Once you have the profile installed you can add your application to your iTunes library by dragging it directly there or going through File>Add To Library. Again, sync your iPhone with your library to get the application on your device.
You should hopefully have your application installed on your iPhone at this stage.
If you have any troubles you should review the iPhone FAQ on Adobe’s website and the instructions on Apple’s iOS Dev Center. You should also feel free to post any comments or questions you have at the Republic of Code Forum.
– End of Tutorial
var gradientScaling:Number = 1 ; // use this for easy scaling of the gradient var gradientMatrixWidth:Number = 50 * gradientScaling ; var gradientMatrixHeight:Number = 50 * gradientScaling ; var gradientMatrixRotation:Number = 0.00 ; var gradientTx:Number = 0 * gradientScaling ; var gradientTy:Number = 0 * gradientScaling ; var gradientDrawWidth:Number = 50 * gradientScaling ; var gradientDrawHeight:Number = 50 * gradientScaling ; var gradientOffsetX:Number = 0 ; // use this to move the gradient horizontally var gradientOffsetY:Number = 0 ; // use this to move the gradient vertically var gradientMatrix:Matrix = new Matrix ( ) ; gradientMatrix.createGradientBox ( gradientMatrixWidth, gradientMatrixHeight, gradientMatrixRotation, gradientTx + gradientOffsetX, gradientTy + gradientOffsetY) ; var gradientType:String = GradientType.LINEAR ; var gradientColors:Array = [0xff0000, 0xff] var gradientAlphas:Array = [1, 1] var gradientRatios:Array = [0, 255] var gradientSpreadMethod:String = SpreadMethod.PAD ; var gradientInterpolationMethod:String = InterpolationMethod.RGB ; var gradientFocalPoint:Number = 0 ; var gradientGraphics:Graphics = this.graphics; // replace 'this' with the object you want to apply the gradient to gradientGraphics.beginGradientFill ( gradientType, gradientColors, gradientAlphas, gradientRatios, gradientMatrix, gradientSpreadMethod, gradientInterpolationMethod, gradientFocalPoint ) ; gradientGraphics.drawRect ( gradientOffsetX, gradientOffsetY, gradientDrawWidth ,gradientDrawHeight ) ; gradientGraphics.endFill ( ) ; /*###################### * REMEMBER THESE IMPORTS * ###################### import flash.display.GradientType; import flash.display.Graphics; import flash.display.InterpolationMethod; import flash.display.SpreadMethod; import flash.geom.Matrix; */