Archive for July, 2009

Five3D multiline wordwrapping text

Thursday, July 9th, 2009

A couple of days ago I had a look into Five3D just because I had some time on my hands and I wanted to check out Five3D for a while now. One big thing I missed in this vector based 3D engine was word wrapping for text. A Google search led me to an inaccessible blog, so I decide to write the word wrapping myself.

Download the file here: Updated DynamicText3D.as (Compatible with v2.1.2)

Usage:

Actionscript:
  1. var text3d: DynamicText3D = new DynamicText3D(HelveticaBold);
  2. text3d.size = 40;
  3. text3d.color = 0xffffff;
  4. // set a maximum width for the text
  5. text3d.maxWidth = 220;
  6. // flick word wrapping on
  7. text3d.wordWrap = true;
  8. text3d.text = "Something long enough to actually wrap...";
  9.  
  10. // Traces out the height of the text
  11. trace("text3d.textHeight")

I know it's not perfect, but it's working for me! ;)

Useful Firefox add-ons

Tuesday, July 7th, 2009

FireBug
Firebug integrates with Firefox to put a wealth of development tools at your fingertips while you browse. You can edit, debug, and monitor CSS, HTML, and JavaScript live in any web page.

WASP
Provides detailed information about the data being collected trough Query String and Cookies by web analytics solutions (called "tags", "trackers" or "web bug"), ad networks, behavioral targeting and multivariate testing tools. Covers over 125 tools, including Google Analytics, Omniture SiteCatalyst, Coremetrics, WebTrends and several others.

HTML Validator
Validates HTML documents using the CSE HTML Validator engine for Windows. Requires CSE HTML Validator for Windows.

Screengrab
It will capture what you can see in the window, the entire page, just a selection, a particular frame... basically it saves web pages as images - either to a file, or to the clipboard.

MeasureIt
Draw out a ruler to get the pixel width and height of any elements on a webpage.

Links:

Edits:

  • 17/09/2009: Added MeasureIt.

HaXe

Friday, July 3rd, 2009

I started having a look at using HaXe a couple a days ago since it promises to be quite interesting.

haXe is a powerful modern language with many compelling features. It is aimed at giving developers a tool to create websites & applications in a single unified language.

It's quite simple to install and if you use FlashDevelop as editor you're pretty much set. I also took a look at some plugins for Eclipse, but they felt quite unfinished (granted most were still in beta). I tried Eclihx and HXDT.

Some useful info I found:

  • HaXe install dir: C:\Program Files\Motion-Twin\haxe\
  • Setting SWF properties using the HaXe compiler: -swf-header <header> : define SWF header (width:height:fps:color), i.e. "-swf-header 640:480:31:000000"
  • When your Main class is extending Sprite make sure to add it to the display list using: "Lib.current.stage.addChild(this);"
  • A nice tutorial on using SWCs with HaXe

Away3D in HaXe problem

Friday, July 3rd, 2009

I tried getting Away3D to run using Haxe, but it keeps on throwing an error at run time when I'm calling View3D.render() on every frame:

TypeError: Error #1034: Type Coercion failed: cannot convert flash.utils::Dictionary@157e1c1 to Function.
at MethodInfo-1076()[C:\Projects\HaXe\test03_away3d\src/away3d/haxeutils/HashMap.hx:50]
at away3d.core.utils::CameraVarsStore/reset()[C:\Projects\HaXe\test03_away3d\src/away3d/core/utils/CameraVarsStore.hx:147]
at away3d.containers::Scene3D/update()[C:\Projects\HaXe\test03_away3d\src/away3d/containers/Scene3D.hx:186]
at away3d.containers::Scene3D/onUpdate()[C:\Projects\HaXe\test03_away3d\src/away3d/containers/Scene3D.hx:85]
at flash.events::EventDispatcher/dispatchEventFunction()
at flash.events::EventDispatcher/dispatchEvent()
at away3d.containers::View3D/notifySceneUpdate()[C:\Projects\HaXe\test03_away3d\src/away3d/containers/View3D.hx:334]
at away3d.containers::View3D/render()[C:\Projects\HaXe\test03_away3d\src/away3d/containers/View3D.hx:921]
at com.dare.haxetest.core::Away3DTest/enterFrameHandler()[C:\Projects\HaXe\test03_away3d\src/com/dare/haxetest/core/Away3DTest.hx:222]

From a commit message in SVN it looks like there is a problem with using Dictionaries in HaXe. As the HashMap class still uses a Dictionary this error seems to be happening. I tried converting it to use the Hash class instead of a Dictionary, but that introduced other problems.

HaXe Iterators

Thursday, July 2nd, 2009
Actionscript:
  1. var myHash:Hash&lt;Int&gt; = new Hash();
  2. myHash.set("one", 1);
  3. myHash.set("two", 1);
  4. myHash.set("three", 2);
  5. myHash.set("four", 3);
  6. myHash.set("five", 5);
  7.  
  8. var total:Int = 0;
  9.  
  10. for ( num in myHash.iterator() ) {
  11. total += num;
  12. trace(num + ": " + total);
  13. }

In computer science, an iterator is an object that allows a programmer to traverse through all the elements of a collection, regardless of its specific implementation. An iterator is sometimes called a cursor, especially within the context of a database.
- From Wikipedia -

In this particular example you don't need to use .iterator() as the Hash class is iterable, see http://haxe.org/ref/iterators > 'Iterable Objects'.

NOTE: Use myHash.iterator() (mind the parenthesis) and not myHash.iterator as I'm used to from coding AS3.

Creating a SWC

Thursday, July 2nd, 2009
Actionscript:
  1. compc -output=C:\something.swc
  2. -sp C:\Projects\test\src
  3. -is C:\Projects\test\src

This works much faster than just adding all classes by hand when using include-classes (or 'ic') and needing to specify each and every class...