all groups > flash (macromedia) > december 2005 >
You're in the

flash (macromedia)

group:

Flash and Ruby/Ajax possible?


Re: Flash and Ruby/Ajax possible? David Stiller
12/27/2005 3:39:38 PM
flash (macromedia):
Tom,

[quoted text, click to view]

You'll be happy to find that a Niagra Falls' worth of water has gone
under the bridge. ;) ActionScript has matured dramatically. While Flash
doesn't support AJAX directly -- the J in that acronym is obviously out,
since Flash doesn't support JavaScript -- it does support XML, web services,
GET/POST forms, remoting, and more. One of the above ought to mesh with
whatever Ruby offers (I'm next to ignorant when it comes to Ruby).

It sounds like you have programming experience, so you may want to take
a peek at some of these URLs. Joey Lott has a terrific three-part primer on
AS2 (ActionScript 2.0), geared toward AS1 developers. The retroactively
named ActionScript 1 is more robust than the Flash 4 era ActionScript ...
it's hard to call them the same language, actually.

http://www.person13.com/articles/

The speed of your game play will determine how you make calls to the
server. If your needs are especially quick, you may want to check out
multiuser server software, such as ...

Adobe Flash Media Server (high priced)
http://www.macromedia.com/software//flashmediaserver/

ElectroServer (moderately priced)
http://www.electrotank.com/electroserver/

Unity (low priced)
http://www.moock.org/unity/

Oregano Multiuser Server (free)
http://www.oregano-server.org/

[quoted text, click to view]

Again, I'm so poorly versed in Ruby that I might just be talking out of
my tookus, but you can certainly interact with a MySQL database with Flash,
given a wide range of middleware options. The asynchronous part would
require a socket server, like those above.

[quoted text, click to view]

Oh, sure it is. Check out these tutorials on side-scrollers and
tile-based games (including isometric). Keep in mind, these tutorials are
mostly (if not entirely) Flash 5-era ActionScript -- and yet look at the
forward leap since Flash 4!

http://oos.moxiecode.com/
http://www.tonypa.pri.ee/tbw/index.html
http://www.strille.net/tutorials/part1_scrolling.php

So if you combine those concepts with the organizational improvements of
AS2 (class-based OOP, ever on the move toward true ECMA compliance), you're
in good shape to put much, if not all, of the logic into your SWF(s), or at
least balance out the work load.

[quoted text, click to view]

I think so, as long as you're flexible on the middleware.

[quoted text, click to view]

You may tire of the Actions panel pretty quickly. There are a number of
3rd party scripting IDEs available, including ...

PrimalScript (high priced)
http://www.sapien.com/

the ActionScript 2.0 Eclipse plug-in (free)
http://www.eclipse-plugins.info/eclipse/plugin_details.jsp?id=867

SE|PY (free)
http://www.sephiroth.it/python/sepy.php

Experiment! Have fun with it! Keep in mind, too, there's a forum here
specifically for ActionScript, so you're morely likely to find
script-related answers there.


David
stiller (at) quip (dot) net
"Luck is the residue of good design."

Re: Flash and Ruby/Ajax possible? David Stiller
12/27/2005 7:32:38 PM
Grumpy7 wrote ...

[quoted text, click to view]

Indeed. I didn't say it could not. :) SWFs can communicate with host
applications, such as browsers, which support JavaScript, via getURL(),
fscommand, and the new ExternalInterface class -- but Flash does not support
AJAX (Asynchronous JavaScript and XML), because Flash does not support
JavaScript. I could have -- and probably should have -- clarified my
statement to indicate what I just mentioned above, so I'm glad you brought
out this point.


David
stiller (at) quip (dot) net
"Luck is the residue of good design."

Flash and Ruby/Ajax possible? tdellaringa
12/27/2005 7:42:55 PM
Hi there,

I have a game idea which I originally wanted to build in XHTML and use Ajax
and Ruby on Rails/mySQL for backend and behavior development.

Because my game idea involves an isometric grid, HTML has become problematic
to get the quality I want. I'm thinking about Flash, but I'm not sure (since I
have not touched flash since version 4) what it can do these days.

Essentially, I want Flash to act as a kind of presentation layer. It would
display backgrounds and game elements, provide the interface and the look and
feel, tied with some HTML/Ajax. But when the user interacts with the game
itself, I want this to be handled asynchronously, talking to a Ruby (possibly
on Rails) backend with a mySQL database.

The game would be a type of multiplayer persistent online RPG. I would
definitely NOT want to handle the game itself inside Flash - that is not an
option.

Is this separation possible and can I use flash in this manner? Any insight is
greatly appreciated! I just downloaded the F8 demo (pro) and am just looking at
it now. Like I said, it has been a long time...

TIA

Tom
Re: Flash and Ruby/Ajax possible? David Stiller
12/27/2005 8:09:51 PM
Tom,

[quoted text, click to view]

They do still work, for sure. :) They're based on methods and
properties of the MovieClip class, so fire up the documentation on that
(arguably the most important class in ActionScript, since the SWF itself is
one big MovieClip instance).

