Archive for July, 2009

Eclipse 3.5 and FDT 3.2 for Actionscript development – Part 5 – Keyboard Shortcuts

SEARCHING

CTRL + Shift + R Jump to a resource. Includes classes and any other files (such as XML files)
CTRL + H Search (rather than find) allows you to search within the entire workspace
CTRL + F Search in one file (CTRL+K/CTRL+SHIFT+K: next/previous)
CTRL + J Find within document. Type the word you want to find then use up and down to skip between instances. Press ESC to cancel
CTRL+J/CTRL+SHIFT+J Incremental search (search as you type)

NAVIGATING

F2 Select class in flash explorer
F3 Show property/method declaration/implementation
F4 Show type declaration
F5 Show superclass
CTRL + T Show type hierarchy
CTRL + R Search references
CTRL + L Go to line
CTRL + U Show type dependency
CTRL + O Show quick outline

EDITING SINGLE FILES

ALT + UpArrow Move line up
ALT + DownArrow Move line down
CTRL + D / CTRL + SHIFT + D Delete line/duplicate line
SHIFT + ENTER / CTRL + SHIFT + ENTER Add indented line after/before
CTRL + 7 Comment/uncomment line
CTRL + (numeric)- / CTRL + (numeric)+ Fold/unfold other methods
CTRL + M Maximize view
CTRL + (numeric)ENTER Alternative to CTRL+M

EDITING MULTIPLE FILES

CTRL + PageDown / CTRL + PageUp Move to next/previous open file
CTRL + F6 Alternative to CTRL+PageDown/CTRL+PageUp
ALT + LeftArrow/ ALT + RightArrow Navigate to next/previous opened files (history)

GENERATING

CTRL + Space Insert code template/auto complete code
CTRL + SHIFT + O Organize imports

FIXING

CTRL + 1 Show fixes (if error bulb is shown)

BUILDING

CTRL + F11 Start last run
CTRL + O Open an outline of functions within the current class to jump to
CTRL + Shift + T Jump to a type (class or interface). Only works when an .as or .mxml file is open
CTRL + L Jump to a line number
CTRL + Shift + C Wrap / Unwrap selected text in a block comment (/* */)
CTRL + Shift + / Comment / uncomment the selected line using an inline comment (//)
CTRL + Shift + D Add ASDoc style comment
CTRL + D Delete the selected text or the actual cursor line
CTRL + UP Move the selected up
CTRL + DOWN Move the selected text down
CTRL + Option + UP or DOWN Duplicate the selected text above or below the selected line
CTRL + X Make selected text ALL CAPS
CTRL + Y Make selected text all lowercase
CTRL + Shift + R Rename selected element (using refactor)
CTRL + M Maximize / Minimize current view
CTRL + Tab Jump to an open file editor
CTRL + Shift + L Keyboard command list. Press it again to edit commands
CTRL + Shift + G Find any references to the selected element within your project
CTRL + Click or F3 Jump to the definition of the selected element
CTRL + Shift + P Jump to matching bracket. e.g. jump from } to {
Tab / Shift + Tab Indent / Un-indent selected text
CTRL + Option + Left / Right Jumps to the location of the previous / next edit without undoing your change

Source: http://dispatchevent.org/mims/flexbuilder-keyboard-shortcuts/

Post to Twitter

Eclipse 3.5 and FDT 3.2 for Actionscript development – Part 4 – Customization

1) Eclipse Splash Screen

There are two ways of changing the Eclipse splash screen, manually or using the Random Splash Screen plugin:

  • Manually
    Put the “splash.bmp” file in the folder C:\eclipse\ and add the following line to the file C:\eclipse\eclipse.ini:
    -showsplash
    splash.bmp
  • Random Splash Screen
    Everytime Eclipse starts, Random Splash Screen overwrites Eclipse’s splash screen with a random image picked from your personal image folder. This image is then displayed on the next Eclipse start.Website: http://sourceforge.net/projects/rndsplash/To modify the plugin options go in

