📜 ⬆️ ⬇️

Making an iphone application on flash CS5

So, due to the fact that Apple removed the magic limitation and now you can officially make iPhone / iPad applications on Adobe Flash CS5 (details: flash-ripper.com ), a splint appears to your eyes - how to do it yourself .

What will we do:
Simple p2p chat

What is required:
1. Adobe Flash CS 5 (download from adobe.com)
2. iPhone Certificate (do not worry, tell you where to get)
3. (optional) jailbroken iphone / ipad
')
So let's go ...

Creating iphone applications


Open Adobe Flash CS 5 and select iPhone OS in Create New:

Voila Now you can create.

(In principle, you can skip everything up to Deploy and make any application of your own, but your business)
Go to the application components:


Let me explain what and why:
Your id is the id that Adobe Stratus assigns. According to this id, it will be possible to establish a p2p connection with the application and send audio / video / commands directly.
Remote id is the id that we connect to / connect with.

The rest should be clear.

We register id-shnik.
TextInput near Your Id, call localIdText and make it read-only
TextInput near Remote Id we call remoteIdText
Big and terrible TextArea let's call chatLog
Connect Button - btnConnect
Send Button - btnSend

Now a small code for the frame:
import flash. net . NetConnection ;
import flash. events . MouseEvent ;

const SERVER_ADDRESS: String = "rtmfp: //stratus.adobe.com/" ;
const DEVELOPER_KEY: String = "register in adobe stratus and you will be given it ;-)" ;

var connection: NetConnection ;
var streamIn: NetStream ;
var streamOut: NetStream ;

var isInStreamInitialized: Boolean ;

enabled = false ;

connection = new NetConnection ( ) ;
connection. addEventListener ( NetStatusEvent. NET_STATUS , connStatus ) ;
connection. addEventListener ( AsyncErrorEvent. ASYNC_ERROR , asyncErr ) ;
connection. connect ( SERVER_ADDRESS + DEVELOPER_KEY ) ;

function connStatus ( event: NetStatusEvent ) : void {
if ( event. info . code == "NetConnection.Connect.Success" ) {
localIdText. text = connection. nearID ;
initOutStream ( ) ;
}
}

function asyncErr ( event: AsyncErrorEvent ) : void {
trace ( event ) ;
}

function initOutStream ( ) : void {

isInStreamInitialized = false ;

enabled = true ;

streamOut = new NetStream ( connection, NetStream . DIRECT_CONNECTIONS ) ;
streamOut. addEventListener ( NetStatusEvent. NET_STATUS , streamStatus ) ;
streamOut. publish ( "media" ) ;

var streamOutClient: Object = new Object ( ) ;
streamOutClient. onPeerConnect = function ( farStream: NetStream ) : Boolean {
remoteIdText. text = farStream. farID ;
initInStream ( farStream. farID ) ;
chatLog. text = "[Connected] \ n " + chatLog. text ;
return true ;
} ;
streamOut. client = streamOutClient;
}

function initInStream ( farID: String ) : void {
if ( isInStreamInitialized ) return ;
streamIn = new NetStream ( connection, farID ) ;
streamIn. addEventListener ( NetStatusEvent. NET_STATUS , streamStatus ) ;
streamIn. play ( "media" ) ;
streamIn. client = this ;
isInStreamInitialized = true ;
}

function streamStatus ( event: NetStatusEvent ) : void {
trace ( "streamStatus:" + event. info . code ) ;
}

function receiveMessage ( msg: String ) : void {
trace ( "receiveMessage:" + msg )
chatLog. text = "<<" + msg + " \ n " + chatLog. text ;
}

function sendMessage ( msg: String ) : void {
streamOut. send ( "receiveMessage" , msg ) ;
chatLog. text = ">>" + msg + " \ n " + chatLog. text ;
}

btnSend. addEventListener ( MouseEvent. CLICK , function ( e : MouseEvent ) : void {
sendMessage ( messageText. text ) ;
messageText. text = "" ;
} ) ;

btnConnect. addEventListener ( MouseEvent. CLICK , function ( e : MouseEvent ) : void {
initInStream ( remoteIdText. text ) ;
} ) ;


I will not explain it. Who cares - Welcome to the comments.
On the topic of the code itself and the use of Flash components - yes, it’s crooked, yes, you can normally - but this is just an experiment ;-)

Deploy


So the app is done. Cmd + Enter (or Ctrl + Enter) ... and we see a standalone player.
But it's boring :-( I want to see the application on the device. Feel it.
Let's get started First you need to build ipa.
Publish IPA

In order to make ipa, we need an iPhone certificate.
You can get it in two ways:
1. You are a registered Apple Developer, paid $ 100 and you already have a magic file
2. You just want to try to make an iPhone application, or make an application for Cydia
In the first case, everything is already there :) In the second, go and download p12 from here

Now let's set up publishing. Open File -> Publish settings. Go to the Flash tab.
Near Player: iPhone OS we press the Settings button:

In the Deployment tab, specify the path to the certificate p12
Password: 1234
We also specify the Provisioning profile. The result is something like this:


Everything. Now we press File -> Publish and sadly wait ...


In the folder c fla we now have ipa. Urya! Left a little bit

Launch ipa on iPhone / iPad

I'll tell you how to do this when using the gray key + jailbroken device.
And to make it very simple:
1. Double click on ipa - iTunes will open and our ipa will be added to the applications.
2. Synchronization with the device - the application on the device
Actually everything!

Chat in action:
iPad:


Mac:

(I typed id with my hands)

Archive with fla and ipa:
http://batsuev.com/habr/p2p-chat.zip

Source: https://habr.com/ru/post/104538/


All Articles