Flash MX (aka Flash 6) introduced dot notation for event handlers ...

myClipInstance.onEnterFrame = namedFunction;

... or ...

myClipInstance.onEnterFrame = function() {
// anonymous function code here
}

.... rather than ...

// attached to instance itself
onClipEvent(enterFrame) {
// instructions here
}

.... which brought with it the ability to create and kill these handlers at
runtime, obviating the need for hack workarounds like setting _x and _y
values to zero during frame loops to cease movement.

You won't see OO organization on those Flash 5 tutorials, but the
*concepts* still apply. Even the syntax still applies, but the coding is
more efficient nowadays. Flash 8 introduces a number of Bitmap classes --
which I explored -- that boost runtime speed significantly.

[quoted text, click to view]

Sure, I can't argue that. Flash doesn't yet interact directly with a
database, but the socket servers I mentioned earlier do fill that gap.
Mainly I wanted to nudge you toward balancing a bit more logic on the SWF
side -- only because I love Flash. ;) Game GUI is about as sophisticated
as it gets, and your collision detections, pathfinding algorithms, and so on
could (should?) be in ActionScript.

[quoted text, click to view]

True.

[quoted text, click to view]

Hellish for ActionScript, agreed! But how much of this are you saying
you might have written in JavaScript? As it is, you're going to have to
write ActionScript to handle the GUI, JavaScript to handle your AJAX --
thanks, again, to Grumpy7 for helping my clarify my earlier comments --
*and* your Ruby game classes.

[quoted text, click to view]

Use one of the multiuser servers I mentioned, or write your AJAX into
the HTML page and trigger those functions via getURL(), fscommand, or the
ExternalInterface class -- or check out the JavaScript Flash Integration Kit
at http://www.osflash.org (not sure what method[s]) they're using; not even
sure it's asynchronous).

[quoted text, click to view]

I don't see a way to perform those collision detections without using
ActionScript, which will then pass through JavaScript and XML to your Ruby
app, or via Java sockets to your Ruby app.

[quoted text, click to view]

The multiuser servers support chat applications and, from what I've
heard or read, true real-time gaming. I can't vouch for that personally,
but they're your ticket.


David
stiller (at) quip (dot) net
"Luck is the residue of good design."

Re: Flash and Ruby/Ajax possible? Grumpy7
12/27/2005 10:05:13 PM
Re: Flash and Ruby/Ajax possible? David Stiller
12/27/2005 11:14:18 PM
Tom,

[quoted text, click to view]

I'll recommend two ActionScript games books. They're not necessarily
related to asynchronous gaming, but one (at least) has a chapter on the
subject. The co-author for this one, Joe Makar, runs (or co-runs) Electro
Tank and is involved with ElectroServer mentioned earlier. The other is
also very good, and if you can wait for the next edition, Glen says it will
feature a chapter on the new Flash 8 Bitmap classes.

