业界资讯:用as3 写后台服务?

          前几天,朋友给我介绍相关的as3命令行相关的外国资料,这些资料真是很有趣。之前用js 创造出nodejs,现在as3 同样有这种希望。下面是一些官方网的介绍和提供的sdk 下载,该技术更倾向于php,python ruby等相关的技术。下面看一下作者的介绍

   下面转载一些相关的资料,相信这些技术会带给新的惊喜。


http://www.redtamarin.com/help/faq


转载一些问答:


Frequently Asked Questions

Q: Does redtamarin use JIT?
A: yes

but let's got into more details

JIT is for Just In Time compilation

redtamarin is not a compiler
you will need to use a compiler from the Flex SDK
to take AS3 scripts and compiel them to ABC (Actionscript ByteCode)

then the AMV2 / Tamarin / RedTamarin run this bytecode
and it is at that moment that the JIT happen

Bytecodes are AVM2 instructions, the JIT
transform those into processor-specific instructions.

See also the redshell page
where you can view all the options that the shell support
to interpret code.


Q: Could it replace PHP or Java?
A: yes

a bit more context

as a programming language ActionScript 3.0
can do more or less everything that you can
do with Java or PHP

as long as it is on the command line or server side
(without a GUI) RedTamarin should allow you
to do about the same things you can do with Java or PHP

it is possible but may not already exists

for example, if you want to do your own HTTP
server in Java, I’m pretty sure you can find
many libraries that already do that

with AS3, well...
you probably gonna have to write this library


Q: Is it like like node.js but with AS3?
A: kind of, you can build a node.as3 with RedTamarin

the goal of RedTamarin is to provide to the developers
all the tools, libraries, etc. they need to build their own node.js in AS3

it may be subtle or generate a long debate
but let make the difference right now

RedTamarin is not a clone of Node.js
RedTamarin is closer to PHP, Python, Ruby, etc.

you can as well run AS3 in blocking-mode
with CGI, WSGI, etc. like you would do with PHP/Python

or run AS3 in nonblocking-mode or async,
even implement your own “main loop”,
like you would do with Node.js

Our goal is to use ActionScript 3.0 to program in the large, for the browsers using the Flash Player, for desktop and mobile applications using AIR, and with RedTamarin for the command line and the server side.

Q: Does it run on one thread?
A: by default, yes

but RedTamarin also supports the concept of Workers
which allow to delegate some part of the program to other threads

See the API documentation page
in flash.system.Workers .


Q: Does it run on 64-bit systems?
A: yes

the RedTamarin runtime: redshell
run in 32-bit or 64-bit
under Windows, Macintosh and Linux

See the redshell page.


Q: Is there a display list?
A: no

it is our goal to support the classes used
for the display list like StageSpriteMovieClip, etc.

but in itself RedTamarin does not render
anything graphically on screen.

Those classes will either return "not implemented"
or support a basic implementation to avoid to break code
but still without rendering anything on screen.


Q: Can it render bitmap to file?
A: no and yes

no, because RedTamarin does not render.

And yes, because if you do provide an implementation
or libraries to read/write bitmaps you can then save it to files.

Technically, as long as you are manipulating files
on the file system (and not rendering them on screen)
you can do any manipulations.

If you have an AS3 library or a command line tool
that can manipulate bitmaps, with the ByteArray
you should be able to generate any files you want.

What we don't have or don't provide yet
is the Bitmap and BitmapData classes
from the Flash Platform API.


Q: Can we use RedTamarin with Stage3D?
A: not by default

RedTamarin does not render anything on screen.

But you could compile AGAL using AGALMiniAssembler.as
as it uses only the ByteArray class.

Or you could take the current code base of RedTamarin
and add a rendering API on top of it,
we have seen examples with OpenGL and QT.

See project variant by @seantron .


Q: Any plans for RTMP?
A: it's not there yet but yes there are plans

so far, things like RTMP, RTMFP, etc.
are just protocols and we already have all the tools
to implement them.

What is really missing is the time and ressources to do it.


Q: Can you load external display list (swf animations)?
A: you can load a SWF as a file

