Posts filed under 'General'

FDT Template for Getter / Setter methods.

If you’re being a good Flex / AS3 dev, you are probably wrapping your class member properties with public getter and setter methods.

If you’re not, you really, really should…

Getters and Setters, otherwise known as accessor methods, or mutator methods (among other things), are very helpful. They allow you to make your public properties have a far greater set of controls and features. I won’t go into all the details here, I’m assuming that you, like me, only fail to set them up because typing…

public var classMember : String;

Is slightly quicker than typing…

private var _classMember : String;

public function set classMember( value : String ) : void {
        _classMember = value;
}

public function get classMember( ) : String {
        return _classMember;
}

Anyway, if you are an FDT user, (or your chosen IDE has a templating feature) you can create a template to do this for you.

Read/Write member … (template name member)

private var _${name} : ${type};

public function set ${name}( value : ${type} ) : void {
        _${name} = value;
}

public function get ${name}( ) : ${type} {
        return _${name};
}

And then it will only take as long as setting up a public var, but with all the goodness that comes with using getter/setters…

You could setup templates for a read only member, and a write only member too…

Read only member … (template name rmember)

private var _${name} : ${type};

public function get ${name}( ) : ${type} {
        return _${name};
}

Write only member … (template name wmember)

private var _${name} : ${type};

public function set ${name}( value : ${type} ) : void {
        _${name} = value;
}
Download the FDT template file.

Add comment July 30th, 2008

Parameter passing in AS3 / Flex 3

If you need to do any sort of parameter passing to your AS3 or Flex Swf’s you may be wondering how to do it. In the olden days when you had a _root context on your MovieClips, and thank you very much there were your variables ready and waiting when you loaded your SWF.

Flex / AS3 has a more semantic and structured approach to the problem, well, it puts the values somewhere more semantic and structured at least.

If your application entry point is a subclass of Application you can grab your parameters from MyAppSubclass.application.parameters or in mxml Application.application.parameters.

For example I have a product ID I want to pass to a small swf when I load it.

<mx:Application 
	xmlns:mx="http://www.adobe.com/2006/mxml" 

	creationComplete="initVars()"

	 height="65">
    <mx:Script><![CDATA[
    	
        [Bindable]
        public var productId:String;
        
        // Assign values parameters to properties.
        private function initVars():void {
            productId = Application.application.parameters.productId;
        }
        
    ]]></mx:Script>
    
    <mx:VBox fontSize="18" fontFamily="Arial">
    <mx:HBox>
        <mx:Label text="Product Id: "/>
        <mx:Label text="{productId}" fontWeight="bold"/>
    </mx:HBox>
    </mx:VBox>
</mx:Application>

All I have to do is load the swf with a query string tacked on the end of the swf’s url and supply the key, value pair for my variable.

key: productId
value: 2983127 (or any other product id I need, be careful of invalid strings!)

so the swf load url would look something like…

myflex.swf?productId=2983127

The mxml will run straight from Flex Builder 3 so try it out for yourself and try loading the swf you compile into a browser (without HTML) and put ?productId=THX1138 on the end of the url…

Hey presto.

Add comment April 22nd, 2008

What? Another MySQL Cheatsheet…?

Did the world really need another mysql cheatsheet? I was just idly wasting time recently, and it turned out I was building a MySql cheatsheet… I was probably asleep at the time.

But anyway, it’s here, you want it you say? Well in that case…

MySql Cheatsheet, made while asleep

Add comment April 21st, 2008

MacBook Pro HDD Upgrade

I just recently upgraded my MacBook Pro’s 100Gb HD to a 200Gb Segate drive. I managed to find a nice guide on Extreme Tech and also a helpful video.

One thing I did have issue with was the subsequent guide to getting Mac Os X onto the new drive. Extreme Tech’s article suggests that you install Os X into the new drive with a clean install… I don’t recommend this…

Before you fit your new drive, Invest a few $$$’s in a 2.5” SATA enclosure and use Disk Utility to prepare the drive for OS X. Disk Utility has a Partitioning option which lets you setup the disk and then Erase to format it as Mac OS X ready.

Then, use the Disk Utility Restore tool … drag the current drive to the Source entry and the New drive to the Destination entry…

Using \&quot;Restore\&quot; to copy your HDD

When the copy is complete, replace the current drive with your new HDD (go with the 7200rpm 200Gb Momentus by Segate, if you vaguely trust me.) and it will boot right up and your system will be in the same state as you left it. You’re free to use the old drive however you see fit, perhaps you should put it to use as an external drive in your new SATA enclosure?

For full details of the hardware upgrade I recommend you read the ExtremeTech article

Add comment April 1st, 2008

AS2Dac

Almost 2 years since it was first written, AS2 NaturalDocs AutoDocumentor, now tersely titled AS2Dac has been given a bit of an overhaul.

JavaDoc support and some dynamic command line options have been added, AS3Dac is also in the works.

In the spirit of not repeating myself, there is much going on at the project home at Google Code : http://code.google.com/p/as2dacperl/ (check the Wiki for the full info…)

There is no timeline as yet for the AS3 version release.

Add comment March 12th, 2008

Next Posts Previous Posts

Clicky Web Analytics