Archive for June, 2007

Command Line MAMP

Saturday, June 23rd, 2007

I just installed MAMP on my Macbook. This is great, as it gives me MySQL, Apache, and PHP all ready to go. First, I restored default ports in preferences, and then I discovered the beauty of TextMate shortcuts when I typed in vhost[tab] in my httpd.conf file while adding in some of my dev sites. Beautiful. I was ready to go. Now, I just needed to load up some databases. Off to the command line… But, there was no mysqladmin. On top of that, the default php 4 install was in my way when I went to do pear upgrades.

The binaries I wanted were there. They just weren’t in my bash path. Once I found the directories I needed, I just added them to my path by appending the following lines to my ~/.profile…

# Add MAMP binaries to front of path
PATH=/Applications/MAMP/bin/php5/bin:\
/Applications/MAMP/Library/bin:$PATH
export PATH

You’ll notice the existing PATH is appended to the end so that my MAMP php binary is now found before the old php4 version when I type ‘php’ from the command line. I also have access to mysqladmin, mysql, etc. like I would on just about every other machine as well as apachectl so I can do things like config tests and vhosts dumps (apachectl -S).

In my opinion, this should really be a part of the MAMP install. Anyway, I thought I’d document it here for future reference.

GridLayout - Part 1

Wednesday, June 13th, 2007

GridLayout (com.bumpslide.util.GridLayout) is a class I originally created to simply manage the attachment and positioning of a series of MovieClips. I began using it to build all my data grids, thumbnail lists, and various types of menus. Recently, I have refactored it to support scrolling and/or paging via an index offset as well as paged data loading via the AS2 DataProvider API. The end result is an all purpose utility that can be used to build everything from simple menus to custom data grids. This post is just a quick introduction to using the code. Parts 2, 3, and 4 (to come) will go into more details about scrolling and data loading as well as alternative uses of the GridLayout class.

You can get a sneak peak at the examples here.
(more…)

Burst Labs on FWA

Monday, June 4th, 2007

Burst IconThe site JD and I made for Burst Labs made Site of the Day for May 27th, 2007 on FWA. If you haven’t seen it, you should check it out.

http://burstlabs.com/

Everything you see was built from scratch. The back-end is a custom MySQL database and admin tool I built using CakePHP. Middleware is AMFPHP, and the front-end is all Flash 8 Actionscript 2.0. When I have more time, I will try to blog a bit about some of the components I built.

Nerd Highlights:
- Custom data grid built with com.bumpslide.util.GridLayout supports mousewheel and paged data-loading
- State management with com.bumpslide.data.Model
- SWFAddress for deep-linking and Back-button support tied directly to the Model

JD has more on the subject.

Easy Bezier Interpolation

Monday, June 4th, 2007

Demo: Easy Interpolation
Source: Interpolation.as

Commenting on my Interpolating Sine post, Saravanan wrote:

is there a way to smooth this line..........please help........

Why, yes, there is. Again, Patrick has done all the dirty work, but unfortunately his interpolation code was dependent on his demo movie clip classes. Rather that bother a man who is now retired, I borrowed his code, removed the dependencies, made it MTASC friendly, and am sharing it with you now. Patrick's cubic bezier and interpolation classes have been combined into com.bumpslide.util.CubicBezier.

Here is a quick sample of using this class to draw a smooth curve through a series of random points:

Actionscript:
  1. import com.bumpslide.util.CubicBezier;
  2.  
  3. // create some random points
  4. var targetPoints:Array = new Array();
  5. for(var i=0; i<9; i++) {
  6.     targetPoints.push({x:50+50*i, y:Math.random() * 300 + 50});
  7. }
  8.  
  9. // interpolate the points
  10. var overshootFactor = 20;
  11. interpolatedPoints = CubicBezier.interpolatePiecewise( targetPoints, overshootFactor );
  12.  
  13. // draw
  14. var holder:MovieClip = createEmptyMovieClip('holder_mc', 1 );
  15. holder.lineStyle(0, 0x880000);
  16. holder.moveTo(interpolatedPoints[0].x, interpolatedPoints[0].y);
  17. CubicBezier.drawBeziers(holder, interpolatedPoints);

The full example and all related source files are all in my Bumpslide Library SVN repository.

References:
http://www.5etdemi.com/blog/archives/2006/10/interpolating-points-using-piecewise-cubic-beziers-source-code/
http://www.timotheegroleau.com/Flash/articles/cubic_bezier_in_flash.htm
http://www.moshplant.com/direct-or/bezier/