— tomauger.com

Archive
Tips and Tricks

Pursuant to a previous post regarding Adobe Acrobat Reader network install, here’s the Flash Player installer that bypasses the Adobe DLM, for those of you that are as paranoid and micro-managerial as I.

Manual Installation instructions on Adobe’s website

The latest installers (for the time being – your mileage may vary depending on how long since I posted this update – Sept 4, 2011 – you’re reading this post!):
http://fpdownload.adobe.com/get/flashplayer/current/install_flash_player_ax.exe (Explorer, ActiveX version)
http://fpdownload.adobe.com/get/flashplayer/current/install_flash_player.exe

Read More

Oh, lately I’ve been having a blast accommodating web servers that are not running PHP 5.3+. Amongst other gotchas, you can’t use the handy class ‘const’ keyword to define constants, you must use define().

Anyway, here’s a quick RegExp you can use in your favorite text editor or IDE to search out all those oh-so-convenient ‘const’ declarations and replace them with their ugly cousin:

Search pattern:

\bconst\s+(\w+)\s+=\s+(['"])([^\\]*)\2;

Replace pattern:

define ('$1', '$3');

Happy RegExping!

Read More

If you’re like me and you hate it when formerly trustworthy software companies start slipping more and more garbage into essential software; if you just want to do a (required) update of some software and all of a sudden are forced to jump through hoops, install additional unnecessary components, download managers etc; if you just want a simple link to the download which seems to be impossible to find on the software vendor’s website; if you just want to update Adobe Acrobat Reader so that the annoying plugin message goes away from Google Chrome, look no further.

Adobe’s Direct FTP Site for Acrobat Reader

Here’s a link directly to Adobe’s Acrobat Reader FTP site. Just click here, and then you’ll have to dig into the folder structure a bit based on your platform and architecture, and the version you’re looking for. Good times.

Read More

In Illustrator, you may have noticed that when you press “D” to set your default stroke colour to black, you actually end up with a muddy grey colour instead. If you’re like me, you won’t notice this until it’s way too late, and half your stuff will be one shade of black and the other will be a darker shade, and then you have to go through the whole rigamarole of using Select > Same Fill etc. to edit the colours.

So how do I fix the default black so it’s not grey?

The answer is to change the colour inside the Black swatch. If you look at your Swatches palette, you will see that the fourth swatch in is Black. By default, Illustrator ships with this Black being equivalent to CMYK 0,0,0,100, which makes sense if you’re working in CMYK a lot.

If you find yourself doing web work and you wish to change the default Black to RGB 0,0,0 just edit this swatch colour.

Read More

The following error in PowerPoint 2003 came up when trying to open a client’s PowerPoint 2007 file:

“PowerPoint was unable to display some of the text, images, or objects as slides in the file (name) because they have become corrupt. Affected slides have been replaced by blank slides in the presentation and it is not possible to recover lost information. To ensure that the file can be opened in previous versions of PowerPoint, use the Save As command and save the file with the same name or a new name.”

The solution was buried, so I’m just resurfacing it here to save others the tedium.

In a nutshell, the issue involves having a particular Microsoft Update installed. The hotfix in question is Microsoft Office KB 2464588. The issue and subsequent solution is documented on Microsoft’s website here.

Download the Microsoft Hotfix (to fix the Microsoft Hotfix)

Sure sure, you skipped all my links to get to the solution. Why waste time, right? Fine. The hotfix you can install to resolve this issue can be downloaded here.

Read More

Get Adobe Flash player

I was going through my archives and discovered a number of little demos and tests done in AS2, either to satisfy my own curiosity, or to answer questions posted on Experts Exchange. Here’s another one.

This demo illustrates the use of ExternalInterface to access the URI of the containing web page. This sort of thing becomes useful when handling deep linking within large Flash multi-page sites.

Read More
Get Adobe Flash player

As the title of this post suggests, there is a somewhat unintuitive “feature” in Flash when using inline “frame” scripts to stop() a movie from playing when it first loads. If you use gotoAndPlay() to jump to that frame, the play() part is “over-ridden” by the inline stop() instruction, which is executed AFTER the playhead has been moved to that frame. This came up on kirupa’s forums and the torch was recently taken up by another user, so I decided to investigate and put this thing to bed.

Workaround 1: Redesign

The solution is reasonably simple: tell your designers to insert a “landing” frame containing the stop() instruction in a frame BEFORE the actual frame that you will be jumping to. So, if you were doing gotoAndPlay(1), instead, have the designer insert a keyframe at frame 1, include the stop() action on that frame, and then duplicate that keyframe to frame 2, at which point you can start your animation loop. Now you’ll call gotoAndPlay(2).

Workaround 2: enterFrame()

Okay, so what if you don’t have the luxury of being able to modify the frame structure of the clip(s)? What if it’s rampant throughout your movie? We’ll make a little modification to our method for jumping to the frame in question.

(Bear in mind that this solution specifically addresses ActionScript 2 code):

buttonMC.onPress = function(){
	this.gotoAndPlay("down");
}
 
buttonMC.onRelease = buttonMC.onReleaseOutside = function(){
	this.gotoAndPlay("up");
	this.onEnterFrame = continuePlay;
}
 
function continuePlay(){
	this.onEnterFrame = function(){};
	this.play();
}

Here you can see that when we call gotoAndPlay() we attach an enterFrame handler that is responsible for doing two things:

  1. call play() on the clip, to get it going again after the stop() was called from the frame script
  2. clear itself (so you don’t call play() every single frame, essentially rendering any future frame script stop() commands useless)

Download Source

And to all you snobs…

Who are tempted to register just so you can post a snotty comment that “real Flash developers don’t use frame scripts anyway”, let me get a pre-emptive strike in. First of all, yes, you’re right. Real Flash devs have been trained (I didn’t say “brainwashed”…) to never use frame scripts. BUT, if you’re more than a grubby-haired teen working alone in his basement, you’ll know that in the real world we often work in these things called “teams”, where you have folk of all sorts of different expertise. We work with these guys called “designers” who can barely be convinced to open up the Actions panel and type the word stop followed by open and close brackets (“why!?!” they cry in despair. “Why the brackets??!”) and a (gasp) semicolon.

And these Designer types, they like to preview their flash movies. And they get really distressed when their buttons start flashing wildly and animating on their own. So we appease them by letting them do this one – and only this one – thing in an inline frame script.

Of course the proper way to do things is to call stop() on the movieClip in your Document Class init() method. And in fact, we’ve even found ourselves writing these complicated recursive methods that drill into every movieClip present on init and stop them programmatically. But like I said, often the designers live with the Flash far earlier in its project lifecycle than we do, so they insert all these little stop(); commands all over the place.

And there you have it.

Wow, speaking of “snotty”, those last two paragraphs were pretty snide. If you haven’t shut down your browser, purged my blog from your bookmarks (you did have my blog bookmarked didn’t you?) and removed me from your blogroll, well thanks for indulging my ranting ways. Speaking of ranting ways, just wait until you see my follow-up to my Apple rant. It’s a-brewin….

Read More

This is a continuation from a previous post that looks at custom development based on the GD Star Ratings plugin for WordPress.

You would think this would be the most highly documented feature – how to actually insert the ratings for a particular article right in your theme. Heck, maybe there’s a way to do it from the Admin panel that I haven’t even noticed, but I’m a back end kinda guy anyway. Here’s the full code. This one has been written to work within The Loop, but it’s trivial to modify it to work with a custom loop or query if you wanted:

$postRatingData = wp_gdsr_rating_article(get_the_ID());
gdsr_render_stars_custom(array(
    "max_value" => gdsr_settings_get('stars'),
    "size" => 12,
    "vote" => $postRatingData->rating
));

That’s basically it in a nutshell. Max Value is the “total” number of stars (eg: 5 out of 5), Size must be one of the default sizes ie: 12, 16, 20, 24 etc, Vote is the actual calculated result, which we got by passing the ID of the current post to wp_gdsr_rating_article.

Read More

GDSR, in case you don’t know it, is one of the best, most complete plugins, and APIs, for adding all sorts of  ratings, thumbs and good stuff to your blog. Anyway, check it out.

Of course, like most WP stuff out there, the documentation is a mess (though I must admit this one is far better than most, so props to the dev). As I desperately try to customize the way it works, I’ll post my findings here.

Getting Admin Settings

So you want to write good code and you want to leverage the extensive settings available in the Admin panel. How to access those settings? Well I don’t know if there’s an official way or not, but digging through the many pages of PHP code, I have found

gdsr_settings_get(SETTING_NAME);

This queries the global GDSR object and grabs the setting by name. The trouble is, I haven’t found any documentation for what these settings names are. There are a couple of strategies here:

1. Query the global $gdsr object. This is a real hack, but it worked for me:

global $gdsr;
print_r ($gdsr->o);

While this ain’t pretty, you’ll get a list of every single setting available. Now you have to figure out the one you want.

2. View source on the Admin page. This didn’t work for me exactly – I had been hoping that by going to the Admin page, and inspecting one of the textfields or pull-down menus and grabbing its name or id I could find the corresponding setting. Turns out, there isn’t any direct correlation – for example the setting that controls the # of stars shown on the article page is called “gdsr_stars” where the gdsr_settings_get string is ‘stars’. Hmmm. Come to think of it, maybe they’re all related after all, just remove the gdsr_ prefix. Worth experimenting with.

That’s all the time I have. If even 1 other person finds this useful it was worth it.

Read More

Important Note: I’ve learned a ton about WordPress since this post, and it actually does not follow best practices.

I will blog on this soon (as soon as my current workload customizing WordPress lets up), but in the meantime, please see my PowerPoint presentation from my recent WordCamp Montreal talk on WordPress best practices. The post below is actually an embarassment. Maybe I should just pull it…

This is a quickie – suppose you want to quickly select the latest comments across all posts within a specific category. This mySQL query gets you there:

select C.*
from wp_comments C
join wp_posts P
	on C.comment_post_ID = P.ID
	and P.post_status = 'publish'
	and P.post_type = 'post'
 
/* join posts to category */
join wp_term_relationships TR
	on TR.object_id = P.ID
 
join wp_term_taxonomy TT
	on TT.term_taxonomy_id = TR.term_taxonomy_id
	and TT.taxonomy = 'category'
	and TT.term_id = [CATEGORY ID]
 
where C.comment_approved = 1
 
order by comment_date_gmt desc
limit 1;

Just replace the [CATEGORY ID] with your $catID and you can change the limit if you want more than just one most recent comment. Limit 5 will give you the 5 most recent comments that you can then loop through and display.

Read More

It’s been a while so I’m forcing myself to post a couple of tips I learned today. Been using AI for nigh on 20 years, and there are still little tricks that I regularly add to my bag.

The polygon tool has always bitten my nards because it seems you have to option-click first, set the number of sides, press OK, then delete the shape, and then draw your shape interactively. I decided that this was just ridiculous and checked the Adobe help docs on the matter. Indeed – you can use the Up and Down Arrow keys (while the mouse button is still pressed) to change the number of polygon sides while in interactive drawing mode. After you’ve got the number of sides right, then you can go to town with the SHIFT key or whatever other modifiers you need to get the job done. Sweet.

Centering Objects

I’ve also always been pissed at AI with the way centering objects works – before I learned this (documented) trick. Ever have a big object and you want to center a small object inside it? So you select both of them and then use the Align Palette to center them – and of course they both move! Well, if you select them both as usual and then CLICK (but not SHIFT-click) on the one you don’t want to move (usually the bigger object) then it will become the “key” shape and it will stay locked in place while the other shape(s) jump into position. Sweeter!
Happy Illustrating.

Read More

Have you discovered the <button> tag yet? It’s actually pretty cool, making it easy(er) to style submit buttons and the like to do things like, say, put pretty icons in front of the button text and so forth.

The button tag looks like this:

<button type="submit" name="action" value="delete_123">Delete This Item</button>

You can even put other cool HTML inside the button:

<button type="submit" name="submit" value="resetPwd"><span class="resetIcon">Reset Your Password</span></button>

This gives you a lot of control, which otherwise might need to be done with one or more (non-semantic) wrappers outside of an <input type=”submit” /> tag.

The real beauty (for me) of the <button> tag, is that the value that is send to your server-side (PHP, Perl whatever) can be different from the message that is displayed to the user. In the first example shown, you could imagine a list of products, each of which has a “Delete This Item” button. The User sees “Delete This Item”, but the server gets “delete_123″ and, with some very simple string splitting, can figure out what action you want it to do (delete) and what item to delete (123).

Cool.

Well, well, well, this is probably the first time I’ve seen IE break the server-side of things, but they’ve managed to cock that up too. Note that this has supposedly been addressed in IE8, but we’re not just targeting IE8 when we write RIAs are we?

The issue is that IE 6, 7 contravene the HTML 4.0 standard, and send the <button> tag’s innerHTML rather than the value!

Can you imagine that?

So what the server gets (when submitted from IE only) is:

<SPAN class=resetIcon>Reset Your Password</SPAN>

(do note that IE converts to upper case AND removes quotes from attributes as well. Awesomeness.)

All other browsers submit:

resetPwd.

Read More