ByteArray Example

This page describes how to setup the ByteArray example application using  Flex and  Django.
Check the DjangoHowto page for more info on using Django with PyAMF.

Introduction

The  ByteArray class in Actionscript™ 3.0 provides methods and properties to optimize reading,
writing, and working with binary data used in the Adobe Flash Player 9 and newer.

This example demonstrates how to:

  • Create a webcam snapshot by capturing the  BitmapData using Flex
  • Wrap the image data with the ByteArray class and send it to a PyAMF remoting gateway
  • Use  Python to write the JPG file to disk
  • Run a simple webserver for static content that serves the JPG files
  • Use Flex to load the JPG and display it in the application

A live demo can be found on the PyAMF  blog.

Download

Grab the example from SVN with:

svn co http://svn.pyamf.org/examples/trunk/bytearray bytearray-example
cd bytearray-example/python

Alternatively, if you just want to have a look, you can browse the example online.

Gateway

The remoting gateway for the Adobe Flash Player and Python AMF clients starts on http://localhost:8000 when you launch
the development server:

python manage.py runserver

Note: make sure you have  Django >= 0.96 installed.

You should see something like:

Development server is running at http://127.0.0.1:8000/
Quit the server with CONTROL-C.

Client

You can simply open the SWF file and it will connect to  http://localhost:8000.

Press the 'Create snapshot' button to make snapshots and save them to disk. You can see the
snapshots in the View tab. The snapshots are saved in the python/gateway/images folder.


adding screenshot of ByteArray example

Attachments