Archive for the ‘Code Tricks’ Category

Flash is odd sometimes

Thursday, September 2nd, 2010

Like when you are embedding a swf in pretty much any non-IE browser (I had FF, Chrome, and Opera installed) and if you set the scale property after you set the salign, it ignores salign. Not sure why, but it’s really odd. So just make sure to place scale, and then salign when embedding.

CS5 flashvars

Monday, June 21st, 2010

I’m posting this up here because I hope someone will find it and discover they did not do something stupid, Adobe did. Basically if you want to use any flashvars in Flash CS5, you must use the work around provided here: http://forums.adobe.com/thread/644057. Basically the new built in preloader (which I’m not sure if you can disable or not) causes all flashvars specified to be set to undefined. Not a handy feature at all. Not sure how that one slipped passed testing, unless no one uses flashvars anymore, but that must not be case then is it?

On the Boards

Friday, February 19th, 2010

Forgot to make a note about probably the coolest site I’ve worked on, ontheboards.tv. It launched three weeks ago and seems to be doing well. It survived the first weekend even with an article in the New York Times about the site. It was neat to work on a large scale project with lots of custom functionality. The site may look pretty simple, but there is quite a bit happening behind the scenes.

One thing we discovered while developing the media player is the FLVPlayback component doesn’t always raise the Buffering/Playing/PausedStateEntered events when those states are entered. Makes it difficult to properly handle those situations when you don’t know you are in them. Turns out if you use the StateChange event and check the event state, you always know what state the FLVPlayback component is in. No idea why that happens, but if you find yourself building a custom video player, keep that in mind.



Edit: Turns out On the Boards found this post and linked it on their blog. In the interest of providing some more details I wrote another post to compliment this one.

Deciding on coding standards

Thursday, July 2nd, 2009

As everyone knows coding standards quickly become a religious debate as soon as there are more than a single developer working on a piece of code. Luckily the people I work with share the same sense of clean coding standards as I do.

However the other day we had a dissagreement about what to name the event parameter in a handler, ‘e’ or ‘evt’. Neither of us had a strong argument for using one over the other. So we ended up playing Rock, Paper, Scissors. It is the perfect solution for deciding on issues that have little to no impact on how the code actually works. It enables a decision to be quickly made, and hopefully the parties involved agree that RPS is a fair and balanced method.

If you want to get super geeky, you could play Rock, Paper, Scissors, Spock, Lizard. I just found out about that the other day because of a t-shirt on Think Geek. I haven’t tried playing yet, it may take a while to remember what beats what now.

A neat Joomla trick

Monday, January 26th, 2009

I’m in the process of making a Joomla site for the first time and I needed to be able to have different pages of the site have different styles. I looked around and wasn’t able to find any examples that actually worked for my needs. I found some info about the Page Class Suffix option, but nothing about how to really use it. I talked with Brian over at Heavy Robot, since he has actually made some Joomla sites and he whipped up this bit of code that fits my needs perfectly. Basically it uses the Page Class Suffix variable from the menu system as the class name on the body. You can then add any styles you need to your basic style sheet and have all sorts of different page styles.

Place this PHP block in the head of the index.php file of your template. I used the built in template editor, which also points out which template you are currently using.

<?php
     $menus = &JSite::getMenu();
     $menu = $menus->getActive();

     if (is_object( $menu ))
          $params = new JParameter( $menu->params );
          $pageclass = $params->get( 'pageclass_sfx' );
?>

 
Then replace the open body tag with this block, also in the index.php file. Or you can use just the part where the page class is written out if you want to have multiple classes on the body.

<body id="bd" class="<?php echo $pageclass;?>">

Now whenever you create a new menu item in the menu manager, add a value for the Page Class Suffix (under the Parameters (System) expando-box) for any pages that need different styles.