Flashguy’s Blog
Wicked Actionscript

Getting a “Shake” Event on the iPhone with Flash CS5

February 8th, 2010 by Gabor Wraight

If you need to find out if a User shakes his iPhone the following might help:

Actionscript:
  1. var accel:Accelerometer = new Accelerometer();
  2. accel.addEventListener(AccelerometerEvent.UPDATE, onAccelUpdate);
  3.  
  4. var lastAccelX:Number;
  5. var lastAccelY:Number;
  6. var lastAccelZ:Number;
  7.  
  8. var shaked:Boolean;
  9. var shakeTreshhold: Number = 1.5
  10.  
  11. function onAccelUpdate(e:AccelerometerEvent):void
  12. {
  13.     if ((e.accelerationX - lastAccelX> shakeTreshhold)||(e.accelerationY - lastAccelY> shakeTreshhold)||(e.accelerationZ - lastAccelZ> shakeTreshhold))
  14.     {
  15.         if(shaked)
  16.             return;
  17.            
  18.         shaked = true;
  19.         // do your shake action here!!!
  20.  
  21.         var t:Timer = new Timer(800, 1);
  22.         t.addEventListener(TimerEvent.TIMER, function onTimer():void{
  23.             shaked = false;
  24.         });
  25.         t.start();
  26.     }
  27.    
  28.     lastAccelX = e.accelerationX;
  29.     lastAccelY = e.accelerationY;
  30.     lastAccelZ = e.accelerationZ;
  31. }

What I do here is listen for accelerometer update Events and compare the values from the last with the current Event. If the delta is higher than the defined treshold value, the phone is shaken. To avoid to many shakes after another I set a timer. I'm not sure, if this is the best practice for doing this, but it works out well in my App.

Posted in Flash CS5, iphone | No Comments »

Determining the direction of a Gesture in Flash CS5 on the iPhone

February 5th, 2010 by Gabor Wraight

If you need to find out in what direction a gesture goes, e.g. Up, Down, Left or Right the following Script might help.

Actionscript:
  1. this.addEventListener(TouchEvent.TOUCH_BEGIN, onTouchBegin)
  2. this.addEventListener(TouchEvent.TOUCH_END, onTouchEnd)
  3.  
  4. var startPoint:Point;
  5. var endPoint:Point;
  6.  
  7. function onTouchBegin(e:TouchEvent):void
  8. {
  9.     startPoint = new Point(e.localX, e.localY);
  10. }
  11. function onTouchEnd(e:TouchEvent):void
  12. {
  13.     endPoint = new Point(e.localX, e.localY);
  14.     var a:Number = endPoint.y - startPoint.y;
  15.     var b:Number = endPoint.x - startPoint.x;
  16.    
  17.     if(a*a> b*b){
  18.         if(a> 0){
  19.             //down
  20.         }else{
  21.             //up
  22.         }
  23.     }else{
  24.         if(b> 0){
  25.             //right
  26.         }else{
  27.             //left
  28.         }
  29.     }
  30. }

Posted in Actionscript 3.0, Flash CS5, iphone | No Comments »

Adding a hyperlink to a Flashbuilder RichText Component

January 23rd, 2010 by Gabor Wraight

First of all be aware to use RichEditableText instead of the RichText. Unfortunatly I couldn't get links to work in the RichText Component. Also set editable="false" focusEnabled="false" in the RichEditableText Component to make it clickable

Actionscript:
  1. <s:RichEditableText editable="false" focusEnabled="false">
  2.     <s:content><s:p><s:span>some Text</s:span><s:a href="http://www.flashguy.de">the link</s:a><s:span>more Text</s:span></s:p></s:content>
  3. </s:RichEditableText>

Posted in Actionscript 3.0, Flashbuilder, Flex | No Comments »

Transparent Air application with Flashbuilder

June 28th, 2009 by Gabor Wraight

Just a quick one that annoyed me a bit. After my Vacation I came back and was so happy that the Flashbuilder beta was released. It was really necessary coz I wasn't happy working with Flexbuilder 3 after seeing the Gumbo preview at Max.

