ActionScript 4 required or a method from the future



4 Comments

Share







While surfing the flex docs i bumped into this method.
Btw, as4 is not just a rumor as the ecma4 development still continues.

ps: sry for the late update, i’ve got tons of projects… :(

JSCompressor or a GIU for the YUI Compressor



1 Comment

Share




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



12 Comments

Share




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

UPDATE: class updated to v.1.3

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


////////////////////////////////////////////////////////////////////////////////
//
//  (c) 2011 Julius Loa | jloa[u know wha]chargedweb.com | http://chargedweb.com/labs/
//  All Rights Reserved.
//  license:	MIT {http://www.opensource.org/licenses/mit-license.php}
//  notice: 	just keep the header plz
//
////////////////////////////////////////////////////////////////////////////////

package com.chargedweb.utils
{
/** fp api **/
import flash.display.DisplayObject;
import flash.text.TextField;
import flash.geom.Rectangle;
import flash.geom.Point;

/**
* <p>AlignUtil class - vertical/horizontal align DisplayObjects</p>
* @availability 	fp9 (flash/flex, as3)
* @version 		1.3
*
* <p>Class usage:</p>
* @example using parentalRelation set to "true" (aligning children inside the "parent")
* <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>
*
* @example using parentalRelation set to "false" (aligning children according to another child on the same level)
* <listing version="3.0">
* import flash.display.Shape;
* import com.chargedweb.utils.AlignUtil;
*
* function createBox(w:Number, h:Number, r:Number):Shape
* {
* 	var sp:Shape = new Shape();
*	sp.graphics.beginFill(Math.random()*0xffffff);
*	sp.graphics.drawRect(0, 0, w, h);
*	sp.graphics.endFill();
*	sp.rotation = r;
*	return sp;
* }
*
* var a:Shape = createBox(200, 200, 45);
* a.x = 200; a.y = 100;
* addChild(a);
*
* var b:Shape = createBox(50, 20, -10);
* b.x = 50; b.y = 200;
* addChild(b);
*
* var c:Shape = createBox(120, 75, 150);
* c.x = 300; c.y = 200;
* addChild(c);
*
* // align 'b','c' according to 'a' (horizontal-left and vertical-top alignment)
* // horizontally
* AlignUtil.setAlign(AlignUtil.H_LEFT, b, a, false);
* AlignUtil.setAlign(AlignUtil.H_LEFT, c, a, false);
* // now vertically
* AlignUtil.setAlign(AlignUtil.V_TOP, b, a, false);
* AlignUtil.setAlign(AlignUtil.V_TOP, c, a, false);
* </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
* @param	parentalRelation:Boolean	whether the "target" DisplayObject is a child of the "parent" or not @default true;
* @return	nothing
*/
public static function setAlign(align:String, target:DisplayObject, parent:DisplayObject, parentalRelation:Boolean = true):void
{
var a:String = align;
var t:DisplayObject = target;
var p:DisplayObject = parent;
var b:Rectangle = t.transform.pixelBounds;
var tp:Point = new Point();
var bp:Point;

/**
* @note 28/03/2011 :: bug fix for TextFields :: tip by Arindam Mojumder
* TextField.transform.pixelBounds return incorrect x/y coordinates (not the actual, but rather
* the one of the transform point) and the x/y are always 'zero' valued, so we make an exception for tfs
*/
if(t is TextField) b = t.getBounds(t.parent);

/** if parentalRelation is enabled, use local coordinates **/
if(parentalRelation)
{
bp = p.globalToLocal(new Point(b.x, b.y));
b.x = bp.x;	b.y = bp.y;
}else{
tp = new Point(p.transform.pixelBounds.x, p.transform.pixelBounds.y);
}

if(a == H_LEFT) t.x = (t.x > b.x) ? tp.x + t.x - b.x : tp.x;
if(a == H_CENTER) t.x = tp.x + int((p.width - b.width)/2 + t.x - b.x);
if(a == H_RIGHT) t.x = (t.x > b.x + b.width) ? tp.x + p.width : tp.x + p.width - (b.x + b.width - t.x);
if(a == V_TOP) t.y = (t.y > b.y) ? tp.y + t.y - b.y : tp.y;
if(a == V_MIDDLE) t.y = tp.y + int((p.height - b.height)/2 + t.y - b.y);
if(a == V_BOTTOM) t.y = (t.y > b.y + b.height) ? tp.y + p.height : tp.y + p.height - (b.y + b.height - t.y);
}
}
}

Flash on apple devices, finally?



7 Comments

Share




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




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



13 Comments

Share




+




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



10 Comments

Share







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




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



6 Comments

Share




Just sit back and watch ^_^

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

csv, xls and utf8 fail



4 Comments

Share




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.

Older Entries Newer Entries