Actionscript 3
How to Apply a Stylesheet to a Text Component
Submitted by ben.bishop on Fri, 02/27/2009 - 22:42.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
Submitted by ben.bishop on Wed, 02/11/2009 - 16:53.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
Submitted by ben.bishop on Mon, 10/20/2008 - 17:06.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
Submitted by ben.bishop on Sun, 10/19/2008 - 02:20.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
Submitted by ben.bishop on Fri, 10/17/2008 - 19:15.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.
Flex: How to Detect When the Browser Window Closes
Submitted by ben.bishop on Wed, 11/14/2007 - 02:42.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
Submitted by ben.bishop on Tue, 11/13/2007 - 04:11.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
Submitted by ben.bishop on Sun, 11/11/2007 - 20:36.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
Submitted by ben.bishop on Fri, 10/19/2007 - 21:21.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.
Actionscript/Flex: How to Programmatically Add a Link to a LinkBar
Submitted by ben.bishop on Wed, 10/17/2007 - 03:46.Problem:
You have a LinkBar's dataprovider bound to a viewstack, but you want to add an extra button that opens an URL in a new browser window when clicked.
Solution:
