Archive for October, 2005

Easing scrollbar

I got a request for it and decided to put up my scrollbar for anyone who might be interested.
It's not using the V2 framework and is designed to be lightweight but flexible.

Features:
Only 4k uncompressed.
Can scroll one or several movie clips, text fields or buttons.
Responds to mousewheel, arrow keys and page up/down keys.
Configurable easing.
Fairly easy to alter style by simply editing the component.
Drag area that resizes with the amount of content to scroll.
Can update when changing the size of the content to be scrolled.

So basically just another scrollbar, but if you are looking for something less bloated then the MM V2 components and just want to do some scrolling it might be useful.

Get the download here.

UPDATE:
After doing some testing with several instances on multiple levels I noticed some issues.
I have now updated the download so you can use several instances as well as load them on top of each other and still have the mousescroll and keyboard control working fine.

To update the scrollbar reinstall the component using the extensions manager by double clicking the .mxp file.
Then drag an instance of the component onto the stage in the .fla with an old version. When prompted choose to replace existing items.
You can now delete the newly added instance, and your previous instances will be up to date.

UPDATE 2006-02-12:
An error in ScrollFocus.as made the key and mouse scroll stop working if you removed the first instantiated scrollBar.
The .zip file have been updated with the amended class file.

AS3 example…waveform display

Many thanks to Guy Watson who confirmed that the FFTMode for computeSpectrum doesn't work yet.
I was hoping to be able to post a proper spectral analyser for Flash, but that has to wait until the FFT is sorted.

So for now you can check out the code for the example waveform display I made.
It's pretty much the same as what was posted on www.richapps.de but I used the readFloat method to access the data to make the wave display correctly.

AS3 computeSpectrum and FFT not working?

I was very excited to notice that you now with AS3 can retrieve amplitude and spectrum information. I been hoping for this for a long time, and now it's there :)
Problem is that it doesn't seem to work properly.

I looked at the example on www.richapps.de and tried it out.
The problem is that accessing the values of the byteArray with normal array access brackets will not give the correct values.
It will return the byte value, ie a value between 0 and 256. According to the documentation for AS3 the computeSpectrum should return a decimal value between -1.0 and 1.0.
So since the length of the byte array is 2048 and the number of values should be 2x256 the values is stored as a single-precision 32-bit value.
So that gives that each value should be stored in 4 bytes and that readFloat would be the appropriate method to retrieve the values.
So my code to read the array for the right channel looks like this:

while(i>1024){
   spectrum.position=i;
      sprites_array[Math.round(i/4)].scaleY=(spectrum.readFloat()*100);
   i=i+4;
}

That works fine when FFTMode is false.
It will display the raw wave as you can see in this example.
(requires flash player 8.5, click to start sound).

