View Full Version : Mac dock in two dimensions
nook
December 10th, 2009, 04:34 PM
I'm looking for an example or script of a mac dock type interface with objects in a grid rather than on a line.
Anyone seen such a thing?
IQAndreas
December 10th, 2009, 05:18 PM
Screenshot perhaps?
I don't use a mac, so I have no clue. I use Windows, not because it's all that good, but because it's so common... Same reason I use Flash...
creatify
December 10th, 2009, 06:31 PM
Here's something I'd set up a while back, might help you head in the right direction. I'd do some forum/google searching for proximity or tsunami even.
Copy this to an AS file, and set it as your Document class:
package {
import flash.display.*;
import flash.events.*;
public class ProximitySample extends Sprite {
private var _boxSize:int = 20;
private var _totalIcons:int = 25;
private var _icons:Array = [];
//--------------------------------------
// CONSTRUCTOR
//--------------------------------------
public function ProximitySample() {
super();
addEventListener(Event.ADDED_TO_STAGE, init);
}
//-----------------------------------
// INIT
//-----------------------------------
private function init(e:Event):void {
removeEventListener(Event.ADDED_TO_STAGE, init);
stage.scaleMode = StageScaleMode.NO_SCALE;
stage.align = StageAlign.TOP_LEFT;
stage.showDefaultContextMenu = false;
stage.quality = StageQuality.BEST;
buildGrid();
}
//-----------------------------------
//
//-----------------------------------
private function buildGrid():void {
var perRow:int = 5;
var spacing:int = 10;
var xp:int = 50;
var yp:int = 50;
for(var i:uint=0; i<_totalIcons; i++) {
var col:int = i%perRow;
var row:int = Math.floor(i/perRow);
var box:Sprite = new Sprite();
with(box.graphics) {
beginFill(0x666666);
drawRect(-(_boxSize/2),-(_boxSize/2),_boxSize,_boxSize);
endFill();
}
box.alpha = .75;
box.x = xp+(col*(spacing+_boxSize));
box.y = yp+(row*(spacing+_boxSize));
addChild(box);
_icons.push(box);
}
addEventListener(Event.ENTER_FRAME, runProximity);
}
//-----------------------------------
//
//-----------------------------------
private function runProximity(e:Event):void {
var t:int = _totalIcons;
while(t--) {
var s:Sprite = _icons[t];
var mx:int = mouseX;
var my:int = mouseY;
var cx:Number = s.x;
var cy:Number = s.y;
var prox:Number = Math.sqrt((mx-cx)*(mx-cx) + (my-cy)*(my-cy));
if(prox<100) {
s.width = s.height = _boxSize*((200 - prox)/100);
} else {
s.width = s.height = _boxSize;
}
}
}
}
}
Hope this helps.
nook
December 10th, 2009, 07:22 PM
IqAndreas: You mean there's a better option than Flash you would use if it wasn't so common?
Creatify: Big thanks. Funny enough I just tested creating something before I saw your post and it actually builds on the same technique, though have some more things happening.
You can check it out here (http://nook.se/storage/kirupa/macDock2D/Test_MacDock2D.swf).
Though I think it's a bit hard to "capture" objects right now. And ideally no object should overlay each other.
Powered by vBulletin® Version 4.1.10 Copyright © 2012 vBulletin Solutions, Inc. All rights reserved.