Category Archives: Action Script

so..

For a long time, I couldn’t post anything to my blog. We’re very busy with the works in Filika Design (check out our web site). And I’m trying to gain my coding skills on different coding enviroments like c++, unity and java-Javascript…

I think, I leave actionscript  in web design works. We have to think about mobile devices. And it’s sad for me to say this but, there is no way to use flash on mobile devices. However, action script is still my special power while programming multitouch apps, generative visuals and kinect based applications…

On the flash side, I’m busy with the new Starling Framework which uses gpu instead of system memory and cpu power. You should check it out if flash is your favourite coding platform 🙂

Some works from Filika Design;

– First video is Aqua Koridor : 12 x 8 m led screen,sonar sensors to track viewers’ coordinates, arduino board parses input data and send them to processing to create interactive visuals.

– Second video is floor projection application. However, it’s working with Kinect+Adobe Air. So, it’s very powerful from conventional floor projection techniques. We chose Kinect. Because, it isn’t affected by light sources, it uses infrared ligth to get infromations like depth, x,y and z position of the objects. So, ambient or spotlights in the venue don’t affect our application or calibration values.


Font Embed Bug on Flash Builder 4.5

Embedding fonts in Flash Builder is so easy as follows. However, in some cases that I have no idea, Flash Builder changes the fonts in your application. To fix that, just goto topbar Project->Clean…Then Flash Builder refreshes your project and everything is gonna be fine 🙂 This is just a reminder for myself. I’m sure, I’ll forget the fix for this issue when I exprience it again.

[Embed(source="com/alptugan/assets/font/HelveticaNeueLTPro-Roman.otf", embedAsCFF="false", fontName="roman", mimeType="application/x-font")]
public var Roman:Class;

[Embed(source="com/alptugan/assets/font/HelveticaNeueLTPro-Bd.otf", embedAsCFF="false", fontName="helvetica-bold", mimeType="application/x-font")]
public var Bold:Class;

[Embed(source="com/alptugan/assets/font/HelveticaNeueLTPro-ThCn.otf", embedAsCFF="false", fontName="helvetica-thin", mimeType="application/x-font")]
public var Thin:Class;

image processing on Rothko’s pieces

I’ve been thinking about to recreate visuals from Rothko’s artworks for a long time. But, I couldn’t have free time for it, because of freelance jobs 🙂 Anyway, finally I’ve coded a part of the application with action script of course. Basically, main app reads every single pixel of the image horizontally and vertically, then create particals according to the pixel’s values of the image. I’ll add some feature’s to the application latter. For now, it creates only jpgs from processed image. Original image belongs to Rothko – Ochre and Red on red (1954)

List of XML and HTML character entity references

Quick post for myself 🙂 While I’m writing xml files, always always forget how to type entities. Here is the link from wikipedia

Sometimes, in xml attributes I need to use “&” character, but it can be problematic. And, I can’t find any solution for this issue. We can use  <![CDATA[ ]]> for xml nodes, but not for attributes. So for me the only possible way is to use character entities. eg:

//in xml node
<content><![CDATA[me & others]]></content>

//in xml node
<content title="me amp&; other"/>

	

Quick Tip – Return Vector Array


If you try to return a Vector typed array in flash, you’ll get the following error.

public function getMainItems():Vector
{
	//Length of Main items
	MainItemLn = xml.item.length();

	//Vector class of MainItems
	var MainVO:Vector     = new Vector.<VOItem>(MainItemLn,true);

	for(var i:int = 0; i < MainItemLn; ++i)
	{
		MainVO[i]        = new VOItem();
		MainVO[i].id     = i;
		MainVO[i].title  = xml.item[i].@title;
		MainVO[i].img = xml.item[i].@img;
	}

	return MainVO
}

1067: Implicit coercion of a value of type __AS3__.vec:Vector.<com.Gallery:VOItem> to an unrelated type __AS3__.vec:Vector.

It is because Vector.<VOItem> isn’t the same type as Vector. That means;

public function getMainItems():Vector.<VOItem>
{
	//Length of Main items
	MainItemLn = xml.item.length();

	//Vector class of MainItems
	var MainVO:Vector     = new Vector.<VOItem>(MainItemLn,true);

	for(var i:int = 0; i < MainItemLn; ++i)
	{
		MainVO[i]        = new VOItem();
		MainVO[i].id     = i;
		MainVO[i].title  = xml.item[i].@title;
		MainVO[i].img = xml.item[i].@img;
	}

	return MainVO
}

And you can get your Vector array values like;

trace(getMainItems()[0].title);
//or
trace(getMainItems()[1].title);
//and so on..
.
.
.

**Note: VOItem is my custom Value Object Class. It doesn’t matter what it is. It can be movieclip, sprite, etc…

Some Usefull Shorcuts for Flex/Flash Builder

Sometimes, looking for some variable or function in the program can be very hard find. For me, this issue always distracts my focus on application. Or, I can be very lazy to comment out /* */ some code block. Anyway, I would like to tell you some of the life and time savers of the shorcuts that I’m using frequently.

1. Cmd + Shift + O: Removes all of the unused imports from your file.

2. Cmd + Shift + C: Comments out the selected block or line with /* */ chars.

3. Control + Alt + H: I think this is the most wonderful one. Searches the selected function name in your project and lists all of them line by line.

4. Cmd + M : Maximizes Flash Builder/Flex window to view only editor window. You can switch back to previous view with the same shortcut also.

5. Cmd + L : When you type this. A little pop-up appears and asks you to type a line number. When you type the number and hit enter, it jumps directly to this line.

6. Cmd + Left Mouse Click : e.g, you have an instance name like “foo”. But you forgot the decleration of the variable. To find the decleration, just press Cmd and move mouse pointer onto “foo”. Then “foo” turns to “foo” underlined in blue color. If you click on it, you will jump directly to the decleration of the variable. Besides that, if you click onto decleration while holding down Cmd key, action Script class of the decleration will be opened in the editor.

7. Control + Tab: Switches between editors/tabs.

8. Cmd + O: Shows you all of the vars, function, methods, etc… in the class. And you search specific names from the opened window.

Please note if I am missing another usefull shortcut.
By the way, there is also a shorcut to view all of the showtcuts 🙂
Cmd + Shift + L