AS3, AS2, Silverlight, Actionscript in Google Trends for Vector Wars

Here is an interesting look to start the new year at Google Trends for some common keywords to this blog audience. Comparing AS2, AS3, Silverlight and actionscript you can see that there is some pretty interesting things happening.

as3 as2 actionscript silverlight  

First off, AS2 and AS3 are clouded because they are also related to EDI and EDI-INT so they get a bit inflated. Silverlight though is pretty unique in the naming. So from this graph we can see this happening:

  • Silverlight and AS3 are growing rapidly
  • Silverlight is crossing over as3 or meeting it
  • The market looking for Silverlight is about 8-10 times as large as actionscript/as3/as3
  • Silverlight and AS3 are growing, AS2 has no growth left and is an EOL language (end of life)
  • AS2 (even with crossover to EDI trends for “as2”) leveled out, where AS3 is starting to lift to a larger market. This is strongly due to it being a fun language based on ES4 and interests programmers.
  • The as3 effect started right in March-April 2007 (hrm I started this blog in April 2007 coincidenc? j/k :))

Another chart including Flex shows a better picture of the keyword wars between flex and silverlight.

as3 as2 actionscript silverlight flex

So from this graph we can see this happening:

  • Flex has a large buzz
  • Adobe’s marketing efforts are many while silverlight is more unique and focused
  • Flex, as3 and Silverlight are popular, and growing in their support (the growth market for technology is in these areas, not in tech from Flash 8/as2)
  • AS2 still taking a nosedive

Flash and Flex programmers and designers should know that with Silverlight 2.0 release coming and the capabilities of Silverlight 2.0 more competitive, flashers should be working on Flex, Flash9 or at least AS3 if not Flex. The RIA competition market will heat up immensely this year with Silverlight 2.0 and possibly Flex3 and coding and programming for Flash and Flex is becoming more involved. It also has a very strong competitor in Silverlight 2.0 coming that will drive this market.

This is all great news if you are ready for it, if you are still coding actionscript2 (AS2) and paying no mind to Silverlight, Flex or at least actionscript3 (AS3) then you will see your market slowly start to fade as things are ramped up and more of a programming focus in the vector wars. If you are a flash coder and ignoring Silverlight, your solutions will suffer. If you are a silverlight coder or .NET coder and ignoring the Flex and AS3 rise your solutions will suffer. I have been playing in AS3, Flex and Silverlight for over a year on both now and they are an entirely new platform with great programming models. The competition puts focus on this market so it is a great time to be skilled in these areas.

Advertisements

HOWTO: SharedObjects for Local Storage AS3

Using SharedObjects in Flash is very simple. Flash has SharedObjects that have been in the player since Flash6 when the introduction of Flash Communication Server which is now Flash Media Server which is releasing version 3 soon (also remote SharedObjects in Red5 is an open source RTMP media server that is based on Flash Media Server). So we can thank this release for SharedObjects, Camera objects, Audio, lots of the NetConnections, protocol enhancements and many other things. However to keep the tips simple we will just touch on the local usage and post a series of posts on these objects.

SharedObjects locally and remote have changed the way offline is thought about and are the backbone of many offline systems and prototypes. They have been influential in moving storage locally to remote in a lightweight AMF0 or AMF3 format.

SharedObject is in the flash.net namespace in AS3.

Here we show how to use the local version of a SharedObject to store data in the most simple form.

import flash.net.SharedObject;
var so:SharedObject = SharedObject.getLocal("userData");
so.data.username= "user1377";
so.data.pwdhash= "[hash] or pwd";
so.flush(); // writes changes to disk

You can see this is extremely simple to store data.Here we show how to use the local version of a SharedObject to retrieve data in the most simple form.

import flash.net.SharedObject;
var so:SharedObject = SharedObject.getLocal("userData");
var username:String = so.data.username;
var pwdhash:String = so.data.pwdhash;

That is it! In the most basic form SharedObjects are more simple than cookies and also are quite nice living outside the bounds of the cookies folder. If a user deletes all cookies it will not delete the SharedObjects. To delete SharedObjects you need to roght click on the Flash player, go to Settings and delete the objects there.You can store any type of data Flash supports from objects to numbers to strings in the SharedObject data.

