• 1-ralphvaessen
  • 2-lassepedersen
  • 3-genig

Three flash websites that could be done with Javascript

Today, less and less people are creating flash websites. Unless there is some very special 3D content, augmented reality or the mobile market is one-digit percentage, people build their websites using HTML5, CSS3 and Javascript. But every now and then, I stumble upon some great website built with flash. Flash was used to create all varieties of effects ( from simple transition to complex shaders ) and now most of them can be reproduced with JavaScript. Today I will show you three flash websites with very nice effects, that could’ve been bult with modern day technologies.

Continue Reading

rangeToPercent() and percentToRange()

These are two very helpful JavaScript functions if you need to work with ranges and percents.


function rangeToPercent(number, min, max){
   return ((number - min) / (max - min));

This function returns percentage of a number in a given range. For example rangeToPercent(40,20,60) will return 0.5 (50%). rangeToPercent(34,0,100) will return 0.34 (34%)


function percentToRange(percent, min, max) {
   return((max - min) * percent + min);

This function returns number that corresponds to the percentage in a given range. For example percentToRange(0.34,0,100) will return 34.



Original functions are part of  MathUtils Class by Bruno Imbrizi written in ActionScript3.

Restrict a number to a range

This is JS syntax of the AS3 bound() function I use for my flash projects.

function bound(_number, _min, _max){
	return Math.max(Math.min(_number, _max), _min);

The function takes 3 parametes:

_number is the number you want to restrict.

_min is the minimal value.

_max is the maximum value.

If the _number is less than _min, the function returns the _min value. If the _number is greater than _max, the function returns _max value. This is a way to ensure you number will be within this minimum and maximum bounds.


console.log(boundrary(10,5,15));   // returns 10
console.log(boundrary(2,5,15));    // returns 5
console.log(boundrary(100,5,15));  // returns 15
Update: 14 aug 2013

The snippet is can be found at javascriptcookbook website:   http://www.javascriptcookbook.com/article/Restrict-a-number-to-a-range

Get mousewheel event delta

If you need to get the scroll of the mouse wheel ( mouse event delta ) you can use this script:

$(window).on("mousewheel DOMMouseScroll", function(event){

	var delta = event.originalEvent.wheelDelta/120 || -event.originalEvent.detail/3;



You can also check the jQuery Mousewheel Plugin by Brandon Aaron