AS3, Convert Python Code to Flex AS3 with flex-pypy

I have officially been sucked into the Python vortex. I recently have really been digging IronPython, Jython and good old plain Python but have not ventured here yet. Google (They employ Guido), Microsoft (IronPython) and Sun (Jython) are all becoming infected pythonistas as well. But this is just too cool, Python to AS3 code with flex-pypy. This project is very young but could be fun, source at Google Code.

Haxe has a similar premise where it can compile to Flash6-9 versions of actionscript 2-3 which makes for a system with better reach. Python code for this is lots of fun and very flexible. Python is becoming a baseplane language and one great language for transcending platform lock-in.

Check out this snippet pulled from here (click to see sample game)

#/usr/bin/env python
This simple example has very little to do with the pygame
chimp example, except that it will act the same (more or less)
and it uses the same resources, only they got converted to
mp3s, pngs.

#Import Modules
from pypy.translator.flex.modules.flex import *

class MyRect:
def __init__(self,x,y,w,h):
self.x, self.y,self.w,self.h = x,y,w,h

SCREEN_W = 468

class Game:
def __init__(self):pass

def init(self,screen):
self.screen = screen
screen.layout = ‘absolute’
screen.setActualSize(SCREEN_W, SCREEN_H)

screen.addEventListener(‘click’,chimp_whip) = load_sprite(“py_background_png”);

self.chimp = load_sprite(“py_chimp_png”);

self.orig_y = self.chimp.y

img2 = self.fist = load_sprite(“py_fist_png”)
self.move = 1
self.spin = 0
self.hit = 0
self.hit_move = 1

self.sfx = {}
self.sfx[‘whip’] = load_sound_resource(“py_punch_mp3”)
self.sfx[‘nohit’] = load_sound_resource(“py_whiff_mp3”)

def loop(self):
img = self.chimp
if self.spin:
self.spin -= 1
img.rotation = self.spin*24
img.x += self.move * 8
if img.x > SCREEN_W-img.width:
self.move = -1
if img.x < 0: self.move = 1 if self.hit: self.hit -= 1 self.fist.y += 6 * self.hit_move if self.hit SCREEN_W - img_halfw: newx = SCREEN_W - img.width if newx img.x and e.stageX < img.x+img.width: game.sfx['whip'].play() game.spin = 20 else: game.sfx['nohit'].play() def flash_main( x=1 ): game.init(castToWindow(x))[/sourcecode]

28 Responses to “AS3, Convert Python Code to Flex AS3 with flex-pypy”

  1. bob Says:

    9ifNNj hi good site thx

  2. dongland Says:

    Oh.. It’s very interesting for me. 🙂

  3. Nzliaakt Says:

    Cool site, , gbsg,

  4. Lzielsfv Says:

    This is a best site, naruto, >:-[[,

  5. Wknapspk Says:

    Nice stuff,
    , eqs,

  6. Qxguxysc Says:

    Cool site, , dwge,

  7. Zdrzcepr Says:

    Visit this link please,
    , 61117,

  8. Rsalqejo Says:

    Visit this link please, , 258,

  9. Glphfxeb Says:

    Nice stuff, , =)),

  10. Gdvpvkok Says:

    This is a best site, , 8]]],

  11. Mubkpekx Says:

    Sorry, , %-))),

  12. porno hub Says:

    gfdg ggh dfhdfh fgh hgdfhg dfdasfgf dshfg h free xxx porno hub

  13. Says:

    comment6, , uljy,

  14. Says:

    comment5, 0 , qpb,

  15. Says:

    comment1, , yubj,

  16. Hero Says:

    hate me blue october
    [URL=]hate me blue october[/URL]
    dayana cadeau
    [URL=]dayana cadeau[/URL]
    lisa gleave
    [URL=]lisa gleave[/URL]
    monologues from plays
    [URL=]monologues from plays[/URL]
    boise school district
    [URL=]boise school district[/URL]
    creighton basketball
    [URL=]creighton basketball[/URL]
    a very old man with enormous wings
    [URL=]a very old man with enormous wings[/URL]
    texas medical board
    [URL=]texas medical board[/URL]
    composite volcano
    [URL=]composite volcano[/URL]
    aimee osbourne
    [URL=]aimee osbourne[/URL]
    ohio unclaimed funds
    [URL=]ohio unclaimed funds[/URL]
    classic arms
    [URL=]classic arms[/URL]
    ouran host club
    [URL=]ouran host club[/URL]
    animated heart
    [URL=]animated heart[/URL]
    deer park water
    [URL=]deer park water[/URL]
    nickel creek lyrics
    [URL=]nickel creek lyrics[/URL]
    marisa tomei nude
    [URL=]marisa tomei nude[/URL]
    lake county property appraiser
    [URL=]lake county property appraiser[/URL]
    walmart music download
    [URL=]walmart music download[/URL]
    banana guide
    [URL=]banana guide[/URL]

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: