explorers’ club

Tuesday, May 13, 2008

Leopard update for Java 1.6 finally out

Filed under: Uncategorized — jwopitz @ 5:11 pm

Check out the info here - link

Also here are some tips for installing multiple versions - link

Saturday, March 22, 2008

when I said, “..and other fun stuff” this is what I meant: AA12

Filed under: fun stuff, misc, science — jwopitz @ 4:42 pm

Holy Geez! Where can I get one? What is especially interesting to me is that anyone who has fired a shotgun truly understands the term “recoil”. Its amazing how they have minimized the recoil effect providing a very stable weapon with sustained rate of fire.  Now if only they could have a magazine fed via a ammo box in a backpack.  Kinda like Tex’s weapon from Predator.

Wednesday, March 12, 2008

tutorial: Flex + AMFPHP + POG

Filed under: actionScript, amf, amfphp, cairngorm, development, flash, flex, mysql, orm, php, pog, remoting, tutorial, xml — jwopitz @ 5:30 pm

Preface

If you are no stranger to the concept of a Rich Internet Application (aka. RIA) and the different constituents that make up a RIA, you can skip this introduction. This tutorial will help developers to setup a Flex application to a database using PHP while minimizing manual database queries. Let’s familiarize ourselves with a few basic RIA concepts. Generally a RIA is comprised of 3 main components:

  • the client - no, not your client that sends the checks, but rather the Graphical (User) Interface that a user of a RIA interacts with. In our case, this the flex client that is deployed to a particular URL.
  • the service layer -this component is the hidden part of the application that interprets client events, requests information stored on a database, and then sends the requested data back to the client. In our case AMFPHP, PHP and POG will be in this category. I will explain what these mean in a bit.
  • the database - this is where our data is stored. In my case this is MySQL. Depending on your local setup, you may be using a different database.

For most of this tutorial we will be dealing with the client and the service layer. The service layer will be comprised of AMFPHP which is a very small framework which facilitates remoting between Flex and PHP. Remoting is simply a means to send and receive native ActionScript objects to a service layer. POG is another small framework for taking PHP objects and allowing CRUD methods for their database counterparts. CRUD stands for Create, Read, Update and Delete and POG simply stands for PHP Object Generator. In our case, we are setting up a RIA so that the objects sent to and from Flex will easily be able to be manipulated via CRUD methods. To sum this up we are establishing a seamless means of having Flex and a database to communicate with a minimum amount of manual data manipulation. If that confused the hell out of you, I apologize as I am kinda new to making tutorials.

Resources

POGTestApp client & server - link
AMFPHP v1.9 20070513 - link
POG - link

The Quest

Anyone who frequents this blog know that I have been on a mission for some time to get some sort of ORM setup for my pet-project. I didn’t want to be encumbered by a heavy framework with a complex API or inheritance structure. I’d looked at CakePHP, Doctrine, Propel, Junction and a few others. As a non-PHP guy, I found all of those to be overwhelming. I’d rather spend my time coding than having to read config documentation or learn a new API. That is not to say that I don’t want to learn something new, I do. I just felt enough of my time had been spent trying to find the right solution. The right solution had to be ultra-simple and intuitive.

Enter POG

POG stands for PHP Object Generator. I’ll spare you my praises of it for now (you can read up on their site if you like). Suffice it to say it is an ORM framework that is simple, intuitive and light weight. And it works for me. This looks like a long read, and it is, but it will go rather quickly. Lot’s of pictures too!!!

Your first Flex + AMFPHP + POG RIA

Server setup

I have my project setup in two places. One location is where my deployable flex content, AMFPHP and POG code goes. The other is simply where I house my Flex project source. Here is a pic of the deploy location:

picture-2.png

I use MAMP (Mac + Apache + MySQL + PHP) which is a turnkey PHP server. It works well for me because I really didn’t like doing all the Terminal setup to get my Mac’s built in PHP setup for this. If my project makes it to the big time, then all this server side setup will be delegated to a more knowledgeable person who can set it up better than I have.

AMFPHP

