Archive for the ‘Flash’ Category

firefox flash focus

Wednesday, April 23rd, 2008

D’oh! I was having a focus problem on a webpage with an embedded flash object (produced with openlaszlo). If the user set focus on some other part of the page, and then returned to the flash object, focus would not return immediately without some “poking around” — clicking different elements. It turned out this was because the object was embedded using code that contained a title, and therefore a floating tooltip, and that tooltip was stealing focus. The solution for me was just to remove the “title=…” part of the “object classid=…” tag.

OpenLaszlo DHTML with SOLO deployment

Wednesday, November 21st, 2007

OpenLaszlo 4.0 has decent DHTML generation. If you are using the command-line compiler for making SOLO deployed material, however, it is not completely obvious what to do.

Specifically, if you compile a source file such as example.lzx:

lzc –runtime=dhtml basic.lzx

You get a “basic.js” file. Tracking down what to do with this file is another matter.

In the tomcat servlet thingie for OpenLaszlo, there is a SOLO Deploy Wizard for DHTML, buried in:

openlaszlo/trunk/lps/admin/solo-dhtml-deploy.jsp

This will take basic.lzx and give you everything you need to wrap it up (including javascript libraries, all the little icons needed for window decoration, etc.)

You can then take that model and return back to the command-line compiler, wrapping the .js file produced in all this material.

This is all fine, just a little non-obvious to people like myself who just use the command-line compiler, and don’t want to touch the tomcat stuff.

Here’s an example bundle: solo-dhtml-example.zip

webcam access from OpenLaszlo

Sunday, November 18th, 2007

We’ve written a few Flash applications using OpenLaszlo that need to access a webcam (”ambush“, “puppet“), and render a processed version of its input. This seems a little odd to do, since any webcam processing in practice requires use of a lot of Flash specific classes, so the Flash/DHTML portability of OpenLaszlo is lost. However, OpenLaszlo is such a pleasant way to develop Flash apps that we wanted to use it anyway.

There may be smarter ways, but the somewhat ugly way we found was as follows. First, we create global variables for our input and output bitmaps:

<script>     
  var src_bmp = new flash.display.BitmapData(160,120,true);
  var dest_bmp = new flash.display.BitmapData(160,120,true);
</script>

Then, we do some set-up in a global oninit method to enable our output bitmap:

<method event=“oninit”>
  _root.createEmptyMovieClip(“bmp”, 1);
  _root.bmp.attachBitmap(dest_bmp, 2);
</method>

Now we create a view for our camera input:

<view name=“camwrap” x=“160″>
  <videoview name=“mycamera” width=“320″ height=“240″>
    <camera name=“cam” width=“160″ height=“120″ show=“true”/>
  </videoview>
</view>

Now, we can access both our input and our output as bitmap objects:

var vid = (this.camwrap.mycamera[‘_getflashvideo’] != undefined)
  ? this.camwrap.mycamera._getflashvideo()
  : null;
src_bmp.draw(vid);
// use flash filters to process src_bmp and generate dest_bmp
 

See the adobe flash site for tips on filters you can use. Just make sure to add the full qualification to class names, such as flash.filters.ColorMatrixFilter.