but it will not render on screen,
it will not play anything by default.

The redshell can "play" (read) SWF files but only
understand the "code" tags.

But if you have some code that can manipulate SWF,
in particular read and understand tags like "images",
you could do more, for ex: extract jpg from SWF files,
or replace them by another one.


Q: Could some sort of "game-engine" run to host several game lobbies, get multiple players to join, then to run game logic as well with redtamarin?
A: hard to say.

only thing we know is using ActionScript 3.0
RedTamarin can probalby help you solve this
problem as it got file system access, sockets,
etc.

If your game client is also programmed in AS3
you could be able to send and receive binary
messages using ByteArray to read/write
to some extends you could probably use AMF
serialisation both client-side and server-side.

But “as is” RedTamarin does not have any
game or socket server ready to use, so you
would have to write it yourself.


Q: Can you "draw" a DisplayObjectContainer to a Bitmap then to a File?
A: no

RedTamarin doesn't do any rendering at all

The goal is not to build some kind of Flash Player,
but to allow the use of a language: ActionScript 3.0
into new territories like the command line and server side.


Q: Could we do things using ImageMagick, or FFmpeg?
A: yes

with RedTamarin you can manipulate files and
processes, so for example you could
load an image into a ByteArray,
save a copy into another filename
and run the imagemagick command line tool
while capturing its output.

In fact, if you do that often, you could
write a wrapper class for ImageMagick that
convert class options to command line arguments.

And Same for any other tools like ffmpeg.


Q: Does redtamarin do most of the multi-threading stuff for the developers to handle multi-socket server connections?
A: no, not yet

when it come to advanced stuff like
multi-threading, multi-sockets, etc.

The low-level functionalities are there
but the high-level utilities are not done yet.

Right now you could create a multi-socket
server using select() (later you could use poll()).

And you could have multi-threading using workers.

In the futur we plan to provide utilities
like SimpleSocketServerSimpleHTTPServer, etc.


Q: Could we use RedTamarin as an image processor server-side?
A: yes

either by providing your own image processing
functionalities or by reusing command line tools
like ImageMagick


Q: Can you load external timeline animations and FLV video and manipulate them to bitmapData?
A: no

again RedTamarin does not do any rendering
but we would like to add classes like Bitmap
and BitmapData and provide the same API
you can find in Flash/AIR.

In the same vein we could also provide a
FLV processing library which could allow to
manipulate/create FLV from the server-side.


Q: What are the challenges?
A: as any projects: ressources

right now finding developers who could work
with the C++ source code of RedTamarin is
very thin if not impossible, the project
complexity is a big barrier to entry.

Finding developers that can work with AS3
but using the RedTamarin API is probably
possible but still hard to find.

End of the day, you have basically one dev, me
so the challenge is to keep adding new functionalities
in a cross platform way, in an easy to use way,
and this require a lot of time.

Ideally if some kind of sponsor or supports
could be found, RedTamarin progress speed
would increase dramatically.


Q: Can I send bitmapData to the server, then the server overlays some displayObjects, and calls bitmapData.draw(), and send back new image?
A: no

at worst the BitmapClass does not exist from the
RedTamarin scope and it will say it’s missing

At best the BitmapData class exists but it is
just a mock implementation.

Ideally we would want to support fully
a BitmapData class that could do what you
describe, it’s not there yet.


Q: is there a specific roadmap?
A: yes

please look here

RedTamarin roadmap


Q: Do you know if AIR will ever be back on Linux?
A: no idea, better ask Adobe

but it is also why RedTamarin exists
we do love Linux and even if some programs
could not run with graphical interfaces
we would very much like to run them at least
on the command line.


Q: What would be the steps for someone to get redtamarin to run on a remote-server / hosting provider?
A: know the operating system, be able to install binaries

shared hosting would be probaly out of question
you would need dedicated hosting with ssh access.