Since I was not satisfied with the splash screens that I found I asked my friend Denio Barani to design a splash screen more appealing, and here are the four versions:

Eclipse Splash Screen 1 (391.67 KB)
Eclipse Splash Screen 2 (391.67 KB)
Eclipse Splash Screen 3 (391.67 KB)
Eclipse Splash Screen 4 (391.67 KB)

Here a list of various splash screens that I found around the web:

2) Eclipse icon

I don’t like a lot the standard Eclipse icon so here you can find some different ones:

To convert the images to icons use the iConvert website.

Post to Twitter

Eclipse 3.5 and FDT 3.2 for Actionscript development – Part 3 – Configuration

In the second post of the serie I suggested some useful plugins. Now is time to configure the Eclipse and FDT installation.

Obviously this is my way of configuring both, so if you would like to make some changes I suggest you to explore all the menus and submenus in Eclipse because you’ll find a lot of interesting properties that can be customized to suit your needs. Here is my configuration.

1) Eclipse preferences configuration

  • Window -> Preferences -> General -> Always run in background
    Window -> Preferences -> General -> Show heap status

    pref general Eclipse 3.5 and FDT 3.2 for Actionscript development – Part 3 – Configuration
  • Window -> Preferences -> General -> Editors -> Text Editors -> Show line numbers
    pref general editors texteditors Eclipse 3.5 and FDT 3.2 for Actionscript development – Part 3 – Configuration
  • Window -> Preferences -> General -> Keys -> Select the “Run Ant Build” and in Binding press CTRL + ENTER to bind this shortcut to the command
    pref general keys Eclipse 3.5 and FDT 3.2 for Actionscript development – Part 3 – Configuration

2) FDT preferences configuration

  • Window -> Preferences -> FDT -> Build Path -> Output folder name: deploy
    pref fdt buildpath Eclipse 3.5 and FDT 3.2 for Actionscript development – Part 3 – Configuration
  • Window -> Preferences -> FDT -> Code style -> Formatter -> Set how you you want your code formatted
    pref fdt codestyle formatter Eclipse 3.5 and FDT 3.2 for Actionscript development – Part 3 – Configuration
  • Window -> Preferences -> FDT -> Core Libraries -> AS3 Core Libraries -> Add…
    pref fdt corelibraries 1 Eclipse 3.5 and FDT 3.2 for Actionscript development – Part 3 – Configuration
    Type: Flash CS3
    Name: FLASH_CS4
    _COMPONENTS
    click Browse…


    pref fdt corelibraries 2 Eclipse 3.5 and FDT 3.2 for Actionscript development – Part 3 – Configuration


    click New...


    pref fdt corelibraries 3 Eclipse 3.5 and FDT 3.2 for Actionscript development – Part 3 – Configuration

    Name: FLASH_CS4_COMPONENTS
    Location: C:\Program Files\Adobe\Adobe Flash CS4\Common\Configuration\ActionScript 3.0\FP10
    click OK


    pref fdt corelibraries 4 Eclipse 3.5 and FDT 3.2 for Actionscript development – Part 3 – Configuration

    click OK


    pref fdt corelibraries 5 Eclipse 3.5 and FDT 3.2 for Actionscript development – Part 3 – Configuration

  • Window -> Preferences -> FDT -> Editor -> Code Assist -> Auto activation triggers for AS: abcdefghijklmnopqrstuvwxyz_.:
    pref fdt editor codeassist Eclipse 3.5 and FDT 3.2 for Actionscript development – Part 3 – Configuration
  • Window -> Preferences -> FDT -> Editor -> Folding -> Leave Folding enabled checked and uncheck all the others
    pref fdt editor Eclipse 3.5 and FDT 3.2 for Actionscript development – Part 3 – Configuration
  • Window -> Preferences -> FDT -> Tools -> Flash -> Flash IDE: C:\Program Files\Adobe\Adobe Flash CS4\Flash.exe
    Window -> Preferences -> FDT -> Tools -> Flash -> Flash Player: C:\Program Files\Adobe\Adobe Flash CS4\Players\FlashPlayer.exe

    Window -> Preferences -> FDT -> Tools -> Flash -> Flash ASO Directory:
    C:\Documents and Settings\User\Local Settings\Application Data\Adobe\Flash CS4\en\Configuration\Classes\aso


    pref fdt tools flash Eclipse 3.5 and FDT 3.2 for Actionscript development – Part 3 – Configuration

  • Window -> Preferences -> FDT -> Tools -> Flash Help -> Click Update Help
    pref fdt tools flash help Eclipse 3.5 and FDT 3.2 for Actionscript development – Part 3 – Configuration

