Oh hi there!

Posted By Thaylin on June 3, 2014

It’s been a while and I’ve been a busy bee. From canvas stuff with EaselJS to developing multi-platform games from Flambe in HaXe I’ve been learning all sorts of new things. I’ll be posting new tidbits of info and nuances about these things that I’ve been learning over the past year and hopefully it’ll help those of you who are new to this sort of development out! Unfortunately, I’ll need to kill my comments until I can update the site to have a better prevention of spam. I logged in and found 53,000 spam comments! Holy cow!

Helpful snippet for me at the moment

Posted By Thaylin on May 9, 2012

Here’s a handy little code snippet. Need to append the placement of a number? Use this!

?View Code ACTIONSCRIPT
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
private function getNth (num:Number):String
		{ 
			var qn:int = ((num%100) / 10); 
			var rn:int = num % 10; 
 
			var suffix:String = "th"; 
 
			if (qn != 1) { 
				switch (rn) { 
					case 1: suffix = "st"; break; 
					case 2: suffix = "nd"; break; 
					case 3: suffix = "rd"; break; 
				} 
			} 
 
			return num + suffix; 
		}

Seeing the android API source code

Posted By Thaylin on December 7, 2011

So looking for all sorts of random things for my current android project I ran across Google Code search.
Holy toledo is it great to be able to see the logic (or seemingly illogical things in some cases) that google has behind their APIs.
Check out some of the android source HERE

Damn handy! Though it makes me a little more than irritated to see that there’s the ability within the android SDK to set a ScrollView’s smoothScrollTo speed but not externally. Unless I’m missing something. At which point I will post it! ^.^

Android timer stuff

Posted By Thaylin on December 6, 2011

Wow, it’s been a while since I’ve last posted!

Just wanted to toss up some code for creating a timer in android. One would think you would just utilize the java.utils.Timer class but that creates a new thread and can create issues with your application. Plus it’s a pain to access stuff from the timer. Android has an alternative to keep everything all together and it’s quite easy to implement.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
private Handler timerHandler;
private int timerTime = 5000; //in milliseconds
private void createTimer()
{
	timerHandler = new Handler();
 
}
private void startTimer()
{
	//resets timer and posts the delayed call
	rotationHandler.removeCallbacks(mUpdateTimeTask);
	rotationHandler.postDelayed(mUpdateTimeTask, timerTime);
}
private void stopTimer()
{
	rotationHandler.removeCallbacks(mUpdateTimeTask);
}
private Runnable mUpdateTimeTask = new Runnable()
{
	   public void run() {
	       //do your thing
 
		//repeat timer if you need to
		rotationHandler.postDelayed(this, timerTime);
 
	   }
};

code reviewing and tons of debugging info!

Posted By Thaylin on May 20, 2011

In the last month or so I’ve been tasked with reviewing a project for performance profiling and just code cleanup in general. It’s been quite a task as I wasn’t familiar with a single part of the code so finding tools to aid in this is uber helpful.

With that in mind, here are a few things I’ve found that are super awesomely helpful in case you come upon having to do the same thing:

Flex PMD – An awesome tool for quickly checking code for those little nitpicky things like unused variables, methods, etc. Not to mention finding not so great things that were done more than likely in a jam.

extra mm.cfg params – this one I just started messing with today and man are some of these super helpful! Especially AS3Trace=1. Holy toldeo! If you know what to look for (i.e. memory allocation table numbers representing certain objects) you can really track rouge code you’re unsure of to just about the start of it’s shenanigans.

Those are the two main things I’ve come across so far that have been great help to me. If I find anything more I’ll post.
Good luck and have fun wondering why some other coders did what they did like that!

Uploading multiple images/data to server!

Posted By Thaylin on April 8, 2011

Oh man what a life saver this was! Super easy to implement and works awesomely so far!

Multipart form data in as3 [Class version 1.2]

Implementing is as easy as this:

?View Code ACTIONSCRIPT
1
2
3
4
5
6
7
8
9
10
11
12
13
jpgEncoder = new JPGEncoder( 100 )			
 
var photo:ByteArray = jpgEncoder.encode( this.getBitmapData( photoBitmap) );
var thumbnail:ByteArray = jpgEncoder.encode( this.getBitmapData(thumbnailBitmap) );
 
var ml:MultipartURLLoader = new MultipartURLLoader();
ml.dataFormat = URLLoaderDataFormat.TEXT; // or whatever works for the response you receive back
 
ml.addEventListener(Event.COMPLETE, onSaveSucces);
ml.addVariable('someText', 'blah blah');
ml.addFile(photo, 'photo.jpg', 'photo');
ml.addFile(thumbnail, 'thumbnail.jpg', 'thumbnail');
ml.load('my/server/path/postImage.php');

For more info on how to set up the php just go to the link!

setting properties at runtime from xml or css

Posted By Thaylin on March 9, 2011

Mainly this is just a post to remind myself in later times about this code snippet but basically this will work with any class with accessible variables.

Take an xml node such as

1
<class id="myClass" color="#FF0000" isActive="false"/>

You can use this snippet to parse through those attributes to set all of your variables for you assuming they exist in your class.

?View Code ACTIONSCRIPT
1
2
3
4
5
6
7
8
9
public function setPropertiesFromXML(xmlNode:XML):void
{
	for each (var obj:XML in xmlNode.@*)
	{
		//check for hex color before setting
		var strValue:String = obj.toString().replace('#', '0x');
		if( hasOwnProperty(obj.name()) ) this[obj.name().toString()] = (strValue=="false") ? false : strValue;
	}
}

Flashbuilder 4 issues with generating components in Flash CS5

Posted By Thaylin on January 19, 2011

I ran into an issue today that was bugging the crap out of me. I kept trying to make graphical components within flash that I could use in a flex project I’m currently working on but whenever I would run the project after embedding them in my library swc I would get this error:

Illegal override of UIMovieClip in mx.flash.UIMovieClip

After trying to update the command that adobe provides for this I realized that for some reason the library that the component that gets generated by the command to store your library classes for flash integration in flex wasn’t the same that I was using in my project so it was having conflicts. So I deleted that generated component in my library and just pointed to my library I’m using in flashbuilder at “Applications/eclipse/Adobe Flash Builder 4 Plugin/sdks/4.1.0/frameworks/libs” and voila! Worked like a charm!

Hooray!

Nice conditional coding tip

Posted By Thaylin on May 13, 2010

Tyler from FCNY turned me on to a nice tip on conditional coding.

Let’s take for example we have a variable that we need to associate with another variable. For instance, we pull in some flashvars and need to check if these exist and if not give them a default value. Let’s look at a couple of the standard ways we can do this. (more…)

Handy code snippets plugin for Flex/Eclipse

Posted By Thaylin on April 7, 2010

For all of those unaware of snippets, these are code shortcuts to increase coding productivity and are damn handy. For an extended idea of what you can do with these visit this blog post I ran across:

On a side note, the poster doesn’t tell you how to install CFEclipse so I’ll just touch on that real quick so you can use these as your reading the blog post. In Eclipse (assuming 3.4.2 Ganymede), go to help>software updates>Available Software – click on Add Site, add http://www.cfeclipse.org/update, select CFEclipse CFML Editor and choose the latest build. Choose to install and follow the prompts. Once you have that installed you’ll be able to access the Snippet Tree View by going to Window>Show View>Other and opening the CFML folder. There you’ll see the Snippet Tree View. Then visit the blog link below and enjoy using wonderful shortcuts!

[link]http://blog.mxunit.org/2009/04/timesavers-cfeclipse-snippets.html[/link]