Now the problem is your question is vague,
what does it mean to "run RedTamarin on a remote-server"?

  • do you want to run AS3 scripts with shebang?
    to replace Bash, PHP, Python ?
    to do system / devops type of work ?

  • do you want to run AS3 on a web server like Apache?
    replace index.php by index.as3?
    run as CGI?

  • do you need to run some kind of web service that supports AMF?
    like AMFPHP?

  • do you want to run some kind of socket server which proxy to Apache?
    like you would do with Node.js?

  • do you need to run a command line program?
    as an executable?
    maybe as a daemon or service?

You can do a lot of different things on a remote server wih a programming language.

We will try to provide much specific examples later
(for ex: how to run redtamarin as a server side script).


Q: Would you make an AWS AME ready to go?
A: yes

we don’t have them ready but yes we can definitively do that
and also provide docker, aptly and other setup.


Q: Would the SDK for Devs (locally) be different/larger than the one used on a remote server?
A: no

the RedTamarin SDK size is dependent on the operating system
and the number of other operating systems you want to support.

We don't make any differences if the system is local or remote.
In general, the SDK is about 30 MB for any operating system.

Adding more runtimes for other operating systems
can grow the SDK to around 50 MB.

If your concern is the size and you want to reduce it,
then you can do the "opposite", eg. support less.
for ex: keep only the 32-bit executables
and remove all the 64-bit executables.

See the redshell page
to know the details of all the different executables
included in the SDK.


Q: Does redtamarin support as3 workers and AIR Server Sockets?
A: yes

the good folks at Adobe added the Worker class
in their last update so yes workers can be used with RedTamarin.

For the “AIR Server Sockets”
you have the functionalities to build a socket server
you don’t have yet the same API as you can find in AIR
(eg. the class flash.net.ServerSocket).


Q: The dev version could support traces to a log file no?
A: yes, but it is better than that

not only you could trace to a log file from
any versions (release, debug, debug debugger)

but you could also redirect the stderr and stdout
to a file descriptor to write into a log,
or other little advanced things like that.

We plan later to also support syslog.h
and also be able to write to Windows NT system logs.


Q: Can it connect to Adobe ScoutCC
A: no

there is a prototype of the Telemetry API
inside the AVM2 but it does not connect to Scout.

Now communicating with Adobe Scout CC
is not something that should be too difficult,
we mainly need to understand AMF
and connect with socket to port 7934.

RedTamarin can do all that already,
but again someone need to take the time to write
a library or some code to demonstrate it.

For example, you could get inspired by the following projects
jcward/hxScout and claus/Pfadfinder
and have some utilities that send telemetry to Scout from your program.


Q: Can we use FlashDevelop to code for redtamarin?
A: yes

you can use any IDE or code editor you want
but you may need to adapt it to RedTamarin needs.

For FlashDevelop in particular, we don't have a tutorial yet
but in short you would install the RedTamarin SDK first
then create an "empty project" and add a "pre build"
using redbean.

If we can, we will provide a plugin or addon that can easily
add "create a redtamarin project" in Flash Develop.


Q: Is there SQLite Support, like found in AIR?
A: not yet

it is planed

For us, adding SQLite support would be
compiling against sqlite.h and its dependancies
add a C.sqlite.* package with
the C functions, structures needed by SQLite.

Then implement the AS3 classes like
flash.data.SQLConnection reusing the SQLite C functions.

Ideally we want to support SQLite, MySQL/MariaDB, MongoDB, etc.

As a kind of workaround, you can now use a ByteArray
to read/write data to it and save/load it from the file system.


Q: Could AIR NativeProcess control redtamarin program?
A: yes

redshell is like any other command line
executable program.

So yes NativeProcess can control it.

Ideally you would want to build a projector,
and use the following from the RedTamarin API

  • Program.argv to see which command line arguments
    you received from AIR NativeProcess

  • Program.workingDirectory to know where
    your programm is running

  • trace() to output strings to stdout

if we take the example from AIR documentation

var nativeProcessStartupInfo:NativeProcessStartupInfo = new NativeProcessStartupInfo();
var file:File = File.applicationDirectory.resolvePath( "yourprojector.exe" );
// ...
// you would see trace() from the projector
// in the onOutputData() function

http://www.redtamarin.com/developers

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值