After installing Virtual Box and getting windows set up I realized the drive was way to small. I tried looking for an easy way to resize the drive but many of them required booting into linux and using a boot manager to copy the contents from one drive to the other.
I finally found a tutorial that uses a command line tool that comes with Virtual Box. Worked like a charm. Hope this saves you some time.
Resize An Existing .vdi Virtualbox Image – EASILY! By Gregory Milby
Google analytics code
Friday, December 3, 2010
Tuesday, October 19, 2010
PHP: bCalendar - Free PHP calendar with international support
I've been working on a calendar class for awhile now and I've decided to release it to the public. I've refactored the class quite a bit so the names and methods make since. It's PHP5 compatible, very skinable, supports multiple languages and comes with documentation. You can download the project here.
Here is a quick example of how to set it up. You can view a running copy here.
There are other properties that control the formatting of the month, year and day on the display. Those are outlined in the documentation under Variable Summary. If you have any questions of feedback please let me know in the comments. Also if you use it in a project let me know. It would be cool to see how people use it.
Here is a quick example of how to set it up. You can view a running copy here.
// Update the language by using setLocal //setlocale(LC_ALL, 'Japanese'); // Include the calendar class include_once "classes/class.bCalendar.php"; // Create the class. The first option is the URL the navigation will use. The second is the path to the css file. The third is the date for the calendar to start on. The last determines which day the calendar will start on. $obj_cal = new bCalendar("index.php","css/calStyle.css", null, 1); #################### # Optional methods #################### // Set the range of the date picker combobox $obj_cal->setComboboxYearRange(2000,2010); // Add a date to the calendar $obj_cal->addEvent("10/19/2010", "This is a test event"); // Link a date on the calendar to a url $obj_cal->linkDate("10/15/2010", "http://google.com"); // Change the behavior of the date picker to not snap to the current date $obj_cal->setComboBoxToCurrentDate(false); // Change the order of the calendar header $obj_cal->setCalendarHeader(array(bCalendar::CAL_PREVIOUS_MONTH, bCalendar::CAL_MONTH_YEAR, bCalendar::CAL_SELECTOR, bCalendar::CAL_NEXT_MONTH)); #################### # Optional methods #################### // Draw the calendar $obj_cal->drawCalendar();
There are other properties that control the formatting of the month, year and day on the display. Those are outlined in the documentation under Variable Summary. If you have any questions of feedback please let me know in the comments. Also if you use it in a project let me know. It would be cool to see how people use it.
Friday, September 24, 2010
Flex : HTML tooltip made simple
I'm currently working on a project that required a fancy looking tooltip. Unfortunately the native tooltip object in Flex doesn't support htmltext. By accident I found out that a swc I was trying to use (Libagic) for a Edit-In-Place TextInput included a class you can use to override ToolTip called HTMLToolTip. You can read about it here. Right-click on the flex example at the bottom of his post to view the source.
Saturday, August 21, 2010
Android : Pixelpipe unable to post video to facebook
I ran into an odd issue where PixelPipe wouldn't let me upload a video from my phone, but it would still upload pictures. I tried reauthorizing the facebook pipe on their website but it didn't help. I tried creating a new pipe and uploading through that and it still didn't work. What finally fixed the issue is reauthorizing the facebook pipe on the phone through the app.
Open Pixelpipe and goto the settings tab. Press the "Edit pipes" button.
This will take you to the list of pipes on your account. Press the combobox for facebook and press "change settings".
Scroll to the bottom of this page and press "Reauthorize this account".
It will ask for your facebook username and password. You might get dumped to a white screen with nothing on it. If this happens press the "back" device button and you should return to the Settings tab. Go back to the facebook pipe and check to see that the pipe has access to your account.
Open Pixelpipe and goto the settings tab. Press the "Edit pipes" button.
This will take you to the list of pipes on your account. Press the combobox for facebook and press "change settings".
Scroll to the bottom of this page and press "Reauthorize this account".
It will ask for your facebook username and password. You might get dumped to a white screen with nothing on it. If this happens press the "back" device button and you should return to the Settings tab. Go back to the facebook pipe and check to see that the pipe has access to your account.
Tuesday, July 13, 2010
Flex / ActionScript: Debugging causes Firefox to crash
After an update to Firefox 3.6.6 I've noticed that while debugging Flash it would crash and display "The Adobe Flash plugin has crashed". It turns out it's due to a new feature called "Hang Protection" that allows Flash to run in it's own sandbox and not take down the whole browser when/if it crashes. After 45 seconds the browser will close Flash because it thinks Flash has stopped responding.
Hang Protection can be turned off so debugging with Flex Builder / Flash Builder will work properly. Follow the directions at this url.
NOTE
Firefox 4 requires a change to a different property. Use about:config to alter the behind the scenes settings and look for dom.ipc.plugins.timeoutSecs and set it to -1.
Hang Protection can be turned off so debugging with Flex Builder / Flash Builder will work properly. Follow the directions at this url.
NOTE
Firefox 4 requires a change to a different property. Use about:config to alter the behind the scenes settings and look for dom.ipc.plugins.timeoutSecs and set it to -1.
Tuesday, April 13, 2010
Flex / ActionScript: Copy an ArrayCollection
While working with an ArrayCollection I ran into a issue. It seems when you set one ArrayCollection equal to another they share memory space. This can cause issues when you perform any operation that will alter the internal array.
The simple solution for this is to always create a new ArrayCollection for the target using the toArray method from the source.
Those post is based on findings from this blog post.
var arrayCollection1:ArrayCollection = new ArrayCollection([1,2,3,4,5]); var arrayCollection2:ArrayCollection = arrayCollection1; trace("arrayCollction1: " + arrayCollection1.toString()); trace("arrayCollction2: " + arrayCollection2.toString()); arrayCollection1.removeItemAt(0); trace("arrayCollction1: " + arrayCollection1.toString()); trace("arrayCollction2: " + arrayCollection2.toString());
Output: arrayCollection1: 1,2,3,4,5 arrayCollection2: 1,2,3,4,5 arrayCollection1: 2,3,4,5 arrayCollection2: 2,3,4,5
The simple solution for this is to always create a new ArrayCollection for the target using the toArray method from the source.
var arrayCollection1:ArrayCollection = new ArrayCollection([1,2,3,4,5]); var arrayCollection2:ArrayCollection = new ArrayCollection(arrayCollection1.toArray()); trace("arrayCollection1: " + arrayCollection1.toString()); trace("arrayCollection2: " + arrayCollection2.toString()); arrayCollection1.removeItemAt(0); trace("arrayCollection1: " + arrayCollection1.toString()); trace("arrayCollection2: " + arrayCollection2.toString());
Output: arrayCollection1: 1,2,3,4,5 arrayCollection2: 1,2,3,4,5 arrayCollection1: 2,3,4,5 arrayCollection2: 1,2,3,4,5
Those post is based on findings from this blog post.
Labels:
actionscript,
actionscript3,
array,
arraycollection,
as,
as3,
coipy,
flex,
toarray
Friday, March 19, 2010
Flash / ActionScript 3: Singleton Example
Singletons are a design pattern that allows you to share one instance of a class throughout a application. An example of where a singleton is useful is when you only want one and only one connection to a database. It also allows you to keep memory usage down because there is only one copy in memory.
I've created a sample ActionScript project that shows how a singleton can be used. You can download it here.
Here is what the files look like.
Singleton_Example.as
ExampleSingleton.as
ExampleClass.as
Lets start with ExampleSinglton.as. The important parts of this class are the _instance member variable, the instance getter method and the ExampleSingleton constructor.
The constructor takes a SingletonLock class argument as a locking precaution. This class is defined at the bottom of the ExampleSingleton package. This allows us to control the way the class is created. The _instance member variable is where we create the instance of the ExampleSingleton. The ExampleSingleton constructor should check to make sure the lock argument is a SingletonLock class and throw an error if it isn't. The error you throw should let the person know how to properly access the singleton.
ExampleSingleton.initialize is where some basic values are set up that are accessed in the rest of the project.
Now lets look at Singleton_Example.as. When we create the singleton variable we access the .instance property of the class. This will return the single instance of ExampleSingleton.
ExampleClass.as also uses the ExampleSingleton class. You'll see how setting a property on ExampleSingleton in Singleton_Example is reflected in ExampleClass and vice versa.
I've created a sample ActionScript project that shows how a singleton can be used. You can download it here.
Here is what the files look like.
Singleton_Example.as
package { import flash.display.Sprite; import Singleton.ExampleSingleton; import classes.ExampleClass; public class Singleton_Example extends Sprite { public function Singleton_Example() { //init the Singleton by grabbing an instance of it var singleton:ExampleSingleton = ExampleSingleton.instance; var exampleClass1:ExampleClass; //set the flag singleton.flag = ExampleSingleton.FLAG1; //show the current state of the flag trace("flag state: " + singleton.flag); //creating this class will update the flag in the singleton exampleClass1 = new ExampleClass; //the flag should be updated now trace("flag state: " + singleton.flag); //update the flag here singleton.flag = ExampleSingleton.FLAG3; //make the class display the state exampleClass1.displayFlagState(); } } }
ExampleSingleton.as
package Singleton { public class ExampleSingleton { //a set of dummy values used to explain how a Singleton is manuplated public static const FLAG1:String = "value1"; public static const FLAG2:String = "value2"; public static const FLAG3:String = "value3"; public static const FLAG4:String = "value4"; //this is the only instance of the class private static const _instance:ExampleSingleton = new ExampleSingleton(SingletonLock); //list of allowed values that can be set for the flag private var _allowedValues:Array = []; //state of the flag private var _flag:String = ""; //this will control wither the Singleton is really to be accessed private var _initialized:Boolean = false; /** * Use this to return an instance of the singleton * @return * */ public static function get instance() : ExampleSingleton { return _instance; } /** * Query the Singleton to see if it's ready to be accessed * @return * */ public function get initialized() : Boolean { return _initialized; } /** * Return the current flag * @return String * */ public function get flag() : String { return _flag; } /** * Set the flag state * @param value * @return Boolean * */ public function set flag(value:String) : void { //make sure the Singleton is initialized first if(!_initialized) { return; } //check to make sure it's an allowed value before setting it if(_allowedValues.indexOf(value) == -1) { return; } //update the flag _instance._flag = value; } /** * This will initialize the Singleton. It's never publicly called. Use ExampleSingleton.instance instead * @param lock * */ public function ExampleSingleton(lock:Class) { if(lock != SingletonLock) { throw new Error("Invalid ExampleSingleton access. Use ExampleSingleton.instance"); } initialize(); } /** * This is where you would set up anything the Singleton needed before it should be accessable to the public * */ private function initialize() : void { //we only need to initialize once. if(_initialized) { return; } //set up what we allow the flag to be _allowedValues = [FLAG1, FLAG2, FLAG3, FLAG4]; _initialized = true; } } } //this is used to lock the Singleton class SingletonLock{}
ExampleClass.as
package classes { import Singleton.ExampleSingleton; public class ExampleClass { public function ExampleClass() { //update the flag in the Singleton. we don't need to create a var to update it ExampleSingleton.instance.flag = ExampleSingleton.FLAG2; } /** * This will display the current flag from the Singleton * */ public function displayFlagState() : void { trace("flag state from ExampleClass: " + ExampleSingleton.instance.flag); } } }
Lets start with ExampleSinglton.as. The important parts of this class are the _instance member variable, the instance getter method and the ExampleSingleton constructor.
The constructor takes a SingletonLock class argument as a locking precaution. This class is defined at the bottom of the ExampleSingleton package. This allows us to control the way the class is created. The _instance member variable is where we create the instance of the ExampleSingleton. The ExampleSingleton constructor should check to make sure the lock argument is a SingletonLock class and throw an error if it isn't. The error you throw should let the person know how to properly access the singleton.
ExampleSingleton.initialize is where some basic values are set up that are accessed in the rest of the project.
Now lets look at Singleton_Example.as. When we create the singleton variable we access the .instance property of the class. This will return the single instance of ExampleSingleton.
ExampleClass.as also uses the ExampleSingleton class. You'll see how setting a property on ExampleSingleton in Singleton_Example is reflected in ExampleClass and vice versa.
Friday, March 12, 2010
ActionScript: The difference between "FOR IN" and "FOR EACH"
I ran into an issue earlier while looping through a list of objects where I couldn't get the index of the array I was accessing. Turns out there is a BIG difference between FOR and FOR EACH. Coding late at night probably didn't help either.
FOR EACH gives you access to the element in the array. FOR gives you access to the index of the array.
The output from FOR loop looks like this:
The output from FOR EACH looks like this:
Hopefully this helps someone from blunt force trauma caused by baning your head against the desk. Probably common knowledge for most, but it never hurts to post it.
FOR EACH gives you access to the element in the array. FOR gives you access to the index of the array.
var elements:Array = [{name:'Orange'}, {name:'Apple'},{name:'Banana'},{name:'Pear'}]; for(var i:Object in elements) { trace("index: " + i); } for each(var e:Object in elements) { trace("element: " + e.name); }
The output from FOR loop looks like this:
index: 0 index: 1 index: 2 index: 3
The output from FOR EACH looks like this:
element: Orange element: Apple element: Banana element: Pear
Hopefully this helps someone from blunt force trauma caused by baning your head against the desk. Probably common knowledge for most, but it never hurts to post it.
Labels:
actionscript,
actionscript3,
as,
as3,
for,
for each,
foreach,
loop,
looping
Monday, March 1, 2010
Flash / Flex / ActionScript: Using IResponder instead of EventListeners
Using addEventListener is a popular way of waiting for a response from a server. I've run into issues using this when a server returns the same response for all methods. Many of the listener methods are tripped for the wrong response. The easy way to avoid this is to use an IResponder.
Here is an example using the HTTPService object. You should be able to use the same steps on a method that returns an AsyncToken.
When send is called it will return an AsyncToken. We can attach an IResponder object to the AsyncToken that will handle the success and fail cases for the response.
Here is an example using the HTTPService object. You should be able to use the same steps on a method that returns an AsyncToken.
var asyncToken:AsyncToken; var internalIResponder:IResponder; ... asyncToken = _httpService.send(); internalIResponder = new AsyncResponder(onHTTPServiceSuccess, onHTTPServiceFault, asyncToken); asyncToken.addResponder(internalIResponder);
When send is called it will return an AsyncToken. We can attach an IResponder object to the AsyncToken that will handle the success and fail cases for the response.
Subscribe to:
Posts (Atom)