Firstly I want to tackle the AMFPHP part since its probably the most straight forward part of the process. Go and download AMFPHP 1.9. I am using the 20070513 release. Once downloaded, unzip it and place it in the aforementioned deploy location. The only things you need to do for AMFPHP is:

  • make note of you services folder (I put a symlink to the whole AMF folder in my flex project so I could have direct access to it from within Eclipse without having to use the bin folder).
  • adjust the following information on the globals.php
    • $servicesPath - in my case “services/”
    • $voPath - this will point to your POG objects folder once we get it setup, in my case “../pog/objects/”

That is all on the AMFPHP aside from constructing your services.

[EDIT 2008.03.21]

Since initially this tutorial only happened to touch upon the setup of these technologies there hadn’t been any issues encountered. Obviously this tutorial didn’t reflect a real implementation of such a setup beyond the simple Get method. Further development has turned up an interesting find about sending AS3 objects out from Flex to be mapped to a POG object. As it is now, it can’t. That is because the naming convention chosen by the POG framework doesn’t get picked up by the AMFPHP deserializer. My gunslinger buddy Renaun Erickson has found a simple solution for this that doesn’t break the POG naming convention. You can read more about it on his blog - link.

You need to open the AMFBaseDeserializer.php and insert the following code at line 384:

elseif(file_exists($GLOBALS['amfphp']['customMappingsPath'] . 'class.' . strtolower($mappedClass) . '.php'))
{
        $include = $GLOBALS['amfphp']['customMappingsPath'] . 'class.' . strtolower($mappedClass) . '.php';
}

POG

POG is unique in that you don’t just go and download a framework (at least not yet). If you visit POG, you are greeted with a little RIA that takes some information about the object you want to create. I decided to use the name TestObject and give it two properties: userName and password both being varchar(255). Just to reiterate, I am using the PHP5.1+ along with the POG database wrapper:

picture-3.png

Notice that I am NOT using the PDO mysql wrapper. Reason being that AMFPHP has issues finding the mysql PDO driver and not everyone’s php environment contains those. So let’s stick to the POG database wrapper.

Since this is the first interaction with POG, we want to download the full framework in addition to you new object:

dlzip.png

Then unzip the file, rename it simple as “pog” and place it in your deployment location. Next locate the {yourMainDeploymentFolder}/pog/configuration.php and update the needed information so that POG can access your database. Here is a snap of mine:

configs.png

Notice that I have my mysql port set to 8889 rather than the default 3306? Also the plugin settings url is an absolute path. In your browser navigate to the following location: http://localhost{:yourPort}/{yourMainDeploymentFolder}/pog/setup/index.php. Go through the initial welcome/setup screen. POG will do some quick unit test, and if everything goes well, you are then presented with a portal to do basic CRUD methods on your new POG object. This is useful because we can setup a few test objects to use in setting up and testing the Flex application.

Now it would appear that POG is ready to go. And you’d be correct if you just want to use the local POG portal to play with it. In order to get it working with Flex and AMFPHP, you need to fix a few things with a few classes in POG. We will come back to that after we get the Flex project setup.

Flex

I am providing my POGTestApp source for you to download, but I also want you to see the steps necessary to do it yourself. First let’s create a new Flex project. I called mine POGTestApp. Now I also have mine located in a different place than the deployment location so I used some advanced options:

flexpath.png

In the provided flex project, I have the Cairngorm.swc in the libs folder. Make sure to add the libs folder to the library path. Also point it to the services-config.xml:

picture-5.png

Open the services-config.xml and make sure to modify the endpoint uri to point to your amfphp gateway.php:

services-config.png

Now at this point you should be able to modify your Services.mxml (ServiceLocator subclass) and add your php services there. If you downloaded the files I have provided, I suggest taking a look at Services.mxml. Since this is a testing application, I have a genericFaultHandler and a genericResultHandler in this file that you can add breakpoints to for debugging purposes. So even though I am making the calls from the application file without any responders, I am still listening for them in Services.mxml. Now if you decide to make some calls of you own, without using my files, you will notice that you get some errors or it just doesn’t seem to work. That is because POG needs some adjustments to work properly.

POG adjustments

Even though POG works inside the provided POG setup.php, it won’t want to play with Flex or AMFPHP unless you give it some help. Here are a few things to modify:

  • open the class.database.php and hardcode your configuration.php settings in there. For some reason the global vars are not making through to the Database class. Since I suck at php, I was advised to put it here until a better solution is found.
  • open the class.testobject.php (or whatever your POG object is named) and add the remoting string: var $_explicitType = YourRemotingClassNameHere.
  • also add include_once(’class.database.php’);to class.testobject.php.

That should do it. Make your own or use the POGTestingServices and play with it. Keep in mind that even though my provided files work, you might get some PHP specific errors that appear to fail silently. If you experience this behavior you need to check your php.log to see what the issue is. Generally its due to the remoting code rather than the POG code.

Retrospective

I really like the idea of remoting for prototyping. It takes the hassle away from having to parse your responses in flex. POG is an ideal solution for developers not that familiar with PHP as the objects translate rather easily and since it is OO, its easy to do the mysql input without having to get involved with writing queries.

When time is of the essence, maybe you will consider this beautifully simple solution. Thanks goes out to Joel Wan (POG) and Renaun Erickson (the gunslinger) for help sorting this out. Let me know if you have any advice, suggestions, criticism and or corrections for this tutorial.

Wednesday, February 13, 2008

DNA-induced crystaline nanoparticle structure = Fortress of Solitude?

Filed under: Uncategorized — jwopitz @ 3:32 pm

Ever since subscribing to Scientific America(n) magazine, I have been super psyched about nanotechnology. They just had a recent article about proposed nanotechnology being used intravenously to do incredible things like monitoring insulin levels, detecting arterial blockages and many micro-intrusive counter measures to our species’ many ailments .

A nanometer is one billionth of a meter. Insanely small. Now scientist have made a break through in what appears to be “teaching” nanomaterials to bind, unbind and reshuffle via the guidance of DNA. Here is the original article - link

Any Superman fan can appreciate these possibilities.

Tuesday, February 12, 2008

Need some extra cash? I got a small gig for you then

Filed under: Uncategorized — jwopitz @ 7:36 pm

Normally I wouldn’t put this kind of a post on my site but I am finding myself running into a bit of a time crunch with a personal project of mine.  I am in need of a) a mentor or teacher and b) some good ol’ fashioned working, readable code.

Here’s the scoop.  I need someone who has had experience working with PHP, MySQL and some sort of ORM framework.  Specifically I need someone to teach me about the proper way of getting those 3 things working properly (e.g. integration in my current code base).  Then I will try to get them to work with my AMFPHP/Flex RIA.  However I may need some assistance in this as well.

Yes, I could spend hours researching this (which I have invested many hours doing so).  But I know my limits when it comes to self-exploration and the opportunity costs in doing so are too high.  Time is my most precious commodity.   So are you interested?   If so then read on.   I don’t really care if you have 10+ years in the field or some high school kid, just so long as you know your stuff.  All you need is to meet the following requirements:

  • proficient in PHP & MySQL w/ knowledge of a ORM technology
  • located in the USA (I don’t really want to deal with huge time differences)
  • speak English proficiently
  • the ability to articulate your points well so that a noob can understand them
  • have a paypal account (I don’t want to screw around with cash, check , etc.)
  • have skype (its free for skype to skype calls and a free download) or some IM client
  • have maybe 4-8 hours to do this to start

If you meet the requirements send an email (no comments on the blog please) to jwopitz (at) gmail (dot) com with the following information:

  • location in the US
  • code samples for PHP (remember a php noob is reading this, but a developer too)
  • skype and IM information
  • price per hour for your help

I look forward to hearing from you.

Thursday, February 7, 2008

Why development makes you feel good

Filed under: Uncategorized — jwopitz @ 8:04 pm

Ever since I got into doing actionscript development I have been profoundly altered as a human being.  I have always enjoyed challenges, but I don’t think that I actively sought difficult and challenging tasks just for the sake of doing them.   I never enjoyed brain teasers.  I’d get pissed if someone asked me a riddle.  I certainly didn’t enjoy math to the degree that I now do.  I was never much of a “step forward past this line” guy who would actively volunteer to take on a task when others wouldn’t.  I sure as shit wouldn’t have picked out a book on string theory and physics just for the sake of reading it 6 years ago.  But now I find myself doing all of these.

Developers are a different breed of people.   Its amazing how I view the world now.  Rather than looking at something for what it is, I look at everything as thought its a class or some object in this physical construct we call reality.  Its like I analyze everything in OOP.  Hell, I find myself talking to non-developers about simple things in terms of OOP way too often.  Its not a car, its an IVehicle implementor with various classes that make it go and steer.  I have often found myself at a loss when the non-developer person I am talking to doesn’t have a clue as to what or more importantly, why I am talking to them in some techno-babble.  Man I am messed up.

