Firefox Flash outline woes? No more!

The (now) new Firefox 3.6 and possibly other versions place a 1px border around flash elements embedded with swfojbect. This outline is similar to the active link outline. May occur on other object and embed tags as well.

firefox-outline

If you’reĀ  annoyed by this, there is a simple CSS fix.

a:focus, object:focus { 
	outline: none; 
	-moz-outline-style: none; 
}

I love Google Chrome’s Error messages

Witty, nerdy, funny.

chrome-error

DeMonster Debugger for debugging flash

Came across a great Flash debugging tool. Step through your code at runtime and change/monitor properties. Run and catch method results instantly!

http://demonsterdebugger.com/

It is an AIR app, so the AIR runtime is required - worth it in my opinion.

Simple JQuery to resize embeds

Sometimes Youtube or other embeds may not work in a given site layout.

Here is a bit of jQuery that loops over each object or embed tag and sizes them according to a maximum width, while respecting the aspect ratio.

Since this is a javascript solution, a visitor must have js enabled for the resizing to occur.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
 
/// Resize embeds
var maxEmbedWidth = 450;
 $("object, embed").each(function (i) {
    var ow = $(this).attr('width');
	var oh = $(this).attr('height');
	if(ow > maxEmbedWidth){
		var s = maxEmbedWidth/ow;
		var nw = Math.floor(ow *s);
		var nh = Math.floor(oh * s);
		$(this).attr('width', nw);
		$(this).attr('height',nh);
		}
});

Fuzzy time or relative time in PHP

Had a need to show fuzzy timestamps on items in PHP. Something like “Posted 3 hours ago” for example. I could not find anything usable in my circumstance right out of the box, so I wrote one. It was cobbled together quickly, but it works. Include the class pass a unix timestamp or a parseable string to the static method and be done with it.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
<?php
class FuzzyTime
{
	/**
	* Various time formats - used in calculations 
	*/
	private static $_time_formats = array(
	array(60, 'just now'),
	array(90, '1 minute'),                  
	array(3600, 'minutes', 60),             
	array(5400, '1 hour'),                  
	array(86400, 'hours', 3600),            
	array(129600, '1 day'),                 
	array(604800, 'days', 86400),           
	array(907200, '1 week'),                
	array(2628000, 'weeks', 604800),        
	array(3942000, '1 month'),              
	array(31536000, 'months', 2628000),     
	array(47304000, '1 year'),              
	array(3153600000, 'years', 31536000),   
	);
 
	/**
	* Convert date into a 'fuzzy' format
	*   -  15 minutes ago,  3 days ago, etc.
	* Pass a unix timestamp or a string to parse to a date.
	* @param string|number 
	* @return string
	*/
	public static function getFuzzyTime($date_from)
	{
		$now = time();// current unix timestamp
 
		// if a number is passed assume it is a unix time stamp
		// if string is passed try and parse it to unix time stamp
		if(is_numeric($date_from)){
			$dateFrom = $date_from;
		}elseif (is_string($date_from)) {
			$dateFrom   = strtotime($date_from);
		}
 
		$difference = $now - $dateFrom;// difference between now and the passed time.
		$val    = '';// value to return
 
		if ($dateFrom <= 0) {
			$val = 'a long time ago';
		} else {
			//loop through each format measurement in array
			foreach (self::$_time_formats as $format) {
				// if the difference from now and passed time is less than first option in format measurment
				if ($difference < $format[0]) {
					//if the format array item has no calculation value
					if (count($format) == 2) {
						$val = $format[1] . ($format[0] === 60 ? '' : ' ago');
						break;
					} else {
						// divide difference by format item value to get number of units
						$val = ceil($difference / $format[2]) . ' ' . $format[1] . ' ago';
						break;
					}
				}
			}
		}
		return $val;
	}
}
?>

Great site for creating sitemaps and other diagrams

picture-2

http://www.lovelycharts.com/ is a slick site for creating all sorts of diagrams and organizational documents.

JSFL Round coords

I used to use a flash JSFL command for rounding the x and y coordinates of objects on the stage. I had trouble finding it for download so I made one. Get it here.

Drop it in your commands folder:
(Win) Documents and Settings\username\Local Settings\Application Data\Adobe\Flash CS4\en\Configuration\Commands\
(Mac) username/Library/Application Support/Adobe/Flash CS4/en/Configuration/Commands.

Select the objects on the stage you would like to round coords on and run the command.

Seo and flash? Looks like adobe (and google) were serious about it.

Adobe now has a section of their site devoted to it http://www.adobe.com/devnet/seo/

The google spider seems to be indexing links in flash at least, check this test http://www.nascom.be/719/can-google-index-flash

A workaround for MOUSE_WHEEL on the Mac

Matt Giger has written an AS3 class that allows access to the MOUSE_WHEEL event on OS X. It uses javascript injection via ExternalInterface to proxy the event from the browser. Check it here

Gaia site.xml creator

A nifty AIR app for creating, printing, and editing a GAIA framework site.xml file.

Originally posted/get it here