import flash.net.SharedObject;
var so:SharedObject = SharedObject.getLocal("userData");
so.data.username= "user1377";
so.data.uid= new Number(1337);
var obj:Object = new Object();
obj.prop = "value";
so.data.userobj= obj;
so.flush(); // writes changes to disk

For large applications SharedObjects local are great because users can have their SharedObject space set to a high amount of space or unlmited for large offline type apps or more complex apps stored in a state object. It gets interesting when you pass this to the server in AMF or extremely compact AMF3 format to a remote stored object, via remoting, Shared Object events or any way you want to.We will be posting more on remote shared objects and some of the other tools such as Camera and Streams for AS3 over the coming weeks and deeper into the Sync Events for remote and local SOs.Sephiroth has a great Python tool to peer into the SOs on disk.

The first version of SharedObject Reader was written in python 2.2.
This new version is written in C# (C Sharp) as it’s now part of FlashDevelop editor.

Red5 also does this as well as many AMF kits.

Sync Events for SharedObject (as they change they launch a sync event)

Event object type: flash.events.SyncEvent
SyncEvent.type property = flash.events.SyncEvent.SYNC

Read more at adobe docs:

flash.net.SharedObject

Sample from AS3 docs showing usage

package {
    import flash.display.Sprite;
    import flash.events.MouseEvent;
    import flash.events.NetStatusEvent;
    import flash.net.SharedObject;
    import flash.net.SharedObjectFlushStatus;
    import flash.text.TextField;
    import flash.text.TextFieldAutoSize;
    import flash.text.TextFieldType;

    public class SharedObjectExample extends Sprite {

        private var mySo:SharedObject;

        public function SharedObjectExample() {
            buildUI();
            saveBtn.addEventListener(MouseEvent.CLICK, saveValue);
            clearBtn.addEventListener(MouseEvent.CLICK, clearValue);

            mySo = SharedObject.getLocal("application-name");
            output.appendText("SharedObject loaded...\n");
            output.appendText("loaded value: " + mySo.data.savedValue + "\n\n");
        }

         private function saveValue(event:MouseEvent):void {
            output.appendText("saving value...\n");
            mySo.data.savedValue = input.text;

            var flushStatus:String = null;
            try {
                flushStatus = mySo.flush(10000);
            } catch (error:Error) {
                output.appendText("Error...Could not write SharedObject to disk\n");
            }
            if (flushStatus != null) {
                switch (flushStatus) {
                    case SharedObjectFlushStatus.PENDING:
                        output.appendText("Requesting permission to save object...\n");
                        mySo.addEventListener(NetStatusEvent.NET_STATUS, onFlushStatus);
                        break;
                    case SharedObjectFlushStatus.FLUSHED:
                        output.appendText("Value flushed to disk.\n");
                        break;
                }
            }
            output.appendText("\n");
        }

        private function clearValue(event:MouseEvent):void {
            output.appendText("Cleared saved value...Reload SWF and the value should be \"undefined\".\n\n");
            delete mySo.data.savedValue;
        }

        private function onFlushStatus(event:NetStatusEvent):void {
            output.appendText("User closed permission dialog...\n");
            switch (event.info.code) {
                case "SharedObject.Flush.Success":
                    output.appendText("User granted permission -- value saved.\n");
                    break;
                case "SharedObject.Flush.Failed":
                    output.appendText("User denied permission -- value not saved.\n");
                    break;
            }
            output.appendText("\n");

            mySo.removeEventListener(NetStatusEvent.NET_STATUS, onFlushStatus);
        }

        // UI elements
        private var inputLbl:TextField;
        private var input:TextField;
        private var output:TextField;
        private var saveBtn:Sprite;
        private var clearBtn:Sprite;

        private function buildUI():void {
            // input label
            inputLbl = new TextField();
            addChild(inputLbl);
            inputLbl.x = 10;
            inputLbl.y = 10;
            inputLbl.text = "Value to save:";

            // input TextField
            input = new TextField();
            addChild(input);
            input.x = 80;
            input.y = 10;
            input.width = 100;
            input.height = 20;
            input.border = true;
            input.background = true;
            input.type = TextFieldType.INPUT;

            // output TextField
            output = new TextField();
            addChild(output);
            output.x = 10;
            output.y = 35;
            output.width = 250;
            output.height = 250;
            output.multiline = true;
            output.wordWrap = true;
            output.border = true;
            output.background = true;

            // Save button
            saveBtn = new Sprite();
            addChild(saveBtn);
            saveBtn.x = 190;
            saveBtn.y = 10;
            saveBtn.useHandCursor = true;
            saveBtn.graphics.lineStyle(1);
            saveBtn.graphics.beginFill(0xcccccc);
            saveBtn.graphics.drawRoundRect(0, 0, 30, 20, 5, 5);
            var saveLbl:TextField = new TextField();
            saveBtn.addChild(saveLbl);
            saveLbl.text = "Save";
            saveLbl.selectable = false;

            // Clear button
            clearBtn = new Sprite();
            addChild(clearBtn);
            clearBtn.x = 230;
            clearBtn.y = 10;
            clearBtn.useHandCursor = true;
            clearBtn.graphics.lineStyle(1);
            clearBtn.graphics.beginFill(0xcccccc);
            clearBtn.graphics.drawRoundRect(0, 0, 30, 20, 5, 5);
            var clearLbl:TextField = new TextField();
            clearBtn.addChild(clearLbl);
            clearLbl.text = "Clear";
            clearLbl.selectable = false;
        }
    }
}

