Archive for June, 2010

RPC in Flash, AMF

June 3, 2010

1. AMF (Action Message Format):

  1. Zend AMF
  2. Java Server BlazeDC
    • Java AMF Client (enable Java applications talk to AMF compliant servers such as BlazeDS, LCDS, or AMFPHP)

2. Benchmarks:

  1. Census: RIA Data loading Benchmarks
  2. Ajax and Flex Loading Benchmarks ( Read Comments as well !  or Google the name as you’ll need to make your investigation to make your opinion)
  3. WebService-HTTP Service – AMF (test from themidnightcoders)
  4. AMF vs. JSON vs. XML:
    • reply from Java Performance blog :  there are different costs for large amounts of data to be send
    • original post by R.Monsol Haefel ( blogged about the advantages and disadvantages of AMF versus JSON versus XML )
    • 5 1/2 blog post : “Now if you’re developing the back-end services yourself, then please, by all means, use AMF if you’re using Flash, and JSON if you’re using AJAX.”

3. Definitions:

  • AMF3  : a compact binary object serialization protocol.
  • AMF (from midnight coders site):
    is a binary protocol designed by Macromedia/Adobe enabling Flash/Flex clients to communicate with backend services. When a Flex/Flash client performs a remoting invocation, the data about the call is encoded in the AMF format and carried in HTTP request to the server. The message contains information about what method should be invoked, values for the arguments, etc. Since AMF is binary and includes a lot of optimizations to keep the size of the AMF messages small, it becomes very compact in comparison to SOAP/XML used by Web Services
  • WebORB and AMF:
    When a Flex/Flash client sends a Remoting/AMF invocation to the web server, it is an HTTP request with binary payload. Web servers do not have built-in knowledge of how to handle and parse AMF messages. As a result, there must be something plugged into web server to enable processing of the AMF messages. Conceptually that piece of software is commonly referred as ‘Remoting Gateway’. A gateway is responsible for parsing and AMF messages, understanding what method should be invoked, handling method invocation and serializing return value back to the client. WebORB is an example of a remoting gateway. However, the product has evolved to provide significantly more functionality to enable other forms of client-server integration.

4. Notes:

  • Add Gzip option on tests ( apply Gzip to JSON string to compact sending data)

Convert Flash IDE graphics to vector data

June 3, 2010

There is a very nice JSFL script “Sel2Draw” (http://debreuil.com/ASDraw/) which converts selected Flash IDE drawings to vector data (as2), line & spline primitives,  see example in Appendix. Read 3D Vectors: From Vector Illustrations Via Sel2draw Into FiVe3d  http://www.motiondraw.com/blog/?p=119

Other links:

1. Converting SVG to FIVE3D, Flash Vector Graphics and Html5 Canvas
2. Shape Export to Objective-C

Appendix.

var drw0 = [
{    fill:[0x3cc00],
origin:[20,70],
records:[[20,49.25,34.6,34.6], [49.25,20,70,20], [90.75,20,105.35,34.6], [120,49.25,120,70], [120,90.75,105.35,105.35], [90.75,120,70,120], [49.25,120,34.6,105.35], [20,90.75,20,70]],
strokes:[[1,0×06600], “-“, “-“, “-“, “-“, “-“, “-“, “-“]
},
{    fill:”stroke”,
origin:[20,10],
records:[[120,10]],
strokes:[[1,0×06600]]
}];
// =====================
//create drawing here:
// =====================
_root.createEmptyMovieClip(“dr0”, 1000);
var img0 = _root[“dr0”];
drawImage(img0, drw0);

var drawImage = function(clip, dat)
{    var prevFill = null;
for(var el = 0; el < dat.length; el++)
{    var element = dat[el];
clip.moveTo(element.origin[0],element.origin[1]);
if(    element.fill == -1 || element.fill == “stroke”)
{    if(prevFill != “stroke”)
{    clip.endFill();
prevFill = element.fill;
}
}else if(element.fill != “donut”)
{    if(element.fill.length != 5)
{    clip.beginFill.apply(clip, element.fill);
}else
{    clip.beginGradientFill.apply(clip, element.fill);
}
prevFill = element.fill;
}
var recs = element.records;
var strokes = element.strokes;
var curStroke = -1;
if(strokes[0] == null)
{    clip.lineStyle();
}else
{    clip.lineStyle.apply(clip, strokes[0]);
}
for(var i = 0; i < recs.length; i++)
{    curStroke = strokes[i];
if(curStroke != “-“)
{    if(curStroke == null)
{    clip.lineStyle();
}else
{    clip.lineStyle(curStroke[0], curStroke[1]);
}
}
var rec = recs[i];
if(rec.length == 4)
{    clip.curveTo(rec[0],rec[1],rec[2],rec[3]);
}
else
{    clip.lineTo(rec[0],rec[1]);
}
}
}    clip.endFill();
return clip;
}