Archive for August, 2007

Tuesday, August 28th, 2007

Jens Krause beat me to the punch. I had brightness added to Tweener AS3 and was adding contrast and saturation as needed on projects but it has already been done!

WS-Blog has added in special properties for Tweener for brightness, contrast and saturation which was the only part missing from the public version of Tweener. I am not sure of the file size with this addition (Tweener is around 9kb) but it is probably the same size with this in as brightness in my updated copy was the same. Adding special properties in Tweener is quite simple and not enormous amounts of script needed and when compressed in the swf it is very small.

There are other kits like TweenerFilterLite, Animation Package etc that do these right now but you have to wait no longer for these functions in Tweener itself which has quickly become many flash developers favorite in AS3 and since it is compatible with AS2 in the same syntax it makes animation in flash and the learning curve for that from AS2 to AS3 non existent for motion.

Jens has a sample demo, script samples and source on his blog.

Thursday, August 23rd, 2007

Thibault Imbert from ByteArray released the first PDF Creator for AS3 / Flash 9 called AlivePDF.

The new BinarySocket and ByteArray handling adds essentially no limit to the imagination of what is implemented in AS3. Non programmers might not understand the immense power that brings to this language and platform in AS3. Essentially it allows creating and reading binary to manipulate any file type.

Thursday, August 23rd, 2007

Due to the suport of binary ByteArray and/or BinarySockets AS3 has been inspiring all kinds of things from PDF creators, to audio, to JPEG Encoders, to zip libraries, crypto libraries and many others. But you know that a language is inspiring or a platform is inspiring if it drives someone to make a Commodore 64 Emulator within it.

That is right, with AS3 as the tool Claus Wahlers has created FC64, which is an Open-Source Commodore 64 Emulator written in Actionscript 3 for Flash Player 9 licensed under the GPL version 2. Commodore 64 Emulator to read C64 emulator files/roms online and play them.

Summer Games anyone?

Wednesday, August 22nd, 2007

Well, one thing is for sure AS3 is inspiring programmers and Solve et Coagula made a Lisp interpreter for Flash9/AS3 as proof. Silverlight has some programming advantages over Flash due to the fact that many languages can be used for it and the DLR. But AS3 is a very fun language and inspires lots of great libraries through it’s simplicity. AS3 is based on the Javascript2 ECMA spec and it proves well that it might really take off and is worth your time to learn, you can make toys at least.

Try the AS3 Lisp intepreter 

Use the commands available here 

Some notes from the author:

AS3 Lisp Source

So I got asked a few times to post the source for the AS3 Lisp. I have and it’s here. Please keep in mind:

  • I wrote this a year and a half ago and didn’t know AS3 or Lisp very well
  • I never intended to release the source so I apologize if anyone is offended by any class names, variable names, function names or comments (such as a function call named getGUI.LoadInterface();)
  • I have since figured out a way better way to handle symbols in the system and it would really clean up a ton of stuff
  • Some one over at YCombinator News noticed that closures don’t seem to work and for that I apologize, if I were rewriting this (which I kinda am just in a different form) I would definitely make closures works since I now realize how important they are to Lisp
Tuesday, August 21st, 2007

Watch this interesting “seam carving” technology to resize images, image item removal, and manipulating images that go well beyond crop, resizing and retargeting.

