JSCompressor or a GIU for the YUI Compressor



No Comments

  • Share/Bookmark




jscompressor

While the whole world is on fire, i made a small air app which actually is a GUI for the yahoo’s YUI Compressor util.

About the YUI Compressor tool:

The YUI Compressor is written in Java (requires Java >= 1.4) and relies on Rhino to tokenize the source JavaScript file. It starts by analyzing the source JavaScript file to understand how it is structured. It then prints out the token stream, omitting as many white space characters as possible, and replacing all local symbols by a 1 (or 2, or 3) letter symbol wherever such a substitution is appropriate (in the face of evil features such as eval or with, the YUI Compressor takes a defensive approach by not obfuscating any of the scopes containing the evil statement) The CSS compression algorithm uses a set of finely tuned regular expressions to compress the source CSS file. The YUI Compressor is open-source, so don’t hesitate to look at the code to understand exactly how it works.



In short, YUI Compressor is a jar tool which compresses *.js files. Sure, u can use it through the command line as described here, however just give JSCompressor a try :)

Requirements:
AIR: 2.0 run-time installed (in case u don’t have it click here)
OS: win
Download: jscompressor.exe

ps: i just love making small apps is my spare time ^_^

AlignUtil – align objects easily



1 Comment

  • Share/Bookmark







Recently i had to align tons of UIComponents with scale and even rotation defined. And so, i decided to write a small static class that would really facilitate my life. I called it AlignUtil. That’s it for now. All links are listed bellow. Hope it helps someone. Cheers ^_^

ps: btw i decided to switch my devs license to MIT, so from now on u r free to use the source codes for whatever u want purpose.

Online demo
Download the AlignUtil class

And here’s the source code (in case u r 2 lazy to download the archive):


////////////////////////////////////////////////////////////////////////////////
//
//  Copyright 2010 Julius Loa | jloa@chargedweb.com
//  All Rights Reserved.
//  license:	MIT {http://www.opensource.org/licenses/mit-license.php}
//  notice: 	just keep the header plz
//
////////////////////////////////////////////////////////////////////////////////

package com.chargedweb.utils
{
	import flash.display.DisplayObject;
	import flash.geom.Rectangle;
	import flash.geom.Point;

	/**
	 * <p>AlignUtil class - vertical/horizontal align DisplayObjects</p>
	 * @author			Julius Loa aka jloa, jloa@chargedweb.com
	 * @availability 	flash/flex, as3
	 * @version 		1.0
	 *
	 * <p>Class usage:</p>
	 * @example Flex sample:
	 * <listing version="3.0">
	 * import com.chargedweb.utils.AlignUtil;
	 *
	 * var btn:Button = new Button();
	 * btn.x = 100;
	 * btn.y = 100;
	 * btn.width = 100;
	 * btn.height = 30;
	 * btn.rotation = 30;
	 * addChild(btn);
	 *
	 * AlignUtil.setAlign(AlignUtil.H_CENTER, btn, this);
	 * AlignUtil.setAlign(AlignUtil.V_MIDDLE, btn, this);
	 * </listing>
	 */
	public class AlignUtil
	{
		/** Horizontal left alignment **/
		public static const H_LEFT:String = "horizontalLeft";
		/** Horizontal center alignment **/
		public static const H_CENTER:String = "horizontalCenter";
		/** Horizontal right alignment **/
		public static const H_RIGHT:String = "horizontalRight";

		/** Vertical top alignment **/
		public static const V_TOP:String = "verticalTop";
		/** Vertical middle alignment **/
		public static const V_MIDDLE:String = "verticalMiddle";
		/** Vertical bottom alignment **/
		public static const V_BOTTOM:String = "verticalBottom";

		/**
		 * Applies a specified alignment to the target DisplayObject
		 * @param	align:String			alignment mode (see the public constants defined above)
		 * @param	target:DisplayObject	target DisplayObject to align (according to the set alignment mode) @see flash.display.DisplayObject
		 * @param	parent:DisplayObject	the parent DisplayObject of the target one @see flash.display.DisplayObject
		 * @return	nothing
		 */
		public static function setAlign(align:String, target:DisplayObject, parent:DisplayObject):void
		{
			var a:String = align; var t:DisplayObject = target; var p:DisplayObject = parent;
			var b:Rectangle = t.transform.pixelBounds;
			var bp:Point = p.globalToLocal(new Point(b.x, b.y));
			b.x = bp.x; b.y = bp.y;
			if(a == H_LEFT) t.x = (t.x > b.x) ? t.x - b.x : 0;
			if(a == H_CENTER) t.x = int((p.width - b.width)/2 + t.x - b.x);
			if(a == H_RIGHT) t.x = (t.x > b.x + b.width) ? p.width : p.width - (b.x + b.width - t.x);
			if(a == V_TOP) t.y = (t.y > b.y) ? t.y - b.y : 0;
			if(a == V_MIDDLE) t.y = int((p.height - b.height)/2 + t.y - b.y);
			if(a == V_BOTTOM) t.y = (t.y > b.y + b.height) ? p.height : p.height - (b.y + b.height - t.y);
		}
	}
}

Flash on apple devices, finally?



6 Comments

  • Share/Bookmark




