Actionscript 3.0
Photo Shoot Builder v0.2.3a
by Brian Hodge on Aug.27, 2009, under Actionscript 3.0, FlashDevelop, Flex SDK
I haven’t blogged in some time because many things have been going on. I am no longer working at Streetwise and I am freelancing at home. So far the journey has been pleasant. I now have much more time to work on personal projects and once such project is Photo Shoot Builder. PSB is still alpha quality, but we will be going beta with is soon.
Bram Timmer, a long time friend and very strong designer/photographer, suggested that photographers needed a more elegant method of creating these set lists. Bram soon handed off the creative to me in the form of a PSD, as we usually do, and after a lot of cutting, codeing and compiling, we find ourselves at v0.2.3. Click the link below.
Photo Shoot Builder is merely a drag and drop enabled tool for building a typical set diagram that is rather common in photography. It utilizes many different design patterns, all within context, and the site is very extensible, easy to update, and performs very well. When the end-user is ready, he or she may choose to save as jpg or png. We are close to enabling the Flickr upload mechanism as well. Go play with the application, but remember it isn’t even beta yet. If you are going to leave feedback, please be constructive.
Flash CS4 3D: A little confusing when using a DocumentClass?
by Brian Hodge on Apr.11, 2009, under Actionscript 3.0, CS4, FlashDevelop
I have a client that needs some simple 3D. Since I am allowed to develop the project for Flash Player 10, and my 3D needs were simplistic, I chose not to use Papervision3D. I began things like normal. I opened FlashDevelop3 and created a project. Then, I opened Flash CS4 and created a rectangle. With a mock-up of the final product in the background, I began to rotate the rectangle in 3D space; until it matched the comp. When I was happy, I tested the movie, and sure enough everything looked great.
After getting my creative into its proper position and perspective, I moved on to link the DocumentClass that FlashDevelop3 created when I created my project, to the newly created flash file. As soon as I entered the document class, I tested the movie. My rectangle no longer had perspective and was only barely visible on screen. I removed the document class and all the sudden my rotation values were back.
I began to scour google for answers and eventually found some on adobe’s site. What what said on adobe’s site was to set the following in your class.
//”this” applies to my DocumentClass
this.transform.perspectiveProjection.projectionCenter = new Point(someNumber,someNumber);
this.transform.perspectiveProjection.fieldOfView = someInt;
Having this information, I quickly entered in and tested my movie. I was a bit saddened to see that nothing had changed. I sat for a moment and thought about it. If the values for projectionCenter and fieldOfView must be set if using a document class, then it is possible that any rotation on the X, Y, or Z, in the Flash IDE may have been ignored. I quickly set rotation values with actionscript and tested the movie. EUREKA! It works.
Hopefully this little tid-bit of information can save you from the aggravation I went through
FlashDevelop3 R2 and the Flex 3.3 SDK video tutorial Part 04: How to create an AIR application.
by Brian Hodge on Apr.06, 2009, under AIR, AIR SDK, Actionscript 3.0, FlashDevelop, Flex SDK
This short video shows you how to create an AIR project.
First, the Descriptor file (setting the namespace to 1.5) and changing any other settings you wish.
Second, edit the CreateCertificate.bat and create a certificate.
Third, edit the PackageApplication.bat, compile your application to create a swf, then run PackageApplication.bat, provide the password set in CreateCertificate.bat and the AIR application is created in the air folder.
Stay tuned for a run-through of the AIR Update Framework, which allows users to check for updates which is dictated by a UpdateDescriptor file on your server somewhere.
CachedSharedObject Class, A Local Shared Object that clears with the browser cache.
by Brian Hodge on Apr.01, 2009, under Actionscript 3.0
DEMO: http://dev.hodgedev.com/DeSOL_testing/
Note: This is not intended as a replacement for SharedObject. Obviously if you still require some level of persistence you could just use the native SharedObject; However, if you require the use of a SharedObject and would like it to clear with the browser cache, or by a certain date, this class can help you.
The class works by creating a cookie when the shared object is created; This is done with the help of the ExternalInterface Class in the flash.external Package which makes a call to a javascript function.
From the point of creation, the SharedObjects lifespan is directly related to that of the Cookie’s life span. The two share the same name, and upon load of the page a function is called to check if a particular cookie exists. The cookie acts as a reference for the SharedObject. If the cookie is removed, meaning the cache has been cleared, the next page load checks the cookie, finds that it does not exists, and clears the SharedObject that has the same name.
-
- //The AS3 Class
- package com.hodgedev.desol.net
- {
- /**
- * …
- * @author Brian Hodge (brian@hodgedev.com)
- */
- {
- /**
- * creates a cookie via ExternalInterface and a call to a
- * javascript function which is expecting three things:
- * a name, a value, how many days until expiration. A
- * SharedObject and a cookie are created with the same name.
- * The SharedObjects life is dependent up on cookie's life.
- * @param pName string used to name the SharedObject
- * @return SharedObject
- */
- {
- var createStr:String = ExternalInterface.call("createCookie", pName, "Exists to allow flash local shared objects to clear with browser cache clear.", "7 " );
- }
- /**
- * an array of cookies recieved from the javascript window.cookies
- * call returned as a string then converted to an array.
- * @return
- */
- {
- }
- /**
- * Acts as the garbage collection for a CachedSharedObject.
- * The cookie that was created at the same time is the
- * reference. If the reference no longer exists, hence
- * the cache was cleared, the SharedObject is removed.
- * @return Boolean
- */
- {
- if (CachedSharedObject.cookies().length < = 1 )
- {
- trace('No cookies found, clearing all CachedSharedObjects.');
- return true;
- }
- return false;
- }
- /**
- * reads a cookie via ExternalInterface. A
- * javascript function returns a string which
- * this function then returns a reformmated
- * version of.
- * @param pName
- * @return String
- */
- {
- return "Cookie name: " + pName + "\nCookie value: " + readStr;
- }
- /**
- * Erases a cookia via ExternalInterface. A
- * javascript function deletes the cookie.
- * @param pName
- */
- {
- }
- }
- }
- //The javascript
- /**
- *Author URL: http://www.quirksmode.org/js/cookies.html
- *Notes: Thanks to the author at the above site for the
- *easy to use functions.
- */
- function getCookies()
- {
- return unescape(document.cookie.toString());
- }
- function createCookie(name,value,days)
- {
- if (days)
- {
- date.setTime(date.getTime()+(days*24*60*60*1000));
- var expires = "; expires="+date.toGMTString();
- }
- else var expires = "";
- document.cookie = name+"="+value+expires+"; path=/";
- return "Cookie created.";
- }
- function readCookie(name)
- {
- var nameEQ = name + "=";
- var ca = document.cookie.split(';');
- for(var i=0;i < ca.length;i++)
- {
- var c = ca[i];
- while (c.charAt(0)==' ') c = c.substring(1,c.length);
- if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length,c.length);
- }
- return null;
- }
- function eraseCookie(name)
- {
- createCookie(name,"",-1);
- }
FlashDevelop3 R2 and the Flex 3.3 SDK video tutorial Part 03: Events, Interactivity, and Timer: the new setInterval.
by Brian Hodge on Mar.21, 2009, under Actionscript 3.0, FlashDevelop, Flex SDK
In part 03, first we talk about why the document class extends Sprite or MovieClip, which FlashDevelop automatically imports Sprite into your project and extends your document class with it.
Second, we talk about waiting for the document class to be added to the stage, so that we make access properties of the stage.
Third, import the required event MouseEvent, to handle mouse interactivity. We setup an event listener for when the end-user has pressed the mouse down while over “_sprite”, the square we created in part 02 of this series. We handled the mouse event with a nice TweenLite driven animation of the “_sprite” object.
Fourth, we imported the two classes for handling keyboard interaction. KeyboardEvent is used to listen for for the key-based events, and the Keyboard class maintains a list of static constants representing unsigned integers used to compare against the keyCode available to the method listener for the KeyboardEvent dispatch.
Fifth, and finally, we talk about the Timer object, which is the new setInterval. Although you can still use setInterval in Actionscript3, I prefer the Timer object. Maybe I prefer Timer because of its use of the new event flow, im not sure; although I can say, that I like that you can stop and start it with built in methods. In this example, we instantiate a Timer object, set it to fire every 1000ms (1 second) and then we listen for that event to be dispatched every second, and have a function fire each time. The function that fires has a simple trace, that when tested, loops over and over in the console.
Stay tuned for part 04, coming soon!