MosesProposes: Standardizing Animation and Motion Kits for Flash, Flex, After Effects, Javascript and I add Director and haXe

The Proposal

Moses, the maker of FuseKit, is hoping to influence Adobe product lines to include a common base for animation and motion going forward. Currently the AS3 world is very alive and is inspiring developers like myself to build lots of toolkits and really creating reusable code and kits that can make things very easy from going to Flash to Flex. But wouldn’t it be nice if a part of these kits that have to be downloaded every time you have an application use them be part of the native Adobe applications, or a core animation kit that partially standardizes animation basics to build upon further?

Are we just asking for trouble or is this a good idea? I don’t’ think it can hurt to bring this to the surface. I know that common syntax and familiar kits can really help the developers and designers move from Flash to Flex to After Effects to Javascript, it could also help Adobe with usage and usefulness of their entire suite of products. Or further this could be a standard that allows Silverlight to also build upon (open standard) and may the best platform win.

I think it would be very wise for Adobe to:

  • Standardize animation toolkits across their products and
  • Start standardizing some of the basic tools of building motion and filter kits to native but still allowing a flourishing open source and community research and development aspect.

What MosesProposes:

Moses did speak with someone at Adobe about this and it is generally in the plans:

“It was also a pleasure to see Richard Galvan present the upcoming crop of Flash features: the sleek update to the animation timeline (better late than never?), support for columnated flowing text (double finally!) and the big one, native 3D player support for Display Objects as rotatable 2D planes. He ran out of time and didn’t get to a few others shown at Adobe MAX, such as built-in IK (inverse kinematics) and faster pixel-level drawing for texture-mapping and photoshop-like filter effects.

Talking to him after the presentation I learned that Richard has a keen awareness of exactly where each feature is at currently. We chatted about low-level animation mechanics of the Flash Player, and I found out that the holy grail of a time-based player is indeed on the distant horizon, but that each rev will need to be a small step toward this goal. The new Flash timeline features meld After Effects, Premiere and Live Motion, and from what I’ve seen I have to say that they are nailing this long-overdue upgrade with great design decisions and a level of usability we’ve never seen in Flash. Kudos, team!”

The Current Situation

Right now Tweener and TweenLite (and animation package and a few others) have a unique position in that they work the same almost for AS2 and AS3 (Flex or Flash – with minor property changes such as _x to x as that has changed in AS3). But it would be nice if these kits also had a version for After Effects (really bringing that tool into Flash/flex developer worlds) and Javascript and it would be great if Silverlight also were supported (AgTweener anyone?).

Tweener is leading the pack in this aspect of creating a similar experience from AS2 to AS3 in Flash and AS3 in Flex and even JSTweener for Javascript, and a kit for haXe which is becoming my favorite toy and the dark horse with the most upside potential, with haXe on the loose these points may all be moot as haXe can target any platform (except After Effects easily, correct me if I am wrong and Silverlight but it could easily be done so to do it for Silverlight 1.0 which is ES3 based).

