AS3 Scrollbar v3

Posted in Actionscript, Flash on August 9th, 2010 by Sandro Haag – 1 Comment

Hey!

The new version of AS3 Scrollbar is much better. I solve some bugs, and implement some features.

- Horizontal Scrollbar - Now you can create vertical and/or horizontal scrollbars. An extra parameter called direction was created into initialize method.
- Blur - You can add blur effect when it is scrolling. It uses some CPU processor, and I need to make it better, but for now it is good :P
- Change Size Method - The public method changeSize(value) changes the size of the scrollbar, and positionate the arrow automatically.

Click here to check the demo.
Click here to download the source files.

Let me know if you find any issue.

Thanks

URL Utilities Class

Posted in Actionscript, Flash on August 2nd, 2010 by Sandro Haag – Be the first to comment

Hey!

I have been using this class for a long time. It is pretty simple, but useful.
It has 3 methods:

getURL - Just like in AS2, that I think is much better than using navigateToURL and URLRequest functions.
javascript - Executes a javascript function.
alert - Executes the javascript alert function.

To download this class, click here

Thanks!

Trigger class

Posted in Actionscript, Flash on February 18th, 2010 by Sandro Haag – Be the first to comment

Hey! Yes, I am alive!

Well, today I am going to show you a class that I use a lot. It is a simple one and its utility is also pretty simple, but it is very useful. The Trigger class!
The name is kind of suggestive, a class that executes a function with some delay. You can set how many times you want to repeat the function and pass many arguments you want in a simple way. It also has the possibility to cancel the execution of a function that was set to trigger.

The class has 2 public static methods:
call (delay:Number, fn:Function, repeat:int = 1, ...args)
cancel (fn:Function)

Below I show you how to use the call method:
Trigger.call(2, trace, 1, "param1", "param2", "param3");
Trigger.call(3, test);

Now, how to cancel the execution of a function:
Trigger.cancel(trace);

You can download the class here
If you have any problem, please report it to me.

Oh, and thanks to Eduardo that helped me with this one.

See ya!

Mouse Wheel Event on Mac

Posted in Actionscript, Flash on September 21st, 2009 by Sandro Haag – Be the first to comment

Really! It doesn’t work!

There are some solutions for this problem, using javascript and Actionscript 3. But one of those I really enjoyed, because it is very simple.

You can check the solution here.

I tested in Safari and FF on Mac, and it worked well.

AS3 Scrollbar v2

Posted in Actionscript, Flash on September 10th, 2009 by Sandro Haag – 2 Comments

Hey!

I did some adjustments on the AS3 Scrollbar, and added a new method.

The getter/setter method gap is used to control the space after the content. The default value is 0. If you set it to 100, for example, the content will scroll more than usual, and will be a gap between the end of the content and the mask. This can solve some spacement problems that sometimes happen.

Click here to see a simple demo.
Click here to download the new sample files.

TODO list
- Add the possibility of the scrollbar be horizontal
- Add blur functionality
- Better up the usage
- Make it more flexible
- Make the tween works independent, so you can adapt to any tween engine

Please, report me the bugs and suggestions.

See ya!

AS3 Scrollbar

Posted in Actionscript, Flash on July 27th, 2009 by Sandro Haag – Be the first to comment

Hey!

Scrollbar was always something that I needed, but also something that I never spent time to create. But, things change and here is the first version of the AS3 Scrollbar.

Click here to see a simple demo.
Click here to download the sample files.

It is very simple to use, and has some nice features. You can stop and restart all its events by simple using the cancel and run method.

It is documented in the class, but if you have some problems or find some bugs, please reply on this post or email me.

Thanks!

Removing a FLVPlayBack Instance

Posted in General on June 29th, 2009 by Sandro Haag – 4 Comments

Hey!

Well, remove a FLVPlayBack instance is more complicated than you can possible imagine!
If you try to remove one, just using this:
removeChild(player);
You will notice that actually the player is there, you can hear it (if it has sound, of course :P)

