Don’t forget the wordWrap!
Posted by admin | Filed under Flash
Quick post time. I was working in Flash today creating some text fields at run time and populating them with text. I set the width, made it multiline and then dropped in the text using code similar to the snippet below.
var contents = new TextField();
contents.width = 300;
contents.multiline = true;
contents.text = myData;
Tested the movie and shocker, the text was not multiline! Confused I read the lines over and over again, changed the order in which I declared the multiline value and then it hit me, word wrap! By default the wordWrap value in Flash is set to false, this forces all the text on one line no matter what the multiline says. By adding a simple wordWrap = true everything displayed as intended.
var contents = new TextField();
contents.width = 300;
contents.wordWrap = true;
contents.multiline = true;
contents.text = myData;
I’m not sure why I always forget the wordWrap but next time I do hopefully I remember I wrote this post!
Tags: AS3
Relative Classpaths in AS3
Posted by admin | Filed under Flash
I’ve been working in AS3 for about a year now and everyone in awhile I slip and use an AS2 property reference, for example ._alpha vs .alpha. The other place I find myself slipping is with classpaths. I work in a SVN development environment so it is important that all classpaths are defined relatively so they work across machines.
For simplicity’s sake here’s a sample of a very basic small Flash project.

In AS2 I would set the classpath as “classes/” to have access to the MyClass.as file in my project.fla.
In AS3 that doesn’t fly and the classpath must be set as ”../myProject/classes” or “./classes”. I’m not 100% clear on why “classes/” no longer works as all three paths seem the same to me, but suffice to say this caused a fair share of headaches when I first made the jump to AS3.