I don’t use After Effects as much right now but if I could easily incorporate this into Flash/Flex and script and animate in a similar syntax and way I know After Effects would definitely have a boost in interest.

Also, the forgotten one Director, can we please get an ES4 based language in that application, or an update? Then kits and add-ons are much more possible. I really miss hardware accelerated 3d in browser as a pushed technology, Director is still around but it does not get the focus it needs. Feel the freedom and coolness just in this small test here in director, hardware accelerated 3d is the best, the Director application environment and Lingo and hacked in javascript are not the best. As a long-time Director user, hobbyist and professional I am disappointed in Director’s support at Adobe thus far, but I digress.

The Reality

The reality is right now the only problem with kits like Tweener, TweenLite, Tween, mx.transitions, mx.motion, etc is that the source has to be embedded in movieclips multiple times. Sometimes there are multiple animation kits per compiled SWF that have to be used for more advanced features. This adds bulk that if common might not need to be there (this comes into play still on mobile and large games/apps).

Let’s say you have an application that pulls in many disconnected SWFs and they all have animation in them, well if you have 20 of these let’s say, and you embedded a very small Tweener at 9k per SWF. That is about 200k of duplication of AS code. Due to the kits small sizes this is not a problem really but when animation kits like Animation Package come into play, you are talking 40k per SWF which would leave you with almost a meg of just duplicated animation code. I don’t think this is that major of a problem for kits like Tweener (9k compiled) and Tweenlite (3k compiled) but as projects get bigger and more depth of animation platforms needed this can be a problem. This can also be solved in architecture with a controller and dummy SWFs to animate but there are times when you need animation in the compiled SWFs and then also need it in many others and the controller.

The other reality is the animation kits (mx.transitions.easing, mx.transitions.tween) for Flex and Tween for fl are a little bloated, more difficult than needed to use and as has been seen, much slower than kits currently available in the community. My one fear about this is that if Adobe makes this, possibly like Microsoft’s toolkits and libraries they put out, they are always bloated and slower, then because they are embedded they are untouchable. If it was standard enough as building blocks that are faster because they are native, then this is the best option as embedded script would be hard pressed to beat native code in the players/applications.

The Future Plans

Some of this is underway….

Animation kits for future, Adobe is releasing Flash 10 called ‘Astro’ that has many new improvements in tweening with xml closer to flex or even Silverlight like transitions and storyboards. Aral Balkan, a sponsor of OSFlash, posted on this and even that Diesel Flash CS4 will include more Tween tools for IK/bones. Tweener , TweenLite, Animation Package, Animation System etc these are all helping to define the best way to do animation kits.

Physics toolkits have their own animation kits currently usually to handle the movement according to algorithms. FOAM, APE , Box2DFlashAS3 (just released very recently will be posting more on this after I check it) and Motor Physics (unreleased but heavily demoed at polygonal labs) are great physics toolkits and I like this being part of the community to get refined, maybe one of them or the best performing ones becomes part of the proposed Adobe Animation bundle. These will define the best way to do physics kits.

3d in flash toolkits have also been emerging rapidly in 2007 with Papervision3D, Away3d based on pv3d, Sandy, and even engines starting to get built on top of these platforms.

The general direction is moving towards another platform in there somewhere but I think much work is left to be done to standardized physics systems, 3d and advanced motion filter tweens and bezier, splines (Catmull-Rom), editors, etc. I think it is getting time for basic animation kits to become more standard though and in latest versions of flash this is included in the flex and flash scripts but not the native code.

Right now the standard in syntax and the broadest reach is Tweener and due to the bigger fish syndrome, haXe that can target any platform, it also has a Tweener and can create code for as2, as3 and any target written in if After Effects, Premiere or other apps get more robust and standard animation and motion kits. Tweener has kits made and contributed for AS2, AS3, haXe, Javascript and others.

There is also Hydra and the AIF Toolkit that are standardizing After Effects and Flash shaders and filters into a new shader language like Cg and reminiscent of processing.org.

