﻿<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>blog.mattiasnorell.com &#187; Air</title>
	<atom:link href="http://blog.mattiasnorell.com/category/air/feed/" rel="self" type="application/rss+xml" />
	<link>http://blog.mattiasnorell.com</link>
	<description>Otukt i otakt</description>
	<lastBuildDate>Tue, 07 Feb 2012 22:58:13 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3</generator>
		<item>
		<title>Flash on the beach</title>
		<link>http://blog.mattiasnorell.com/2010/08/16/flash-on-the-beach/</link>
		<comments>http://blog.mattiasnorell.com/2010/08/16/flash-on-the-beach/#comments</comments>
		<pubDate>Mon, 16 Aug 2010 19:38:56 +0000</pubDate>
		<dc:creator>Mattias</dc:creator>
				<category><![CDATA[ActionScript]]></category>
		<category><![CDATA[Air]]></category>
		<category><![CDATA[Flash]]></category>
		<category><![CDATA[Flex]]></category>
		<category><![CDATA[Two]]></category>
		<category><![CDATA[#nöjd]]></category>
		<category><![CDATA[flash on the beach]]></category>

		<guid isPermaLink="false">http://blog.mattiasnorell.com/?p=930</guid>
		<description><![CDATA[I flera år har jag velat åka. I år åker jag. Ni som vet vad &#8221;Flash on the beach&#8221; är vet att jag  inte behöver skriva en lång text för att förklara hur nöjd jag är över det. Det här &#8230; <a href="http://blog.mattiasnorell.com/2010/08/16/flash-on-the-beach/">Läs mer <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p><a href="http://static.mattiasnorell.com/blog/2010/08/fotb.jpg" rel="shadowbox[sbpost-930];player=img;" onclick="pageTracker._trackPageview('/outgoing/static.mattiasnorell.com/blog/2010/08/fotb.jpg?referer=');"><img class="alignnone size-full wp-image-931" title="Flash on the beach - Confirmation email" src="http://static.mattiasnorell.com/blog/2010/08/fotb.jpg" alt="" width="640" height="347" /></a></p>
<p>I flera år har jag velat åka. I år åker jag. Ni som vet vad &#8221;Flash on the beach&#8221; är vet att jag  inte behöver skriva en lång text för att förklara hur nöjd jag är över det. Det här kommer bli grymt. Grymt!</p>
<p>Grymt!</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.mattiasnorell.com/2010/08/16/flash-on-the-beach/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Dynamic mask using ActionScript</title>
		<link>http://blog.mattiasnorell.com/2010/01/15/dynamic-mask-using-actionscript/</link>
		<comments>http://blog.mattiasnorell.com/2010/01/15/dynamic-mask-using-actionscript/#comments</comments>
		<pubDate>Thu, 14 Jan 2010 23:18:29 +0000</pubDate>
		<dc:creator>Mattias</dc:creator>
				<category><![CDATA[ActionScript]]></category>
		<category><![CDATA[Air]]></category>
		<category><![CDATA[Flash]]></category>
		<category><![CDATA[In english]]></category>
		<category><![CDATA[Tutorial]]></category>
		<category><![CDATA[dynamic]]></category>
		<category><![CDATA[mask]]></category>

		<guid isPermaLink="false">http://blog.mattiasnorell.com/?p=399</guid>
		<description><![CDATA[I was asked if is possible to use my inverted mask-class with a dynamic mask. The answer right now is &#8221;not yet&#8221;. But it got me thinking and if you ask me again in a few days the answer might &#8230; <a href="http://blog.mattiasnorell.com/2010/01/15/dynamic-mask-using-actionscript/">Läs mer <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>I was asked if is possible to use my <a href="http://blog.mattiasnorell.com/2009/10/21/pure-actionscript-3-inverted-mask/" target="_blank">inverted mask-class </a>with a dynamic mask. The answer right now is &#8221;not yet&#8221;. But it got me thinking and if you ask me again in a few days the answer might be &#8221;of course, it always has&#8221;. So I Googled some stuff about dynamic masks and found that almost none suited what I wanted. I wanted the user to be able to double click somewhere inside the swf, add as many anchorpoints they want, be able to move them around and if they so choose, delete them.</p>
<p>Not as much <a href="http://www.urbandictionary.com/define.php?term=Frankencode" target="_blank" onclick="pageTracker._trackPageview('/outgoing/www.urbandictionary.com/define.php?term=Frankencode&amp;referer=');">Frankencode</a> as I was affraid it would be but someone might find it useful so I thought I´d share it. The code is commented if you are new to AS3 and want to know what is going on.</p>
<p><a href="http://blog.mattiasnorell.com/wp-content/uploads/2010/01/dynamicmask.swf" rel="shadowbox[sbpost-399];width=640;height=385;">And here is a demo of the little thing</a>. Doubleclick inside the swf to add anchorpoints and doubleclick the handles to remove them.</p>
<pre class="brush: actionscript3; font-size: 50%">package{
import flash.display.Sprite;
import flash.events.MouseEvent;
import flash.events.Event;

public class Main extends Sprite{

//Setup a some stuff
public var maskBG:Sprite = new Sprite();
public var cord:Array = [];

public function Main():void{

// The image that will appear thru the mask
var lemmyImage:Sprite = new Sprite();
lemmyImage.addChild(new Lemmy());
addChild(lemmyImage);

// An invisible sprite that tracks where the user click
var clickMe:Sprite = new Sprite();
clickMe.graphics.beginFill(0xFF0000,0);
clickMe.graphics.drawRect(0,0,stage.stageWidth,stage.stageHeight);
clickMe.graphics.endFill();
addChild(clickMe);

// Some eventhandlers to see where the user click and to update the mask
clickMe.doubleClickEnabled = true;
clickMe.addEventListener(MouseEvent.DOUBLE_CLICK,addCord);
stage.addEventListener(Event.ENTER_FRAME,updateMask);

addChild(maskBG);

// Set the mask layer to cover the image
lemmyImage.mask = maskBG;

}

private function moveStart(e:MouseEvent):void{
e.currentTarget.startDrag();
e.currentTarget.addEventListener(MouseEvent.MOUSE_MOVE, moveUpdate);
}

private function moveStop(e:MouseEvent):void{
e.currentTarget.stopDrag();
e.currentTarget.removeEventListener(MouseEvent.MOUSE_MOVE, moveUpdate);
}

private function moveUpdate(e:MouseEvent):void{
// Get the location in the array for the handler
var id:int = getHandleId(e.currentTarget.name);

// Update the array with the new values
cord[id] = {id:e.currentTarget.name,x:e.currentTarget.parent.mouseX,y:e.currentTarget.parent.mouseY};
}

private function removeHandle(e:MouseEvent):void{
// Get the location in the array for the handler
var id:int = getHandleId(e.currentTarget.name);

// Remove the part of the array by splicing it.
// Save the splica in a temporaryarray so that it is possible
// to merge the stuff after out deletedpart with the array again.
var a:Array = cord.splice(id,cord.length);
for(var i:int = 1;i&lt;a.length;++i){
cord.push(a[i]);
}

e.currentTarget.parent.removeChild(e.currentTarget);
}

private function updateMask(e:Event):void{
// Clear the masklayer
maskBG.graphics.clear();
maskBG.graphics.lineStyle(2,0xffffff);
maskBG.graphics.beginFill(0xFF0000,1);

// If the value of i is 0 then we want to move to the locatino.
// If we use lineTo it will draw a line from the top left corner.
for(var i:int=0;i&lt;cord.length;++i){
if(i==0){
maskBG.graphics.moveTo(cord[i].x,cord[i].y);
}else{
maskBG.graphics.lineTo(cord[i].x,cord[i].y);
}
}

maskBG.graphics.endFill();
}

private function getHandleId(val:String):int{
// Hack to find the location of the coordinate in the array
for(var i:int=0;i&lt;cord.length;++i){
if(cord[i].id == val){
var id:int = i;
}
}

return id;
}

private function addCord(e:MouseEvent):void{

//Add handle
var handle:Sprite = new Sprite();
handle.graphics.beginFill(0xff0000,1);
handle.graphics.drawRect(0,0,10,10);
handle.graphics.endFill();
handle.x = e.currentTarget.mouseX-5;
handle.y = e.currentTarget.mouseY-5;

// I use the datemethod just cause it easy to get a uniquevalue.
// It's not close to perfect so you should rewrite this part.
// It was late when I did this, sorry  I guess =)
var now:Date = new Date();
handle.name = String(now.getUTCMinutes()+now.getMilliseconds()*Math.random());

// Set up the listeners for the handler
handle.doubleClickEnabled = true;
handle.addEventListener(MouseEvent.MOUSE_DOWN, moveStart);
handle.addEventListener(MouseEvent.MOUSE_DOWN, updateMask);
handle.addEventListener(MouseEvent.MOUSE_UP, moveStop);
handle.addEventListener(MouseEvent.DOUBLE_CLICK, removeHandle);
handle.addEventListener(Event.ADDED_TO_STAGE,updateMask);
addChild(handle);

// Push the coordinate into the array
cord.push({id:handle.name,x:e.currentTarget.mouseX,y:e.currentTarget.mouseY});
}
}
}</pre>
]]></content:encoded>
			<wfw:commentRss>http://blog.mattiasnorell.com/2010/01/15/dynamic-mask-using-actionscript/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Skistars väderkub</title>
		<link>http://blog.mattiasnorell.com/2009/03/19/skistars-vaderkub/</link>
		<comments>http://blog.mattiasnorell.com/2009/03/19/skistars-vaderkub/#comments</comments>
		<pubDate>Thu, 19 Mar 2009 09:06:44 +0000</pubDate>
		<dc:creator>Mattias</dc:creator>
				<category><![CDATA[Air]]></category>
		<category><![CDATA[Flash]]></category>
		<category><![CDATA[skistar]]></category>
		<category><![CDATA[widget]]></category>

		<guid isPermaLink="false">http://blog.mattiasnorell.com/?p=106</guid>
		<description><![CDATA[Brandade applikationer började dyka upp under förra året och hade en ganska trög start. Men i och med att Adobes Air fått mer spridning samt att det börjar få fäste hos webbproducenter kommer det, på gott och ont, explodera med &#8230; <a href="http://blog.mattiasnorell.com/2009/03/19/skistars-vaderkub/">Läs mer <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p><img class="size-full wp-image-107 alignnone" title="skistar_widget" src="http://blog.mattiasnorell.com/wp-content/uploads/2009/03/skistar_widget.jpg" alt="Skistar weather air-application" width="580" height="408" /></p>
<p>Brandade applikationer började dyka upp under förra året och hade en ganska trög start. Men i och med att <a href="http://www.adobe.com/products/air/" target="_blank" onclick="pageTracker._trackPageview('/outgoing/www.adobe.com/products/air/?referer=');">Adobes Air</a> fått mer spridning samt att det börjar få fäste hos webbproducenter kommer det, på gott och ont, explodera med liknande applikationer under året som kommer. Vi på <a href="http://www.two.se" target="_blank" onclick="pageTracker._trackPageview('/outgoing/www.two.se?referer=');">Two</a> har turen att ha en kund som <a href="http://www.skistar.com" target="_blank" onclick="pageTracker._trackPageview('/outgoing/www.skistar.com?referer=');">Skistar</a> som vågar prova nya vägar att marknadsföra sig. Denna gång blev resultaten en Air-applikation som skall vara en enkel väg för deras besökare att enkelt uppdatera sig på väderförhållanden på de olika orterna utan att behöva gå in på Skistars webbplats. Skistar ville presentera fem destinationer på varsin sida av väderkuben samt en framsida där de kan publicera nyheter och erbjudanden. Kuben roteras med hjälp av <a href="http://blog.papervision3d.org" target="_blank" onclick="pageTracker._trackPageview('/outgoing/blog.papervision3d.org?referer=');">Papervision3D</a> och uppdateras i realtid från deras vädersystem. Ett grymt kul projekt som i slutändan fick ett riktigt häftig resultat.</p>
<p>För att hämta applikationen kilar ni över till <a href="http://www.skistar.com/parser.php?did=500:1022" target="_blank" onclick="pageTracker._trackPageview('/outgoing/www.skistar.com/parser.php?did=500_1022&amp;referer=');">Skistar.com</a> och följer instruktionerna.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.mattiasnorell.com/2009/03/19/skistars-vaderkub/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