The European Union’s new Digital Agenda, an ambitious program of incentives and legislation designed to improve access to technology across the EU, could force companies such as Apple to open up their businesses by requiring them to offer more interoperability and use open standards. It could force more openness even if those companies are not the dominant player in a specific market, because the language in the EU Agenda says that such measures could apply merely to “significant” players in a market — broadening the scope of previous antitrust rules substantially.

Could that be true? Flash player support on i-devices, really? Or just another rumor?

more info here => http://bit.ly/abeBdC

ps: 0k, that’s it guys. I’m fed up with that apple stuff, let’s get back to development :)

Flash on the iPad



1 Comment

  • Share/Bookmark




Well, finally someone’d found some courage to stop Steve’s flash rage :)

Frash is a port of the Adobe Flash runtime for Android to the iPhone, using a compatibility layer, by comex (http://twitter.com/comex). Frash can currently run most Flash programs natively in the MobileSafari browser. Frash currently only runs on the iPad, but support for other devices (3GS+ only due to technical restrictions) is planned, as well as support for iOS 4.

A release is planned for when Frash is stable. Developers are welcome to join the effort at http://github.com/comex/frash – fork it and send a pull request with your patches.

Frash uses a multi-process model similar to Chrome on the desktop, so a crash in the Frash/Flash plugin doesn’t take down the browser. You can see this while I’m playing Alien Hominid: the ad above crashed (probably a Frash bug), but Safari stays open just fine, and continues to play other Flash content on the page.

Video and keyboard input are currently not supported. The former will require major reverse engineering of the video decoding frameworks on the iPhone, but the latter should be reasonably easy to implement.

…and if anyone from Adobe reads this: Hosting the libflashplayer.so binary somewhere accessible outside the Android Market would make this a lot easier to distribute :) .

Shot on an iPhone 4 and edited using iMovie on the phone.

ps: muhaha, i told u Steve that yr rage was useless ;)

js tooltip



No Comments

  • Share/Bookmark




+




Well, i’m not a js-developer actually, however i had to write a small tooltip in js 2day and i thought that some of you would probably find it usefull. Won’t post the source code here this time, but the demo and source archive are still available @see the links below.

  • Lightweight
  • Supports basic fade effects
  • Easy to use
  • Uses external png graphics
  • Supports html
  • Works in all browsers

Check out the online demo or grab the source files

ps: thx DryIcons for the icon.

Realaxy actionscript editor finally shipped



4 Comments

  • Share/Bookmark







Yes, guys, finally realaxy is out for download :)
Btw it supports win/mac/linux. And guess what, it’s free !
Ain’t that awesome? Profit!


html5 almost ready?



1 Comment

  • Share/Bookmark




Did you know that there’s a some sort of a html5 fan club?
Why am i telling you this? Because there’s a sort of a timer telling when will html5 be fully released check it http://ishtml5readyyet.com/ :)

ps: only 12 more years still to go…

flash vs html5 on nexus one



4 Comments

  • Share/Bookmark




Just sit back and watch ^_^

ps: So, where did the great html5 performance go? :)

csv, xls and utf8 fail



2 Comments

  • Share/Bookmark




In case u need to save utf8 data to a csv or xls file, mind that those formats do not support utf8 encoding.
Say, u’ve got to save a cyrillic text to a csv file:


// A sample cyrillic, bulgarian text, for exmaple
var utf8String:String = "Аз съм българче. Обичам наште планини зелени...";

// Try to save the file in utf8 charset and then
// open it with Microsoft Excel
var file:FileReference = new FileReference();
file.save(utf8String, "utf8_test.csv");

And here’s the result:

But don’t hurry to google for an as3 charset encoding library, as there’s a simple way to solve this issue:


// A sample cyrillic, bulgarian text, for exmaple
var utf8String:String = "Аз съм българче. Обичам наште планини зелени...";

// csv, xls appear to work only with the ascii
// and windows-like charsets, so as the string is
// cyrillic, we'll use the cyrillic (Windows) charset 'windows-1251'
// which codename's 'x-cp1251' according to the adobe's as3 reference.
var bytes:ByteArray = new ByteArray();
bytes.writeMultiByte(utf8String, "x-cp1251");

var file:FileReference = new FileReference();
file.save(bytes, "cp1251_test.csv");

Now we got the expected result:


Really simple, but still there might be someone who’d need it.

ResourceMonitor v2 = ResourceMonitorUtil [updated to 2.1]



8 Comments

  • Share/Bookmark




UPD: i’ve updated the class to version 2.1, fixed some bugs, added new features, switched the license to MIT !


yellow – current fps
cyan – current memory usage
red – max memory usage graph

As lots of you asked me to add some new features like the font color changing, performance increasement etc, i decided to make a new version of the ResourceMonitor class. I’ve added a few new features, made the code more ammm more readable (well, it’s an os class, so probably u’d like to edit smth there) and i’ve even made a documentation this time :)
And i also decided to rename it to ResourceMonitorUtil.

Class usage also has shorten.

Flex:


import com.chargedweb.utils.ResourceMonitorUtil;

rawChildren.addChild(new ResourceMonitorUtil());

Flash:


import com.chargedweb.utils.ResourceMonitorUtil;

addChild(new ResourceMonitorUtil());

Blah-blah-blah, just let me download the ResourceMonitorUtil source code already

Read more

Older Entries