Flash MX 2004 Game Design Demystified
Jobe Makar and Ben Winiarczyk

Macromedia Flash MX 2004 Game Development
Glen Rhodes

Note http://www.glenrhodes.com/ ... a link to his amazing Wolfenstein 3D
clone (yes, in Flash!).

[quoted text, click to view]

Ha, I hear ya, man. Good luck, for sure! :) I've very keen on game
design -- not that I'm particularly experienced -- but I empathize with your
enthusiasm and trepidation. Write me offline, if you like ... I'd be
interested in seeing your progress from time to time.


David
stiller (at) quip (dot) net
"Luck is the residue of good design."

Re: Flash and Ruby/Ajax possible? tdellaringa
12/28/2005 12:42:26 AM
Thank you David for all the info. I've seen 2 of the three links there on
scrolling and game design/tiles. I wondered how correlative they are to Flash 8
since they are basically Flash 5 techniques. I assume they would still work.

As far as having Flash "handle the game" - maybe I'm not being clear. If you
think of an online RPG, multiplayer - you create a persona, which is
persistent. When you log onto the game, you pick up where you left off, a week
ago, a month ago - a year ago. Your persona will interact with literally every
other player and every location, object, etc you come upon. For this I need a
full OO language with a database. I need the OO language to model all the
objects of the game, which can become fairly complex and will evolve over time.
I need the db to store the data associated with these objects.

I don't see how Flash can handle really any of that, other than doing it all
in Actionscript, and that would be hellish, really. I could write that stuff in
JS, so I could probably handle it in AS, but it just doesn't make sense to do
so - it's the wrong tool.

Ruby is a *pure* OO language, akin to Java, but more like Java on steroids I
guess - much more advanced in terms of getting things going, and there is a
framework called Rails which is even more helpful. Getting off topic, but just
to put my cards on the table.

I do realize there will be a steep learning curve for me if I choose the Flash
route. Maybe one of my main questions is how would Flash communicate with what
I write on the backend? Let me expand the idea a bit.

You are playing somewhat of a turn-based game. This wouldn't be a action game
or a scroller at all. It's role playing. You would move from screen to screen
based on location (in space for example) And if other people were in your same
zone, you would see them and possibly interact with them, or with other objects
in your zone/sector.

Say you want to explore some object in that sector, well Flash is handling
moving your icon or whatever over to that something - then when they meet,
Flash needs to send certain data (that it originally gets from the server side)
about who each object is and then accept return data based on actions chosen,
etc.

I want this done asynchronously because I don't want to reload the playfield -
it should happen seamlessly. The only time I want the playfield to "reload" is
when the player moves from sector to sector.

I'm not sure if that info helps or makes things blurrier :). I'm thinking
Flash can do what I want - and I want to get some tests running soon - I'm just
wanting to make sure it indeed can do what I need before I invest time only to
find out it can't.

Tom
Re: Flash and Ruby/Ajax possible? tdellaringa
12/28/2005 2:08:25 AM
Thanks again David, for the clarifications. Yes, I would expect to handle
things like collisions/meetings, movement, travel from one playfield to the
next with Flash AS. I would only expect the game objects themselves to be
modeled in Ruby. I'll have to check out some of the links you posted. The whole
thing is pretty daunting right now :) Not only am I just learning Ruby, I'm
ages behind in Flash, as I said. I have the capability to do it all I believe,
it's just a heap o' work in my face.

If anyone (or you again David) have any other comments, I'd be glad to hear
them!

Tom
Re: Flash and Ruby/Ajax possible? tdellaringa
12/28/2005 5:49:34 AM
Thanks again David! I will keep your info handy and may contact you offline - especially if I ever get this thing going ! :)

AddThis Social Bookmark Button