[youtube=http://www.youtube.com/watch?v=vIFCV2spKtg]

Be sure to watch the end where you can edit the images and remove objects from the photography or image.

Tuesday, August 21st, 2007

Watch this interesting “seam carving” technology to resize images, image item removal, and manipulating images that go well beyond crop, resizing and retargeting.

[youtube=http://www.youtube.com/watch?v=vIFCV2spKtg]

Be sure to watch the end where you can edit the images and remove objects from the photography or image.

Tuesday, August 21st, 2007

Tinic Uro who works on the Flash player made some amazing announcements about the new beta flash player. Video is getting a major upgrade to the already pwning FLV format on the web, they are moving away from that however towards a H.264 standard format (can you say HD movies on your PC in Flash?). Silverlight (Windows Media VC-9), Quicktime and other formats were looking superior to FLV quality (although noone can beat the file size) but this has changed the game completely.

The people running the Flash product are just answering the calls of the market very effectively.

Some tidbits of what is possible with the new H.264 standard video in Flash:

  • Playing content of other formats inside of Flash without worrying about loading another player or plug-in. (MPEG player or Quicktime movies for instance)
  • Play HD video on your PC in Flash with support from video card manufacturers in the works.
  • Play AAC SBR data instead of MP3, 5.1 channel surround sound.
  • Use open source only tools for your complete video pipeline.

It seems Flash is determined to continue to lead video on the web

Tuesday, August 21st, 2007

Dojo Toolkit, a robust javascript library similar to my favorite js kit mootools, recently update and added some support for Silverlight effects. This is one really cool aspect of Silverlight in that it allows you to script/code it in many languages in the DLR (Dynamic Language Runtime) including ironpython, C#, IronRuby, javascript and others. Where as with Flash you only have Actionscript3 available.

Check out the Silverlight demos here:

butterfly.html 20-Aug-2007 18:19 33K
circles.html 20-Aug-2007 18:19 4.0K
clock.html 20-Aug-2007 18:19 7.3K
lion.html 20-Aug-2007 18:19 22K
tiger.html 20-Aug-2007 18:19 100K

DojoX

  • high quality implementations of previously experimental features: gfx (portable 2D drawing), data wires, offline, storage, cometd, etc.
  • dojox.gfx now includes Sliverlight support
  • many more features and improvements than there’s room for here.

Dijit

  • unified look and feel for all widgets
  • ambitious a11y and i18n features in every Dijit widget
  • a mature CSS-driven theme system with multiple, high-quality themes
  • huge improvements in system performance
  • data-bound widgets
  • Declarations for lightweight widget writing
  • a new page parser that allows instances of any class, not just widgets
  • no magic

Core

  • reduced API surface area (easier to remember and use)
  • dojo.query() always available, returns real arrays
  • from-scratch high-performance DnD system
  • Base (dojo.js) is 25K on the wire (gzipped)
  • dojo.data APIs finalized
  • new build system
  • new test harness for both CLI and browser use
  • dojo.behavior now marked stable and based on dojo.query
  • excellent animation APIs with Color animations in Base (always available)
  • all the features you’ve come to count on from Dojo (RPC, JSON-P, JSON, i18n, formatting utilities, etc.)

[ source ]

Friday, August 10th, 2007

When debugging flash sometimes you need to either debug in browser or check a past version of the Flash player or the new beta player to see how things are looking. Here is a list of some tools beyond the included debugging IDEs FlashCS3 and Flex2 that are helpful to making your flash projects more bulletproof.

  • Firefox Flash Version Switcher from Sephiroth


    Find out if your code is just messed in the latest version or an older version of the flash player. This has links to the older versions of the Flash player from Adobe that you are interesting in testing.

  • Xray Flash/Flex Debugging Kit by John Grden XRay is a flash/flex debugger

    for real-time debugging and spying on your code. It is 16KB for the connector that you add to your files but it is debugging in style. If you have any issues with a live app or to help during testing Xray is great. It also includes a nifty admin site that allows you to access objects and spy on your code at any time.

    Xray (The AdminTool) is a “snapshot viewer” of the current state of your Flash application without impacting the performance or the file size of your application. Xray’s true nature is to look into the very guts of the Flash application and disolve the 2d myth you see on screen to a 3D tangible entity you can truly crawl through.Xray is brought to you by Blitz Labs.

  • AS3 Debugging with Firebug and Actionscript from marcosweskampWhen using Firebug (a web developers Swiss army knife for browser debugging) you can also use actionscript to write to the firebug console with this class from marcosweskamp The code to Console.as for firebug is here.

  • Output Panel from Senocular
    Last but not least, try out this class that creates or mimic the output panel in flash
    . Another great quick class from senocular. You have to change your trace command to Output.trace but I recommend that you abstract logging anyways to a method that can determine to trace, Output.trace(str:*) or any further logging you might want to do for debug or application logs (it also makes it easy to switch out logging options). This Output panel can help when you don’t’ have the debugger available, or for use in a live debug mode of your application. This class can be implemented in minutes.

    package com.senocular.utils {
      import flash.display.Shape;
      import flash.display.Sprite;
      import flash.display.Stage;
      import flash.display.GradientType;
      import flash.events.Event;
      import flash.events.MouseEvent;
      import flash.geom.Matrix;
      import flash.text.TextField;
      import flash.text.TextFieldType;
      import flash.text.TextFormat;
      import flash.text.TextFormatAlign;
      import flash.text.TextFieldAutoSize;
    
      /**
      * Creates a pseudo Output panel in a publish
      * swf for displaying trace statements.
      * For the output panel to capture trace
      * statements, you must use Output.trace()
      * and add an instance to the stage:
      * stage.addChild(new Output());
      *
      * Note: You may want to place Output in an
      * unnamed package to make it easier to
      * trace within your classes without having
      * to import com.senocular.utils.Output.
      */
      public class Output extends Sprite {
      private var output_txt:TextField;
      private var titleBar:Sprite;
      private static var instance:Output;
      private static var autoExpand:Boolean = true;
      private static var maxLength:int = 1000;
    
      public function Output(outputHeight:uint = 150){
       if (instance && instance.parent){
        instance.parent.removeChild(this);
       }
    
       instance = this;
       addChild(newOutputField(outputHeight));
       addChild(newTitleBar());
    
       addEventListener(Event.ADDED, added);
       addEventListener(Event.REMOVED, removed);
      }
    
      // public methods
      public static function trace(str:*):void {
       if (!instance) return;
       instance.output_txt.appendText(str+“n”);
       if (instance.output_txt.length > maxLength) {
        instance.output_txt.text = instance.output_txt.text.slice(-maxLength);
       }
       instance.output_txt.scrollV = instance.output_txt.maxScrollV;
       if (autoExpand && !instance.output_txt.visible) instance.toggleCollapse();
      }
      public static function clear():void {
       if (!instance) return;
       instance.output_txt.text = “”;
      }
    
      private function newOutputField(outputHeight:uint):TextField {
       output_txt = new TextField();
       output_txt.type = TextFieldType.INPUT;
       output_txt.border = true;
       output_txt.borderColor = 0;
       output_txt.background = true;
       output_txt.backgroundColor = 0xFFFFFF;
       output_txt.height = outputHeight;
       var format:TextFormat = output_txt.getTextFormat();
       format.font = “_typewriter”;
       output_txt.setTextFormat(format);
       output_txt.defaultTextFormat = format;
       return output_txt;
      }
      private function newTitleBar():Sprite {
       var barGraphics:Shape = new Shape();
       barGraphics.name = “bar”;
       var colors:Array = new Array(0xE0E0F0, 0xB0C0D0, 0xE0E0F0);
       var alphas:Array = new Array(1, 1, 1);
       var ratios:Array = new Array(0, 50, 255);
       var gradientMatrix:Matrix = new Matrix();
       gradientMatrix.createGradientBox(18, 18, Math.PI/2, 0, 0);
       barGraphics.graphics.lineStyle(0);
       barGraphics.graphics.beginGradientFill(GradientType.LINEAR, colors, alphas, ratios, gradientMatrix);
       barGraphics.graphics.drawRect(0, 0, 18, 18);
    
       var barLabel:TextField = new TextField();
       barLabel.autoSize = TextFieldAutoSize.LEFT;
       barLabel.selectable = false;
       barLabel.text = “Output”;
       var format:TextFormat = barLabel.getTextFormat();
       format.font = “_sans”;
       barLabel.setTextFormat(format);
    
       titleBar = new Sprite();
       titleBar.addChild(barGraphics);
       titleBar.addChild(barLabel);
       return titleBar;
      }
    
    // Event handlers
      private function added(evt:Event):void {
       stage.addEventListener(Event.RESIZE, fitToStage);
       titleBar.addEventListener(MouseEvent.CLICK, toggleCollapse);
       fitToStage();
       toggleCollapse();
      }
      private function removed(evt:Event):void {
       stage.removeEventListener(Event.RESIZE, fitToStage);
       titleBar.removeEventListener(MouseEvent.CLICK, toggleCollapse);
      }
      private function toggleCollapse(evt:Event = null):void {
       if (!instance) return;
       output_txt.visible = !output_txt.visible;
       fitToStage(evt);
      }
      private function fitToStage(evt:Event = null):void {
       if (!stage) return;
       output_txt.width = stage.stageWidth;
       output_txt.y = stage.stageHeight - output_txt.height;
       titleBar.y = (output_txt.visible) ? output_txt.y - titleBar.height : stage.stageHeight - titleBar.height;
       titleBar.getChildByName(“bar”).width = stage.stageWidth;
      }
     }
    }
    

Other debug and logging tools that may help are listed here from OSflash.

  • Alcon – An external output console for Actionscript debugging
  • LuminicBox.Log – A logging API and output console for ActionScript
  • DebugIt – Displays traced data in a seperate SWF so you can debug outside of Flash, while running your application in its shell/production environment.
  • Print_r Debugger – Brings PHP‘s “print_r” to Flash, invaluable once you start to use it. Free, Complete Source Available
  • Sock4Log – JAVA application which displays traced data from SWF and other (PHP,JS…). Could be a command line or windowed application.
    Thursday, August 2nd, 2007

    Uploading on the internet is pretty arcane. Either you have to individually select each file with the browse file input, install some activex control or use java to select multiple files. It always ends up being a tedious action.

    But Flash is the new champ in file upload for the web, as with video, Flash just makes it simple. The FileReferenceList class and its browse method pop up the multiple file select box where the user can hold CTRL or SHIFT to select multiple files and watch them all drop in rather than having to painstakingly select them one by one and not having to install an unknown activex or java applet.

    Here’s script to upload multiple files (or get the multiple file select box).

    var fileRefList:FileReferenceList = new FileReferenceList();
    fileRefList.addEventListener(Event.SELECT, selectHandler);
    fileRefList.browse();
    
    function selectHandler(event:Event):void
    {
        var request:URLRequest = new URLRequest("http://www.[yourdomain].com/upload/");
        var file:FileReference;
        var files:FileReferenceList = FileReferenceList(event.target);
        var selectedFileArray:Array = files.fileList;
        for (var i:uint = 0; i < selectedFileArray.length; i++)
        {
            file = FileReference(selectedFileArray[i]);
            file.addEventListener(Event.COMPLETE, completeHandler);
            try
            {
                file.upload(request);
            }
            catch (error:Error)
            {
                trace("Unable to upload files.");
            }
        }
    }
    function completeHandler(event:Event):void
    {
        trace("uploaded";);
    }

    [source]

    SWFUpload is based on this and is a nice AJAX based script that uses ExternalInterface in AS3 to pass the javascript presentation to the flash uploader.

    The multiple file select, checking the file size before uploading and the ExternalInterface access for Actionscript to talk to Javascript makes Flash the best option for online file uploads for the web yet.