But what you usually want to do to display a spectrum is to use FTT.
That will analyse the wave and actually make it into spectral information.
So, I try with just setting FFTMode to true....but no luck :(
Here is the swf with FFT applied.
As you can see there is no spectral information. With a sine sweep like this what you should see is a thin spike travelling from right to left.

Am I doing it completely wrong, or is indeed the FFTMode not working as it should?
Someone managed to get it to display a proper spectrum graph yet, and if so how?

RIA wars

Here we go again.
What is the future dominant platform of RIA development?
The latest discussion that triggered me to reflect on the issue again is over at ajaxinfo.com

Actually I find discussions like this quite interesting and don't mind dissecting the pros and cons. I guess I just like a good argument :)
But I'm also aware of that it is impossible to judge what is the most suitable technology to use without knowing what the goals of the project is, and most of all, who's going to develop it.

The article by Alexei White on ajaxinfo does seem to reach a similar conclusion in a way. The major drawback with Flash according to the author is that it's hard to find developers skilled with the technology.
I do find the evaluation questionable though.
Sure there is more developers specializing in HTML and JS than ones specializing in actionscript.
But that doesn't mean that the HTML/JS developers usually can put together a complex RIA using their existing knowledge. To get it all to work together in a way that give reliable results seems to be a skill in it's own right.
That the developers have the "basic skill set necessary for interacting with components" for working with AJAX is not of much value if they don't have the full skill set needed to get the job done.
They could hopefully acquire it, but they could also learn a new language.
I would not think it's actually hard for someone already skilled in JS, Java and PHP to learn actionscript, and for sure Flex or Laszlo with their XML based markup can be worth the effort to learn if you want to be working with RIA development.

Sure finding a technology that matches the skill set available is beneficial, but I would say that there has to be a balance.
So you also have to consider finding developers that is capable of handling the technologies best suited for realising the goals.
What is the most efficient balance has to be carefully evaluated.
With large companies you of course have an inertia due to having invested in certain technologies and they can't sack their whole IT team every time a new and better technology come along, so hence there will be a large dose of conservatism involved.
And that's I think a big reason why AJAX is getting all the hype it has at the moment. To me it does seem like an attempt to squeeze the last drops out of a heavily invested skill set, financially by companies and intellectually by developers.

There is often much talk about all the variables one have to consider in the choice of technology. And sure many of them can be valid in very specific circumstances, but usually there is few variables that really matters and would outweigh any other benefits or disadvantages. And evaluating them properly can be hard enough without adding more to the equation.

From the perspective of the customer it's mainly two variables:

  • How much will it cost to develop?
  • How successful will it be at achieving it's goals?
  • From the developers perspective it's more of a conflict:

  • How efficient are the technologies compared to each other in achieving the objectives of the project?
  • How comfortable do i feel using one technology over the other?
  • How long can I go on what I feel comfortable with and still stay in business?
  • The user should of course not have to reflect on the technology and one has to presume all that matters is the result they are presented with and that they can get to it.

    The arguments often brought in to the discussion about Flash and FLEX being proprietary tends to be very superficial to me.
    Especially considering that the swf format is open.
    Alexei White mentions in his summary that Flash "suffer from the Vendor lock-in problem".
    I actually have problems understanding in what way it might been a problem for any project. Sure i prefer to support an open standard and open-source software based on my sentiments.
    But if we look at the standards based formats like HTML, CSS and SVG there is a lot of real problems that will have very immediate effects on any project involving such technologies.
    The "vendor lock-in problem" certainly pales in comparison to the problem of getting web standards to be standardised.

    Back button, Bookmarking and Deeplinking

    I've done a little update to my system for enabling the back button and providing deep linking/bookmarking functionality for Flash sites and applications.
    It's now using Macromedias JS integration kit for Flash to JS communication.

    Click here to download it.

    Try the system here.

    I was hoping I would solve issues with some browsers that it was not working with previously, but since there is more issues than if the browser supports the setVariable command to pass data from JS to Flash it seems like it will be very difficult to get a few browser/OS combinations to work.

    Basically I found two different methods of approach.

    One is using Rober Penners hidden frame method.
    That's still what the system does for IE, but using an iFrame instead instead of a regular frame set and removing the need to create actual HTML files to load into the frame by using document.write().
    With FF I did not have much luck with that approach.
    Just using JS to write into the hidden frame worked fine and made the back button work, but when trying to also update the hash to enable the bookmarking everything started going wrong.

    The other approach is to at regular intervals check the location.hash and if it's been updated cause a change of state in Flash.

    Both approaches have various problems on different browsers.
    For example Safari apparently will not record a history event when you use document.write() to update an iFrame.
    Opera 8 will not record a history event if you update the hash, and after experimenting a bit with writing into the iFrame I gave up on getting it to work with that method.

    It would be great with a system that works for every perceivable browser and OS, but as long as the system fails gracefully it's at least not doing any harm to implement and as it is now it will cover a vast majority of users.

    So far I tested and confirmed it working with FF 1.0.6 and 1.5 beta 1, IE6, NS8 and Opera 8.5
    Opera 8.01 does not show the hash and back button fails, but at least deep links are working.

    I would be very interested to hear from mac users in particular to find out if NS, Safari and IE still is not working.