TDOT Blog Touchwood Creative

Register | Forgot password?


Touchwood is continuing to grow!

We are looking for talented Flex developers to join our Interactive Group. If you have any interest we would love to meet you. Please email your resume to us at:

jobs@touchwoodcreative.com


Blogs

How to Apply a Stylesheet to a Text Component

Problem:

You want to be able to apply a stylesheet to a text component.

 

Solution:

To solve this problem, we are going to extend the Text component with our own custom text component called "StyleText:"

 

public class StyleText extends Text
{

private var _styleSheet:StyleSheet = new StyleSheet();

public function get styleSheet():StyleSheet{

return _styleSheet;

}
public function set styleSheet(s:StyleSheet):void{

_styleSheet = s;
this.textField.styleSheet = s;

}

public function StyleText()
{

super();

}

}

 

 

New Site Launched

Touchwood is proud to present its new website at http://www.touchwoodcreative.com. The site was developed almost exclusively with the Flex framework as an exercise and proof of concept that developers using Flex can not only build a stable application but can also provide a rich visual experience to the user.

Flex's transitions, parallels, and effects were used extensively to add the more polished elements to the presentation of the agency's capabilities and past work.

Also used was Flex's ability to take XML, parse it, and update the UI according to the XML file's contents. This allows Touchwood to update the site quickly and frequently with cool new client projects. So be sure to check it out frequently!

 

 

A "Link" Approach to Managing Screens in Flex

Problem:

You want to "link" mutliple MXML files to each other via buttons.

Note: For new Flex developers, it is sometimes easier to think of "linking" MXML files together. Also note, because of Flashplayer's garbage collection issues this may not be the most ideal solution for very big applications and a ViewStack may indeed work better.

Solution:

Create a ScreenManager singleton class that clears and creates fresh new instances of MXML components for the application.

Note: You can also use a ViewStack to manage mutliple screens and have navigation devices such as buttons just change the selected index of the ViewStack. However, for this scenaro, let's say we want fresh new screens. (ViewStacks maintain its children's states. So, for example,if you have a form and navigate away from it, if you were to return all of the values would still be there.)

Implementation:

Uniform Link Widths in Flex's LinkBar Component

Problem:

You want the links in the LinkBar component to be the same width.

Solution:

Extend the LinkBar component to have a property called "linkWidth."

public class UniformLinkBar extends LinkBar

{

[Bindable]
public var linkWidth:Number = 50;

Override the createChildren method. In this method bind the new "linkWidth" property to each child's width.

override protected function createChildren():void{

super.createChildren();
for(var i:int = 0; i < this.numChildren; i++){

BindingUtils.bindProperty(getChildAt(i), "width", this, "linkWidth");

}

}

To Implement:

<components:UniformLinkBar linkWidth="100">

Attached is the library project.

Superscript and Subscript TextArea Component

Problem:

You need to display superscripts and subscripts in a TextArea.

 

Solution:

Embed super and sub script fonts and extend the TextArea component to automatically  update the stylesheet object to apply the font to "sup" and "sub" tags. For extra convenience make this a component that can be reused easily.

Cross platform Zinc projects

One of the biggest challenges of developing crossplatform applications using Flash and MDM Zinc is properly loading external assets. Typical assets include images, data (css, xml, txt etc...) and video (flv typically). The main outline of our task is as follows:

  1. Determine what type of path
    we need to properly load each type of asset on each operating system. This
    is the most time consuming part.
  2. Develop a method of
    determining which operating system we are on (without having to change any
    code).
  3. Put together a package of
    classes that detects operating system and returns the proper path. At this
    point it is also helpful to plan on future platforms, such as the AIR
    runtime environment or running on a web server.

So without further ado, let's get on with it...

 

 

Flex: How to Detect When the Browser Window Closes

I came across this thread post by blu3 on the FlashKit forums and thought it was too handy to not share on here.

I managed to pull this off and and here comes the solution. First i
declared cleanUp() function in Flex which does the dirty work and
cleans user's leftovers. Then i use ExternalInterface for registering
my cleanUp() function so that i can access it using JavaScript from
.html wrapper:

Touchwood Presents UI Marker Beta 1

Touchwood is proud to present UI Marker Beta 1. UI Marker is a Flex component that allows users to draw squares, lines, and notes on an AIR application's UI and save the screenshot as a PNG. This tool is valuable for design reviews and/or client input and feedback.

How to implement:

Let's say you want to setup your app to where a user can click F12 and make notations. Here's how you do it.

Actionscript 3: How to Draw a Shape with Flex 3

Problem:

You want to draw a square programmatically using Actionscript's drawing API.

AIR: How to Detect All Link and Image Clicks in a HTMLControl

Problem:

How can an AIR application detect if a link or an image has been clicked inside an HTMLControl?

Solution:

Create an app to loop through all images and links in the web page's DOM and attach click listeners to them.

Syndicate content
© Touchwood Creative 2007 | We use Firefox