3) Perspective customization

  • Window -> Customize Perspective -> Tool Bar Visibility -> Disable FDT MXML Coding
    persp toolbar visibility Eclipse 3.5 and FDT 3.2 for Actionscript development – Part 3 – Configuration
  • Window -> Customize Perspective -> Command Group Availability -> Disable Annotation Navigation
    Window -> Customize Perspective -> Command Group Availability -> Disable Editor Navigation
    Window -> Customize Perspective -> Command Group Availability -> Disable FDT MXML Coding

    persp command groups Eclipse 3.5 and FDT 3.2 for Actionscript development – Part 3 – Configuration

  • Window -> Customize Perspective -> Shortcuts -> Submenus: New -> Disable MXML Class
    persp shortcuts new Eclipse 3.5 and FDT 3.2 for Actionscript development – Part 3 – Configuration
  • Window -> Customize Perspective -> Shortcuts -> Submenus: Open Perspective -> Enable Flash FDT
    Window -> Customize Perspective -> Shortcuts -> Submenus: Open Perspective -> Disable Java
    Window -> Customize Perspective -> Shortcuts -> Submenus: Open Perspective -> Disable Resource

    persp shortcuts open persp Eclipse 3.5 and FDT 3.2 for Actionscript development – Part 3 – Configuration

Select if it’s not already selected Window -> Open Perspective -> Other… Flash FDT and press OK

persp open persp Eclipse 3.5 and FDT 3.2 for Actionscript development – Part 3 – Configuration

Then close this views:

  • SWF Viewer
  • Javadoc View

Then open the Ant view from Window -> Show View -> Ant and dock it with the Outline panel.
If you want you can select the button Link with Editor inside the Flash Explorer so the current file you are editing will be selected in the Flash Explorer project tree.
The final look will be this (click to enlarge):


ide normal 300x240 Eclipse 3.5 and FDT 3.2 for Actionscript development – Part 3 – Configuration

I suggest you to move the minimized toolbars (like Flash Explorer, Outline Panel, Problems, etc.) at the bottom of the interface so when everything is minimized and you’re writing code you’ve the maximum space available like this (click to enlarge):


ide maximized 300x240 Eclipse 3.5 and FDT 3.2 for Actionscript development – Part 3 – Configuration

Next post: Eclipse 3.5 and FDT 3.2 for Actionscript development – Part 4 – Customization

Post to Twitter

[AS3 SNIPPET] Convert date in time interval string


function formatDate(d:Date):String
{
var now:Date = new Date();
var diff:Number = (now.time - d.time) / 1000; // convert to seconds
if (diff < 60) // just posted
{
return "Just posted";
}
else if (diff < 3600) // n minutes ago
{
return (Math.round(diff / 60) + " minutes ago");
}
else if (diff < 86400) // n hours ago
{
return (Math.round(diff / 3600) + " hours ago");
}
else // n days ago
{
return (Math.round(diff / 86400) + " days ago");
}
}

var date:Date = new Date();
trace(formatDate(date)); //Traces "Just posted"

Source: http://blogs.adobe.com/cantrell/archives/2009/06/actionscript_fu.html

Post to Twitter