So, just do this:
player.getVideoPlayer(player.activeVideoPlayerIndex).close();
player.activeVideoPlayerIndex = player.activeVideoPlayerIndex + 1;
player.visibleVideoPlayerIndex = player.activeVideoPlayerIndex;

Yeap, Adobe sometimes doesn’t help us! :P

Randomizing an Array

Posted in Actionscript, Flash on May 25th, 2009 by Sandro Haag – 4 Comments

Hi!

Here is a simple example of how to sort the items of an Array and get a randomized Array:

function sortArray (original:Array) : Array
{
   var temp:Array = original;
   var sort:Array = [];

   while (temp.length > 0)
   {
      var r:int = Math.random() * temp.length;
      sort.push(temp[r]);
      temp.splice(r, 1);
   }

   return sort;
}

Now, just execute the method, passing as parameter the Array that you want to randomize.

var original:Array = [0, 1, 2, 3, 4];
var randomized:Array = sortArray(original);
trace(”result: ” + randomized); // result: 3, 1, 4, 0, 2

That’s it!

Zinc 3.0

Posted in Actionscript, Flash, Zinc on May 18th, 2009 by Sandro Haag – 2 Comments

Hey!

Yes, a long time has passed since the last post. So here I am.

I am using Zinc 3.0 for a project, and here is my report of it.
In a few words, I can say that it is good, but not better than Adobe AIR.
It is a little complicated in the beggining, cause doesn`t have documentation. The only doc available is here, and it doesn’t  help so much.

To give an example, If I don’t do this:
mdm.Application.init(MovieClip(this), onInit);
The functions that I will execute will not work, but it will not throw me any error.
I have spent a considerable time to discover that I need to initiliaze the mdm classes.

When you have all configured, and familiared with the Zinc, it is kind’a easy to use. A lot of things you do in the Zinc Builder, on graphic mode. I guess the main problem of Zinc is the documentation, cause I think you can do everything with it, you just have to know how. Another problem is that there are not a lot of users, so this turns the thing a little bit complicated when you need some help.

Well, if someone has some question about it, just post here.

Thanks!

Regular Expressions

Posted in Actionscript, Flash, General on January 30th, 2009 by Sandro Haag – 2 Comments

Regular Expressions is one of the great things that Adobe has done in Actionscript 3. It simplifies the way that you do the validation of email, birthdate, cep…

Almost all programming languages have Regular Expressions, the only thing that modify, is the usage.

Here are some examples:

Email

var regExp:RegExp = /^[a-z][w.-]+@w[w.-]+.[w.-]*[a-z][a-z]$/i;
var isValid:Boolean = regExp.test(”hahahaag@gmail.com”);
trace(isValid); // true

Birthdate

This is one of the longest Regular Expression that I’ve used. It validates the birthdate perfect, including leap year.

var regExp:RegExp = /^(((0[1-9]|[12][0-9]|3[01])([/])(0[13578]|10|12)([/])([1-2][0,9][0-9][0-9]))|(([0][1-9]|[12][0-9]|30)([/])(0[469]|11)([/])([1-2][0,9][0-9][0-9]))|((0[1-9]|1[0-9]|2[0-8])([/])(02)([/])([1-2][0,9][0-9][0-9]))|((29)(.|-|-)(02)([/])([02468][048]00))|((29)([/])(02)([/])([13579][26]00))|((29)([/])(02)([/])([0-9][0-9][0][48]))|((29)([/])(02)([/])([0-9][0-9][2468][048]))|((29)([/])(02)([/])([0-9][0-9][13579][26])))$/i;
var isValid:Boolean = regExp.test(”16/06/1986″);
trace(isValid); // true

You can find many others, searching at Google. The usage is the same.

If somebody finds others interesting RegExp, please send it to me.

Good luck!