Proper use of Buttons in AS3

Flash Development No Comments »

I recently came across an issue with disabling buttons in ActionScript 3 without removing the MouseEvent listeners. In AS2 its simple if you just set the enabled property on the button/movieclip to false. In AS3 you have to do a little more than that. You need to set the mouseEnabled property on the button/movieclip to false but I also found that the MOUSE_OUT event will get triggered when that occurs so you need to do some custom code to disable that functionality.

In AS2

buttonClip.onRelease = function() { this.enabled = false}
buttonClip.onRollOver = function() { // do something }
buttonClip.onRollOut = function() { // do something }

In AS3

buttonClip.addEventListener( MouseEvent.MOUSE_DOWN, buttonClick );
buttonClip.addEventListener( MouseEvent.MOUSE_OVER, buttonOver );
buttonClip.addEventListener( MouseEvent.MOUSE_OUT, buttonOut );
 
function buttonClick(_e:Object) {
    _e.target.mouseEnabled = false;
}
function buttonOver(_e:Object) { // do something }
function buttonOut(_e:Object) {
    if(_e.target.mouseEnabled == false) return;
    // do something
}

You’ll  notice in AS3 how you need to check if the mouseEnabled property is set to false before you handle the mouse out functionality. In my project I was changing the button color on mouse over and changing it back on mouse out. When they clicked on the button, I set the mouseEnabled to false but the buttonOut function was getting triggered automatically, so this workaround fixed the issue. It’s not too much extra code but was annoying to figure out what was going on.

PHP Nested Functions using global variables

Web Development 1 Comment »

Today I figured out the hard way some intricacies of using the global setting within nested functions. In PHP, if you want to load a variable from outside of your function, you first have to declare it as global before you use it inside your function. So Something like this.

$a = 1;
function test() {
    global $a;
    echo $a; // will output '1'
}

I assumed it worked similar to actionscript where anywhere you use a global variable it can find it. That isn’t always the case in PHP as I just found out. The global setting is merely a reference to the top level code, so issues can come up when you are using nested functions. So I had a function that did an include or two and had a function within that at some point and realized any variable that was within that first function was not accessible even if I globalized the variable. So here is what I was trying.

function simpleFunction() {
    $a = 1;
 
    function test() {
        global $a;
        echo $a; // will output nothing
    }
 
}

Nothing would output in this senario because my test function is looking on the top level code for that variable. Since my variable isn’t in the top level, there is an issue. So my solution was simple. Just declare the variable global in the top level and then use it wherever I want. Something like this.

global $a
 
function simpleFunction() {
    global $a;
    $a = 1;
 
    function test() {
        global $a;
        echo $a; // will output nothing
    }
 
}

So now the variable is declared in the top level even though I’m using it within a function and a nested function. It took me a bit of time to figure this out so hopefully someone else can learn from it. Enjoy!

My new mac-mini server

Misc, Web Development 1 Comment »

Recently I had been toying with the idea of getting my own server because I hate being limited to whatever my shared host allows. I wanted to be able to load whatever software I wanted on it, load up as many websites/domains as I wanted, handle as many ftp accounts as I wanted and install any media streaming software I wanted. Email wasn’t really an issue since I think it makes more sense to route it all through a google apps account. I had a bit of experience (just a bit) working with servers since I have a mac-mini setup in my living room running MAMP that has all my movies on it and actually has a domain pointed to it (via zoneedit.com) to present client work.

After a bit of research I came accross macminicolo.net. They simply allow you to send them your mini, or you can buy one off them, and they hook it up to their network allowing you to access it through vpn, vnc, ssh or however else you choose. One might question its speed but I have already put a couple database heavy sites on it, including this website, and they load immediately.

I ended up buying a mini locally here and installing a faster, larger hard drive and loaded up the ram in it, installed all the necessary software and sent it off to them. They are in Las Vegas and there seems to be a fairly good pipeline to the internet down there. I’m very pleased with the server and the speed of my sites, I feel sort of free now because I am not under the yoke of being on the same server as a dozen or so other people; *barf*. So I can do whatever I want with it without having to ask if a specific port is open, or if php has a specific setting activated. I even ended up buying OSX Server. It has a bit of a learning curve for a server newbie like me but I feel pretty comfortable using it now. I didn’t have to worry about setting up a mail server or dns info which kept things simple. Setting up an ftp server on it was a bit tricky but I managed to get that working with pureFTPD and I even managed to get a few cron-jobs running on one of my sites.

Anyways, my hat is off to the fella’s at macminicolo.net for making my life a bit more easy.

Online Coupon Codes – My latest creation

Web Development No Comments »

Coupon Sherpa - Online Coupon Codes

I am now officially in the affiliate marketing world. After developing the Coupon Sherpa iPhone application with my brother Luke we decided we would also build a full fledged website offering every kind of coupon imaginable. So now our iPhone application is one aspect of what Coupon Sherpa is, with its most important being the website where you can find online coupons, printable coupons, grocery coupons and even coupon friendly blog postings. We just recently finished it and I would say it is some of the best PHP mySQL work that I’ve done. I built a brand new content management system (CMS) for it that allows for multiple users with different types of user accounts with the ability for them to manage all our stores, coupons, categories, banners, links, comments, etc. Both the back-end and front-end of the website utilize a large amount of the latest ajax technology to help keep the user experience seamless for doing such things as submitting contact forms, adding coupon or blog posting comments, or even suggestion hints when a person is using the search tool. PHP and mySQL were used for the framework and I also implored some new techniques I’ve learned recenbtly with CSS to display the content.

Something kind of exciting about the site is that I was actually able to get all our coupons to load dynamically from affiliate networks. Each network that we work with has a different type of api that we use to grab the latest coupons. This forced me to have to create a parser file for each network to work with their xml,csv, or even rest data. We then load any coupons we haven’t seen into our database using a cron job and then either remove the ones we don’t want or enable the ones we want to show up on the website. Seems straight forward enough but it actually took a fair bit of thought to make it all work. We also decided to ask for people’s twitter info on comments in the blog and I was able to access Twitter’s api and load in the person’s twitter image and user account info to display for each comment.

Anyways, a lot of work went into making it happen but it’s finally up and running and we’re excited to see how it works. We’re hopeful that a lot of people can save some money using it.

Some links…
American Eagle Coupon Codes
Kohl’s Coupons
Gap Coupon Codes
Target Coupons

Visit CouponSherpa.com

New Site Launch – Ray Caesar Portfolio

Web Development 1 Comment »

So, over the winter I had been working on a portfolio website redesign for a 3D artist in Toronto. The project was mostly php/mysql based which was a welcome change from all the flash work I had been doing earlier that year. The website includes an inline CMS (meaning that after you login, you just navigate around and edit whatever items you want to). It turned out a lot better than I thought it would and uses a lot of ajax for a lot of the cms updates. My buddy Ian McFadyen did all the design work and did an amazing job to boot. I handled all of the development work.

View Ray Caesar’s website.

After learning about the project I realized I should probably get my hands on a PHP based framework to base everything off of. I found out that so many frameworks are way too convoluted with things I would never use. Along my google journey I ran accross something called Simple PHP Framework. I downloaded it and ran some tests with it. It comes with some very nice utility functions and classes including user authorization classes and database access classes. It had pretty much everything I was looking for.

Anyways, I’m just sending out much love to the guys involved with the framework for saving me many hours of tearing my hair out figuring a lot of this stuff out myself. I’ve also since implemented it on http://www.freeshipping.org and the admin for my first iPhone app’s webservice at http://www.couponsherpa.com.

Coupon Sherpa: Scannable Coupons on your iPhone

iPhone Development No Comments »

For the past couple months I had decided to take a break from Flash development and try something completely foreign to me; iPhone App development. The language is completely different than Actionscript, however it comes Model-View-Controller based, so that was my only comfort.

My brother and I came up with an idea to put coupons on the iPhone, something that hadn’t been done yet, or at least hadn’t been done very well yet. The idea, I would develop it, he would design it and get the coupons in it.
Read the rest of this entry »

Autoblur Javascript Object

Web Development 1 Comment »

I hate coding things twice and every once in a while I seem to need something that automatically clears the default value in an input text field for a form. So I decided to write a javascript object that would make life incredibly easy for me. And now its all yours if you have a need for something like this. Here is an example of what I’m talking about. You will notice that when you click in the text field it clears the default text, and if you click away from the text field it will return the default text only if you haven’t entered anything. it’s pretty basic but annoying to always have to code again and again so I have added it to my utils.js file that I use throughout my projects. Here’s the code…
Read the rest of this entry »

Today is Free Shipping Day

Misc No Comments »

I have written previously about the free shipping website that my brother created. To help merchants and shoppers he’s created a new shopping day. It’s called Free Shipping Day and it is today. Over 250 participating merchants will be offering free shipping with delivery by Christmas. Luke says that merchants really like the idea of this holiday and some very big brands have contacting him to let him know that they will be participating. You can find a list of all the merchants that will be taking part in the first Free Shipping Day at his website.

As for every other day of the year you can find coupon codes for free shipping at FreeShipping.org. Some of the new merchants that are on the website include Victoria’s Secret, J Crew, Saks Fifth Avenue and Crutchfield.

Happy Free Shipping Day!

Flash Tracer Dashboard Widget

Flash Development 9 Comments »

This will likely be of interest to most Flash Developers fortunate enough to be working on a Mac.

Since I recently stopped using Firefox due to its ever increasing size and annoyance of download requests every time I opened it, I chose to switch over to a much slimmer Safari. The only thing I really missed with Firefox was the Flash Tracer extension, which allowed me to see what was going on in the flash files loaded into Safari. So why not come up with a widget to make that happen. So I decided to download the new xcode development tools provided by Apple. It comes with a handy graphical tool for making osx dashboard widgets. After a few evenings of tinkering with the program I came up with my first widget, it is similar to Firefox’s Flash Tracer extension but will allow you to use any browser you want and has a few more features. It uses Ajax to load the flashlog.txt file generated by the flash player (debug version) and parses the data for displaying properly. Pretty strait forward but very useful for any flash developer I would think. All I do is hit the corner hot-spot that loads my dashboard and the flash tracer widget appears showing me all the guts of my flash files that are running in my browser.
Read the rest of this entry »

Free Shipping Just in Time for the Holidays

Misc 1 Comment »

I am happy to announce that our company Kinoli just launched Free Shipping.org. The web site is an online shopping resource with a list of over 600 stores with free shipping coupons and promotion codes. By the end of 2008, we expect to have over 1000 free shipping coupons on the site. The site also has a list of last minute shipping dates for many of the most popular stores.

Some of the featured deals will get you Target free shipping , or free shipping at Kohls, Macys, Sierra Trading Post, Dell, Shutterfly, Snapfish, Lands End or JCPenney free shipping. You can shop by brand or category. The toys free shipping category is one of the most popular on the site.

Anyways, we hope you can get some use out of it this holiday season.

We’re super excited about FreeShiping.org and would love your feedback.

WP Theme & Icons by N.Design Studio
Entries RSS Comments RSS Log in