Archive

Posts Tagged ‘snippet’

Snippets : shapes

November 29th, 2010 1 comment

Now and then I have a need to quickly add simple shape to my visual object. In most cases for fast and rough debugging. Sometimes for prototyping application if I still don’t have visuals, and sometimes… well I need a shape! :)

Here are couple of snippets to add quick shape to your DisplayObject.

 

#shape-rectangle

var $$(shapeVar=rectangle):Shape = new Shape();
$$(shapeVar).graphics.lineStyle($$(lineThickness=0.1,1,2,3,4,5,10), $$(lineColor=0xFF0000,0×000000,0x00FF00,0x0000FF,0xFFFF00,0xFF00FF,0x00FFFF,0xFFFFFF));
$$(shapeVar).graphics.beginFill($$(fillColor=0x0000FF,0×000000,0xFF0000,0x00FF00,0xFFFF00,0xFF00FF,0x00FFFF,0xFFFFFF));
$$(shapeVar).graphics.drawRect($$(x=0), $$(y=0), $$(width=100), $$(height=100));
$$(shapeVar).graphics.endFill();
this.addChild($$(shapeVar));

#shape-roundRectangle

var $$(shapeVar=roundRectangle):Shape = new Shape();
$$(shapeVar).graphics.lineStyle($$(lineThickness=0.1,1,2,3,4,5,10), $$(lineColor=0xFF0000,0×000000,0x00FF00,0x0000FF,0xFFFF00,0xFF00FF,0x00FFFF,0xFFFFFF));
$$(shapeVar).graphics.beginFill($$(fillColor=0x0000FF,0×000000,0xFF0000,0x00FF00,0xFFFF00,0xFF00FF,0x00FFFF,0xFFFFFF));
$$(shapeVar).graphics.drawRoundRect($$(x=0), $$(y=0), $$(width=100), $$(height=100), $$(ellipseWidth=20));
$$(shapeVar).graphics.endFill();
this.addChild($$(shapeVar));

#shape-circle

var $$(shapeVar=circle):Shape = new Shape();
$$(shapeVar).graphics.lineStyle($$(lineThickness=0.1,1,2,3,4,5,10), $$(lineColor=0xFF0000,0×000000,0x00FF00,0x0000FF,0xFFFF00,0xFF00FF,0x00FFFF,0xFFFFFF));
$$(shapeVar).graphics.beginFill($$(fillColor=0x0000FF,0×000000,0xFF0000,0x00FF00,0xFFFF00,0xFF00FF,0x00FFFF,0xFFFFFF));
$$(shapeVar).graphics.drawCircle($$(x=0), $$(y=0), $$(radius=100));
$$(shapeVar).graphics.endFill();
this.addChild($$(shapeVar));

#shape-ellipse

var $$(shapeVar=ellipse):Shape = new Shape();
$$(shapeVar).graphics.lineStyle($$(lineThickness=0.1,1,2,3,4,5,10), $$(lineColor=0xFF0000,0×000000,0x00FF00,0x0000FF,0xFFFF00,0xFF00FF,0x00FFFF,0xFFFFFF));
$$(shapeVar).graphics.beginFill($$(fillColor=0x0000FF,0×000000,0xFF0000,0x00FF00,0xFFFF00,0xFF00FF,0x00FFFF,0xFFFFFF));
$$(shapeVar).graphics.drawEllipse($$(x=0), $$(y=0), $$(width=100), $$(height=80));
$$(shapeVar).graphics.endFill();
this.addChild($$(shapeVar));

#shape-path

This one is hard to modify and use just by editing snippet parameters, but for quick lines or not standard shape it’s nice starting point as example.