But back the point of being a better person.  I certainly feel smarter after becoming a developer.  I feel like more of a man too.   Growing up around my Iron Worker father, who always had a project going, I was always in the garage tinkering with tools and helping him fix things.  After moving to Boston, I lacked a garage or even the simple space to work on hands-on projects to satisfy those needs to work on something.  I felt less of a man.  Somehow emasculated by the lack of a garage or hands-on projects.  Though I may still lack a physical garage or bench to work with tools and saws and drill presses, I have my computer that serves as my digital garage.   Flex, ActionScript, PHP and other languages are now my digital tools.  And it feels great.  I feel like a man again.  Maybe a flabby, pale, desk-ridden man, but a man nonetheless.  And just look at my beefy finger muscles!  You know, there are some days my head hurts from thinking too much.  If thinking and challenging your brain is the cure for Alzheimer’s then everyone should do some sort of development.

The really cool thing about development for me is this:  Actionscript was my gateway drug.  Now I am looking for some bigger, heavier drugs like machine code, RFID, Make Controllers, C+, and the like.  I wanna build something big.   I am a developer junkie I suppose.   The other cool thing is now I am super psyched to buy a house and get a garage of my own.  So when I am done in my digital playground, I can go out to my garage and build a robot or some cool and useful thing for real.

Anyhow, I thought I’d share that with my fellow developers.   I have been thinking about this for a long time, just never shared it.  You gotta share the things you love (except your wives and girlfriends).  I am so happy to find something that is not only fun, but educational and pays the bills.

Wednesday, January 30, 2008

As my eyes glaze over… Some Community Input Please?

Filed under: actionScript, development, flash, flex, mysql — jwopitz @ 5:05 pm

I have been pluggin’ away at my pet project for a while now. Learned a little here about PHP5, a little there about MySQL and a quite a bit over yonder about AMFPHP.

Up until now, I was doing all of my PHP/MySQL communication by hand. Manually coding queries in PHP is rather intense for a noob. Plus it broadens my rather narrow OO mind. But I think its time to graduate to the big leagues now. I am really wanting to implement some sort of MVC or ORM type framework onto my project so that I can focus on developing my application more efficiently.

The problem is that there is a wealth of these frameworks out there and very little in the way of melding them specifically with my technology combination: Flex - AMFPHP - MySQL - Apache. Firstly, my eye glaze over when I start to read highly-technical documents on integration. These folks write these things as though you have been working with their technology for decades. Nope, I am new and need some noobie documentation please.

So I pose this question to my fellow developers: Have you any experience with a particular ORM/MVC framework working with AMFPHP & MySQL?  Can you give me some input on the pros/cons for combining them with AMFPHP Specifically any of these:

  • Propel
  • Creole
  • Symfony
  • Seagull
  • CakePHP
  • any others I don’t know of?

I look forward to your responses.

J

Friday, January 11, 2008

EventDispatcherProxy & ProxyEvent

Filed under: actionScript, components, development, flash, flex, gaming, geometry — jwopitz @ 11:06 pm

Preface

This is gonna be a ’stream of conscientiousness’ type post. Hopefully it will be rather easy to follow and not long winded.

Might want to open this and follow along: example flex application

In the Beginning

One of my pet projects has been making an isometric (i.e. Diablo, Diablo II) game for Flash. Part of that effort was to create an Isometric framework where a developer could easily create and manipulate isometric primitive objects while not having to deal with complex math or all the logic behind Isometric game engines. Suffice it to say its still in development and in the umpteenth version. Thank you OCD.

Initially I had made the framework in AS2, extending MovieClip, blah blah blah. Then AS3 came out and resolved alot of issues I was having while creating new ones. IsoLib made the jump to AS3. Now the basic unit was extending Sprite. That was great in one respect but generated alot of funky API methods that seemed counterintuitive.

At a crossroads