So, I started a new AIR Project in Flashbuilder and got stuck imediatly. I wanted a transparent application and this was really easy in Flexbuilder 3.As we now have the Spark framework things have changed a bit. To get an application with no crome and transparency you have to do the following:

  • Set system Chrome to none in the application descriptor file
  • Set transparent to true in the application descriptor file
  • Copy the file ApplicationSkin.mxml from the flex4 library to your project in a folder skins and name it ApplicationAlphaSkin.mxml
  • add the state: <s:State name="normalInactive" /> as first state in ApplicationAlphaSkin.mxml
  • set alpa="0" on the solidcolor of the backgroundRect
  • set the new skin in you application tag: skinClass="skins.ApplicationAlphaSkin"

Hope this helps someone.

Posted in Flashbuilder | 7 Comments »

Long Time no Blogging

June 28th, 2009 by Gabor Wraight

Hey you guys out there.
I'm sorry for not blogging for ages, but i was really busy with some awesome projects and and a long vacation in the US. I'll try to get all the stuff posted here in the next few days!

Posted in General | No Comments »

Talk - Flex Builder 4 & Flash Catalyst Preview

January 16th, 2009 by Gabor Wraight

Hey everybody,

for those of you out there around Munich I'm talking about the new version of Flex Builder & Flash Catalyst. The talk is happening on the 27.01.09 at the Haus der Kommunikation, Brienner Straße 43-45 a-d, 80333 Munich(Service Plan).

It will be a hands on session with only a few slides. I'm going to show the great new workflow between designer and developer. You're going to learn how easy it will be to create a dynamic application starting with a photoshop file using Flash Catalyst and Flex Builder. I'm going to show how easy it is to convert artwork to components and export these to Flex Builder. In Flex Builder you will learn about the new features that will make a developers life a lot easier.

For more information please visit http://www.fugmuc.de

Because it's a german usergroup the talk is held in german.

Posted in Talks | No Comments »

Flex Builder 4 - MAX 2008 Preview

November 21st, 2008 by Gabor Wraight

This video gives an overview of the new features in Flex Builder 4. These are:

  • Package Explorer with outline view where you can even navigate into the ActionScript classes of a SWC file. Also you have the Flex Framework in here.
  • File Templates which allow you to define templates for Classes, Interfaces, CSS and MXML
  • Improved Refactoring with moving of classes
  • Class code hints if you mouse over you'll get the ASDocs for that class
  • Generate Getters and Setters
  • Generate event handler e.g. when you define a click action on an Button you can automatically generate the Handler with one click.
  • Jump to Line in Debugger
  • Conditional Breakpoints(I Love this one)
  • Network Monitor, yes it's back!
  • Flex Unit support

I'm so looking forward to a stable beta release.

Posted in Conferences, Flex | No Comments »

I am now an Adobe Certified Expert

November 18th, 2008 by Gabor Wraight

Today I had my Adobe Certified Expert Exam for Flex 3 and AIR here in San Francisco and what should I say, I passed! I must say it was pretty tough, because the exam covered a wide range of Flex and AIR Development including every different aspect there is.

For anybody out there interested in taking the exam check out the Adobe Flex 3 and AIR ACE Preparation Guide. The exams are available through Pearson VUE somewhere close to you.

Posted in General, Uncategorized | 2 Comments »

Flash Catalyst - Max 2008 Preview

November 18th, 2008 by Gabor Wraight

Part1

Part2

These videos were recorded today at Max in San Francisco.

The Adobe Team showed us a demo of what is possible with Flash Catalyst. I had to split it up in two parts for youtube.

And guess what, Adobe was so kind to give us a DVD with Flash Catalyst and the new Flexbuilder 4, Codename Gumbo. As soon as the Catalyst videos are on youtube, I'm going to post an awesome preview on Gumbo. Stay tuned!

Posted in Conferences, Flash Catalyst | No Comments »

Adobe Max 2008 San Francisco

November 17th, 2008 by Gabor Wraight

Adobe Max 2008

I arrived in Lovely San Francisoco yesterday night. After Alex and Sven picked me up at the Airport we went out for a decent dinner at a Thai place.

Today we registered for the Conference in the Mocone Center. We got our Bagdes and a quit ugly Bag. Fortunatly it's eco friendly... After that we did a little sightseeing including a Cable Car trip to Fisherman Warf. Really Nice!

Now I'm looking forward to tomorrow on what I'm going to see at the conference. There are quite some rumors about what we're gonna be presented. Flash Catalyst(Thermo) will be one of the Big ones. Stay tuned for more info tomorrow.

Posted in Conferences | No Comments »

« Previous Entries