As humans we trial and error and build new platforms in the market to step on to create better platforms to build cool stuff, it is evolving right now. AS3 is inspiring platforms within platforms of Flash and Adobe kits as well as on Silverlight and in the Javascript world with JSTweener, jquery etc. As these things are refined we build a level standard platform to build more stuff on. Eventually this will be there and whoever does the standard platform for animation will probably reap in users and abilitty to easily add new products and solutions where people already have training. Silverlight is an example with .NET developers. .NET was also an example with C# so similar to Java. ES4 based AS3 has proven it is inspiring all types of new platforms and kits and will continue to do so and it is an interesting time in this industry whichever direction it goes.

Motion Detection In Flash (AS2 and AS3) and C#

Currently working on some motion detection with flash/c# and webcams right now. Here’s a basic overview of some motion detection source files and tricks. Most motion detection is based on snapshots and finding brightness of a pixel with all combined colors, then comparing that to previous snapshots to detect enough variance and thus movement. If you have a webcam hooked up, this sample in Flash AS3 highlights this well showing the camera on the left, then the brightness snapshots on the right. It also has an indicator to the amount of movement due to much brightness.

C#

Here is a nice example of motion detection using various motion detection algorithms in C#. This is built on the very slick AForge.NET Computer Imaging Library.

If you ever wanted your own motion detection or recording it is all possible with the basics of checking brightness and snapshots in the most simple form checking how much change or variance their was to bright pixels or the count of bright pixels compared to previous snapshots.

// Calculate white pixels

private int CalculateWhitePixels( Bitmap image )
{
    int count = 0;
    // lock difference image
    BitmapData data = image.LockBits( new Rectangle( 0, 0, width, height ),
        ImageLockMode.ReadOnly, PixelFormat.Format8bppIndexed );
    int offset = data.Stride - width;
    unsafe
    {
        byte * ptr = (byte *) data.Scan0.ToPointer( );
        for ( int y = 0; y < height; y++ )
        {
            for ( int x = 0; x < width; x++, ptr++ )
            {
                count += ( (*ptr) >> 7 );
            }
            ptr += offset;
        }
    }

    // unlock image
    image.UnlockBits( data );
    return count;
}

Flash AS2

In Flash this is also possible here is a good article from Flash8 that explains cycling through each pixel to compare the image data and implement motion detection from a webcam.

For instance the basics here show how you can compare each pixel and the change in the brightness for each pixel:

//accuracy
tolerance=10;

//color of the current pixel in the current snapshot
nc=now.getPixel(x,y);

//red channel
nr=nc>>16&0xff;

//green channel
ng=nc>>8&0xff;

//blue channel
nb=nc&0xff;

//brightness
nl=Math.sqrt(nr*nr + ng*ng + nb*nb)

//color of the same pixel in the previous snapshot
bc=before.getPixel(x,y);

//red channel
br=bc>>16&0xff;

//green channel
bg=bc>>8&0xff;

//blue channel
bb=bc&0xff;

//brightness
bl=Math.sqrt(br*br + bg*bg + bb*bb);

//difference in brightness between now and before
d=Math.round(Math.abs(bl-nl));

if(d>tolerance)
{
//there was a change in this pixel
}

Flash AS3

Here is a link to grab a conversion of the AS2 Flash motion detection above to AS3.

Source of AS3 motion detection here.

Grant Skinner has done some interesting things with motion detection with Flash and webcams in the past in the incomplet gallery.

C# or other hardware accelerated capable kits are faster but AS3 and Flash with the new AVM2 virtual machine  should be about 10 times faster than AS2 as much of the improvement in performance and the virtual machine is on iteration speed increases such as loops (i.e. pixel loop).

HOWTO: Silverlight Preloader with Downloader

UPDATE: See a sample of this Preloader that allows many files to be downloaded.

There are some great videos and links on the downloader object from Microsoft for Silverlight.

In Silverlight you can create an object called a downloader that probably stems from the htc ie5.5 downloader that was part of ajax beginnings, it is ver similar to the XMLHTTP object but it has zip capabilities. This downloader can download individual files or zip file packages that you can grab xaml, xml, images, script etc from them and use them or load them in to xaml files. This helps to keep things compact and allows for preloaders and smoother beginnings of your animations where needed.

The zip downloading is attractive and much of this is going on in Flash AS3 with FZip or ASZip AS3 packages. These are made possible with ByteArray and BinarySockets and other fun tools that give no limits. In Silverlight all you have is javascript or the silverlight downloader object to get other data at runtime.