[AS3 SNIPPET] Convert seconds to ww:dd:hh:mm:ss


function convertTime(number:Number):String
{
number = Math.abs(number);
var values:Array = new Array(5);
values[0] = Math.floor(number / 86400 / 7);// weeks
values[1] = Math.floor(number / 86400 % 7);// days
values[2] = Math.floor(number / 3600 % 24);// hours
values[3] = Math.floor(number / 60 % 60);// mins
values[4] = Math.floor(number % 60);// secs

var stopage:Boolean = false;
var cutIndex:Number = -1;

for (var i:Number = 0; i < values.length; i++)
{
if (values[i] < 10)
{
values[i] = "0" + values[i];
}
if (values[i] == "00" && i < (values.length - 2) && !stopage)
{
cutIndex = i;
}
else
{
stopage = true;
}
}
values.splice(0, cutIndex + 1);

return values.join(":");
}

Post to Twitter

[AS3 SNIPPET] Legal age verification


var legalAge:int = 18;

var userDOB:Date = new Date(year, month - 1, day);
var today : Date = new Date();

var diff:Date = new Date();
diff.setTime(today.getTime() - userDOB.getTime());

var userAge:int = diff.getFullYear() - 1970;

if(userAge >= legalAge)
{
trace("lets get pissed!");
}
else
{
trace("go away!");
}

Source: http://mrdoob.com/blog/post/633

Post to Twitter

[AS3 SNIPPET] Format day, month and year to full date


function formatFullDate(year:Number, month:Number, day:Number):String
{
var days:Array = new Array("Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday");
var months:Array = new Array("January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December");
var currentDate:Date = new Date(year, month - 1, day, 1, 1);
var currentDay:String = days[currentDate.getDay()];
var currentMonth:String = months[currentDate.getMonth()];
var output:String = currentDay + " " + day + " " + currentMonth + ", " + year;

return output;
}

var formattedDate:String = formatFullDate(2009, 7, 7);
trace(formattedDate); //traces Tuesday 7 July, 2009

Post to Twitter

[AS3 SNIPPET] Detect if mouse pointer is over/out of the stage area


stage.addEventListener (Event.MOUSE_LEAVE, leaveHandler);
stage.addEventListener (MouseEvent.MOUSE_MOVE, returnHandler);

function leaveHandler(event:Event):void
{
trace("leaveHandler");

stage.addEventListener (MouseEvent.MOUSE_MOVE, returnHandler);
}

function returnHandler(event:Event):void
{
trace("returnHandler");

stage.removeEventListener(MouseEvent.MOUSE_MOVE, returnHandler);
}

Event.MOUSE_LEAVE: dispatched by the Stage object when the mouse pointer moves out of the stage area.
MouseEvent.MOUSE_MOVE: Dispatched when a user moves the pointing device while it is over an InteractiveObject.

Post to Twitter

[AS3 SNIPPET] Detect if Flash movie gain/lose focus

stage.addEventListener(Event.ACTIVATE, activateHandler);
stage.addEventListener(Event.DEACTIVATE, deactivateHandler);

function activateHandler(event:Event):void
{
trace("activateHandler");
}

function deactivateHandler(event:Event):void
{
trace("deactivateHandler");
}

Event.ACTIVATE is dispatched when the Flash Player or AIR application gains operating system focus and becomes active.

Event.DEACTIVATE is dispatched when the Flash Player or AIR application operating loses system focus and is becoming inactive.

Post to Twitter

[AS3 SNIPPET] Priority level of event listener


addEventListener("event", handler1, false, 1);
addEventListener("event", handler2, false);
addEventListener("event", handler3, false, 3);
addEventListener("event", handler4, false, 1);
addEventListener("event", handler5, false, 2);

Listener methods are executed in this order:

  1. handler3
  2. handler5
  3. handler1
  4. handler4
  5. handler2

If two or more listeners share the same priority, they are processed in the order in which they were added.
The higher the number, the higher the priority.

Post to Twitter

Next Page »