Recently I discovered Sandy 3D (or for those who can read Chinese, 3D 3D). What a phenomenal framework. I am completely blown away by it. Aside from the crazy parameter names in the API, it works beautifully. I haven’t fully decided to abandon my IsoLib efforts but this discovery certainly makes the idea more enticing. But for now I will continue trudging onwards as I think Sandy 3D may be a bit overkill or what I am doing. But peering into the framework, I discovered some things I was doing wrongly.

Mainly my basic visual unit was extending Sprite rather than being a data-type class with a stored reference to its visual attribute. Why would one choose this route? Well firstly it would make the framework’s API quite a bit lighter. Example: Rather than setting an IsoCube’s isoX or isoHeight, one could simple say isoCube.x or isoCube.height. So it certainly would allow a more intuitive API without rewiring Sprite’s public attributes. But it creates a problem.

Now that my visual class is hidden behind the scenes, I could not make use of events triggered on the non-public container aka. the base unit’s visual attribute rendered to the screen. So if I wanted to assign a click event to my isoCube, normally I would have to say isoCube.container.addEventListener… and again folks, container is non-public. Plus that again is not intuitive. I’d rather have a simpler API where I could say, isoCube.addEventListener… and it would do the dirty work behind the scenes. The other reason is that I want to the event target that is handled to be isoCube, not isoCube’s container. Don’t ya love OOP?

Enter EventDispatcherProxy & ProxyEvent

Proxy means alot of different things to alot of different people. My browser proxy, my proxy settings, etc., etc. But looking at a dictionary definition it simply means something which acts on behalf of something else. So this is an excellent name. Basically I want a class that will act as an IEventDispatcher on behalf of a non-public attribute who is also an IEventDispatcher.

Disclaimer

Now keep in mind I made this little thing in a day, and it is completely plausible that I am overlooking some one-liner AS3 trick that does all this for you. If so, please let me know.

How it works

EventDispatcherProxy is an IEventDispatcher which contains a few other items in it. It has:

  • public var proxy:IEventDispatcher - this is normally the instance, but you could dispatch on behalf of someone else too
  • public var proxyTarget:IEventDispatcher - the target which you are acting on behalf of
  • a non-public hash table to keep track of all the things you are intercepting
  • a redispatcher method that intercepts proxy’d events and triggers the appropriate handler function with the event target being he EventDispatcherProxy not the proxyTarget

ProxyEvent extends a regular ol’ Event with two additional properties:

  • public var proxy:IEventDispatcher - this will reference the instance of the EventDispatcherProxy, in the case of the IsoCube example above, this would be the IsoCube itself
  • public var targetEvent:Event - this is a reference to the original event that got intercepted and proxy’d for.

Its all theory for now or is it…

I am posting a zipped project for you to check out. Please give me some feedback.

example flex application

Thanks,
J

Thursday, January 3, 2008

For those who thought Geometry sucked in high school…

Filed under: geometry, math, science — jwopitz @ 8:16 pm

This kind of stuff is what inspires me to go back to school and get a grad degree in…Math? Geometry?

The video is rather lengthy but its put into steps via simple animations so as to understand fully the process for inverting a sphere composed of a theoretical material that can infinitely pass through itself, bend, stretch and twist but cannot be pinched, torn, cut, or pierced.

[UPDATE - per a reader's request/inquiry]

Not Knots - part 1

Not Knots - part 2

Friday, August 10, 2007

The future of this blog? My other blog?

Filed under: Uncategorized — jwopitz @ 12:39 am

So if you are a loyal reader (ha.. who am I kidding?) then you have probably noticed the lack of Flex/Flash related posts.  Firstly, I apologize for this as I have become somewhat disenchanted with Flex development.  Its not that I don’t enjoy it, its more that I have so little time to share discoveries and I lack the motivation to write about it.  Maybe its the call of the summer.  But its more likely that I have rediscovered my previous passion - music.  Secondly I have way too many interests and I cycle through them occasionally.

Anyway.  If you are a music lover, then you might be interested in reading my other blog - http://raiseyourfists.wordpress.com/.  I like writing and sharing.  I like talking about music too.  So I figure I will redirect my attention to things that I am currently passionate about.  That is not to mean that I will not be posting Flex related post here.  Quite to the contrary, I will be doing just that AND I will keep posting weekly riddles since I think that furthers brain development.  I only hope they are challenging.  Else I will have to break out the MENSA book of riddles.  YIKES!!!

Older Posts »

Blog at WordPress.com.