Downloading assets in Silverlight is different than in Flash. Flash compiles libraries to swf files, it can load pngs, it can preload anything in numerous ways. Silverlight does not compile to one file or into compressed binary currently and this offers flexibility but it also makes file sizes at their default size very big. PNGs for instance can’t be zipped any smaller usually but in Flash9 these are sometimes 1/10th the size of the actual file when compressed better in the SWF file. Even if you zip them in Silverlight they are still around the same size. Silverlight XAML files compress well and these can get very large if lots of pathing is used.

Flash has always been the master at smallest file sizes and even the player itself is extremely small, under a MB. Silverlight 1.0 which is just javascript is 1MB, the Silverlight 1.1 plugin with DLR support is going to be 4MB currently (it still is in alpha so it could come down).

Currently in Silverlight 1.0 this is just a javascript release, the DLR and C# version of Silverlight 1.1 Alpha probably has 6 months or a year. So with no byte array binary handling or sockets of any type except javascript ajax, downloader is your only option now. But it is a good tool for now to help with preloaders and bringing files in smaller to make your rich applications and games faster.
Currently the only createObject call that is supported is the “downloader” object. I would like to see more here like a “socket” object but when Silverlight 1.1 launches with C#/python/ruby support things may change in this regard.

To create a downloader you do this in javascript:

// Event handler for initializing and executing a download request.
function onMouseLeftButtonUp(sender, eventArgs)  //sample mouse button click
{
// Retrieve a reference to the plugin.var slPlugin = sender.getHost();    // Create a Downloader object.
var downloader = slPlugin.createObject("downloader");

// Add DownloadProgressChanged and Completed events.
downloader.addEventListener("downloadProgressChanged", onDownloadProgressChanged);

downloader.addEventListener("completed", onCompleted);

// Initialize the Downloader request.
// NOTE: downloader APIs disallow file: scheme
// you must run this sample over localhost: or off a server or the following call will fail
downloader.open("GET", "promo.zip");

// Execute the Downloader request.
downloader.send();
}

// Event handler for updating visual progress indicator
function onDownloadProgressChanged(sender, eventArgs)
{
// Calculate the downloaded percentage.
var percentage = Math.floor(sender.downloadProgress * 100);
// Update the Rectangle and TextBlock objects of the visual progress indicator.
progressText.text = percentage + "%";
progressRectangle.width = percentage * 2;
}

function onDownloadCompleted(sender, eventArgs)
{
// Retrieve the XAML content from the downloaded package file.
var jacketBrowserXaml = sender.getResponseText("jacketBrowser.xaml");

// Create the objects from the XAML content.
var jacketBrowser = plugin.content.createFromXaml(jacketBrowserXaml);

// Add downloaded XAML content to the plugin.
sender.findName("rootCanvas").children.insert(0, jacketBrowser);

// Retrieve a reference to the Image object representing the jacket.
var jacketImageSlice = sender.findName("jacketSlice");

// Set the Source property of the Image object to the specific jacket image
// within the downloaded Zip package file.

jacketImageSlice.setSource(sender, "rotation01_green.png");
}

This video is the quickest way to understand the whole downloader setup.But this is also a very simple example. The hard part is deciding where to put your preloaders and how to load things in. If you are putting your XAML in a zip file you will need to have a preloader in a container XAML file as the main control and then a Canvas object to load that XAML into. This complicates many things and is really a design approach from the beginning.

In coming posts I will be posting a multifile preloader, a single file preloader, a zip preloader and some sample setups for silverlight projects and Flash projects based on zip and direct preloading.

I will put this sample script to work below for preloading files in Silverlight 1.0:

///////////////////////////////////////////////////////////////////////////////
//
// PreloaderMultifileClassLibrary.js
// The MIT License
// 
// Copyright (c) 2007 Ryan Christensen, drawk llc
// 
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
// 
// The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Software.
// 
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
// THE SOFTWARE.
//
///////////////////////////////////////////////////////////////////////////////

// setup the namespace objects to be good javascript form
// Ag1 = Silverlight 1.0 library
if(!window.B)
window.B={};
if(!window.B.Ag1)
window.B.Ag1={};