var $$(shapeVar=path):Shape = new Shape();
$$(shapeVar).graphics.lineStyle($$(lineThickness=0.1,1,2,3,4,5,10), $$(lineColor=0xFF0000,0x000000,0x00FF00,0x0000FF,0xFFFF00,0xFF00FF,0x00FFFF,0xFFFFFF));
$$(shapeVar).graphics.beginFill($$(fillColor=0x0000FF,0x000000,0xFF0000,0x00FF00,0xFFFF00,0xFF00FF,0x00FFFF,0xFFFFFF));
$$(shapeVar).graphics.drawPath(
new <int>[
$$(command1=GraphicsPathCommand.MOVE_TO,GraphicsPathCommand.LINE_TO,GraphicsPathCommand.CURVE_TO),
$$(command2=GraphicsPathCommand.LINE_TO,GraphicsPathCommand.MOVE_TO,GraphicsPathCommand.CURVE_TO),
$$(command3=GraphicsPathCommand.LINE_TO,GraphicsPathCommand.MOVE_TO,GraphicsPathCommand.CURVE_TO),
$$(command4=GraphicsPathCommand.CURVE_TO,GraphicsPathCommand.LINE_TO,GraphicsPathCommand.MOVE_TO),
$$(command5=GraphicsPathCommand.LINE_TO,GraphicsPathCommand.MOVE_TO,GraphicsPathCommand.CURVE_TO)
],
new <Number>[
$$(point1x=50), $$(point1y=0),
$$(point2x=100), $$(point2y=50),
$$(point3x=80), $$(point3y=150),
$$(point4x=50), $$(point4y=0), $$(point5x=20), $$(point5y=150),
$$(point6x=0), $$(point6y=50)
]);
$$(shapeVar).graphics.endFill();
this.addChild($$(shapeVar));

Categories: FlashDevelop Tags: ,

Snippets : general

November 29th, 2010 No comments

Because FlashDevelop is updating so fast, and becoming so good… my 5 of 6 most used snippets are deprecated. I am talking about my #privatVar, #publicVar, #privatFunction, #publicFunction and #functionVarPass snippets.

They now can be easely and much better generated just by using CTRL+SHIFT+1.(except the fact that they can’t detect int type, just Number type… but thats little discomfort in overall goodness.)

So I present you couple of my general purpose snippets. (I don’t set shortcuts to them.)

 

#getURL

navigateToURL(new URLRequest(“$$(url=http://www.google.com/)”), “_blank”);

#getHtmlVars

var htmlVars:Object = LoaderInfo(this.root.loaderInfo).parameters;

#paragrafSmall

//———————————-
//     $$(paragrafTitle)$(EntryPoint)
//———————————-

#paragrafBig

//————————————————————————–
//
//      $$(paragrafTitle=Time for class splitting?)$(EntryPoint)
//
//————————————————————————–

#stageSetup

this.stage.quality = $$(quality=StageQuality.BEST,StageQuality.HIGH,StageQuality.MEDIUM,StageQuality.LOW);
this.stage.scaleMode = $$(scaleMode=StageScaleMode.NO_SCALE,StageScaleMode.SHOW_ALL);
this.stage.align = StageAlign.TOP_LEFT;
this.stage.frameRate = $$(frameRate=25,60,30,20,12);
Categories: FlashDevelop Tags: ,

Snippet : Instantiate

November 7th, 2010 No comments

One of my most used snippet is – instantiate.

To bind snippets to key-preses I use Macros.

Instantiating a class snippet could be simple one liner, if not for Vector data type. Vector has very unique format, and it requires special attention then instantiating. (I don’t use Array type anymore, so it’s very important for me to cover this case.)

I will present two different ways to instantiate stuff quickly.

1 – my old way of instantiating stuff

 

We need to create 2 snippets, I named them #instantiateLast and #instantiateSelected.

#instantiateLast :

$(CurWord) = new $(CurWord)($(EntryPoint));

#instantiateSelected :

$(SelText) = new $(SelText)($(EntryPoint));

 

Now in MENU >> Macros >> Edit Macros… we create 2 new macros :

instantiateLastWord [CTRL+ALT+1] :

InsertSnippet|#instantiateLast

 

instantiateSelected [SHIFT + CTRL+ALT+1] :

InsertSnippet|#instantiateSelected

 

(don’t forget to restart FD for shortcuts to start working.)

 

Use instantiateLastWord with non Vector classes keeping cursor over Class name, and then dealing with Vector – select the whole thing and use instantiateSelected.

2 – my current way of instantiating stuff

 

This method requires some instructions to use properly, but you will need only one macro for both Vector’s and non Vectors, and then you deal with Vector you will have to select less.

We will reuse #instantiateSelected snippet described above, and will create this macro for it:

instantiateSelectLast [CTRL+ALT+1]:

ScintillaCommand|WordLeftEndExtend
InsertSnippet|#instantiateSelected

You will have same functionality as before with non Vector classes, just use the macro keeping the cursor in the end of class name. With Vector is a bit tricky, you have to select everything except ”Vector”, and keep cursor in the end of this word. Best way to do it – back select to this point.

 

Have fun with this snippets.

 

Categories: FlashDevelop Tags: ,

MindScriptAct is Stephen Fry proof thanks to caching by WP Super Cache