if (!window.Sys)
window.Sys = {};

if (!window.Silverlight)
window.Silverlight = {};

Silverlight.createDelegate = function(instance, method) {
return function() {
return method.apply(instance, arguments);
}
}

B.Ag1.PreloaderMultifileAssets = function()
{
// TODO alow JSON or Array passed
// loads up the asset arry to cycle through
this.resourceArray = new Array();
}

B.Ag1.PreloaderMultifileAssets.prototype =
{
loadAssetsArray : function()
{
this.resourceArray[0] = "spinner.png";
// add your images/zips/files to load here
for (var i=1; i&lt;=16; i++)
{
this.resourceArray[i] = "drive_in_files/image" + i + ".png";
}
this.resourceArray[i++] = "drive_in_files/bg.png";
this.resourceArray[i++] = "drive_in_files/c1.png";
this.resourceArray[i++] = "drive_in_files/c2.png";
this.resourceArray[i++] = "drive_in_files/c3.png";
this.resourceArray[i++] = "drive_in_files/c4.png";
}
}

// total pages available
B.Ag1.PreloaderMultifile = function(control)
{
this.plugIn = control;      // Store the host plug-in
this.currentDownload = 0;   // Current resource to be downloaded
// this.maxNumPages = maxNumPages;
this.preloaderMultifileAssets = new B.Ag1.PreloaderMultifileAssets();
this.preloaderMultifileAssets.loadAssetsArray();
// alert(this.preloaderMultifileAssets.resourceArray);
this.downloadAssets();
}

B.Ag1.PreloaderMultifile.prototype =
{
downloadAssets : function()
{
//alert(this.preloaderMultifileAssets.resourceArray);
var _file = this.preloaderMultifileAssets.resourceArray[this.currentDownload];
if(_file != null &amp;&amp; _file != undefined)
{
this.downloader = this.plugIn.createObject("downloader");
this.downloader.addEventListener("downloadProgressChanged", Silverlight.createDelegate(this, this.downloadProgressChanged));
this.downloader.addEventListener("completed", Silverlight.createDelegate(this, this.downloadCompleted));
this.downloader.open("GET", this.preloaderMultifileAssets.resourceArray[this.currentDownload]);
this.downloader.send();
}
},
downloadProgressChanged : function(sender, args)
{
try
{
var progressRect = this.plugIn.content.findName("progressRect");
progressRect.width = (sender.downloadProgress) * 450;
}
catch(e)
{
}
},
downloadCompleted : function(sender, args)
{
this.currentDownload++;
var progressText = this.plugIn.content.findName("progressText");
var progressPercent= this.plugIn.content.findName("progressPercent");
if (this.currentDownload &lt; this.preloaderMultifileAssets.resourceArray.length)
{

progressText.text = "Downloading: " + this.preloaderMultifileAssets.resourceArray[this.currentDownload];
progressPercent.text = parseInt((this.currentDownload/this.preloaderMultifileAssets.resourceArray.length)*100) + "%";
this.downloader.open("GET", this.preloaderMultifileAssets.resourceArray[this.currentDownload]);
this.downloader.send();
}
else
{
// Hide progress UI
var downloadUI = this.plugIn.content.findName("downloadUI");
this.plugIn.content.findName("fadeDownloadUI").begin();
downloadUI.isHitTestVisible = false;

progressPercent.text = "100%";
progressText.text = "Downloading Complete";

// initialize canvas and anmiations
this.plugIn.content.findName("innerCanvas").Visibility = 'Visible';
this.plugIn.content.findName("IntroAnimation").begin();
}
}
}

If you change your Silverlight handleLoad to something like this you can use the class above for list of files before it plays the xaml animations and presentation.

handleLoad: function(plugin, userContext,  sender) { // be sure to add these parameters, by default they are not added
// alert(plugin.id + " : " + userContext + " : " + sender.toString());
plugin.content.findName("innerCanvas").Visibility ='Collapsed';
plugin.content.findName("innerCanvas").Opacity = 0;
var preloader = new B.Ag1.PreloaderMultifile(sender.getHost()); // pass in the silverlight control

I will have a complete tutorial of this soon.

Flash9 AS3 Lisp Interpreter

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

Dojo Adds Silverlight Effects Support

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 ]