QTP runtime error. TypeError: Error #1006: showConnectionAttemptMessage is not a function.

January 26, 2012 Leave a comment

If you compile an air application against the latest Flex 4.6 SDK and include the QTP and automation libraries, you will hit a wall:

TypeError: Error #1006: showConnectionAttemptMessage is not a function.
Read more…

Categories: Uncategorized

DropDownController PopupAnchor

November 8, 2011 Leave a comment

Lets pretend you have a popup that you want to show when a button is clicked, as in the following example:

<?xml version="1.0" encoding="utf-8"?>
<s:WindowedApplication 
	xmlns:fx="http://ns.adobe.com/mxml/2009"
	xmlns:mx="library://ns.adobe.com/flex/mx"
	xmlns:s="library://ns.adobe.com/flex/spark">
	
	<s:Button 
		label="Some Button that pops something up"
		horizontalCenter="0"
		verticalCenter="0"
		click="popup.displayPopUp = true;"/>

	<s:PopUpAnchor 
		id="popup"
		right="0"
		bottom="0">
		<s:Group>
			<s:Rect 
				width="50"
				height="50">
				<s:fill>
					<s:SolidColor color="0xFF00FF"/>
				</s:fill>
			</s:Rect>
		</s:Group>
	</s:PopUpAnchor>

</s:WindowedApplication>

How do you easily manage when the popup is closed in this case?
Read more…

Garbage Collection Strategy Reiterated

November 7, 2011 1 comment

A new article was recently published on adobe’s devnet providing another recap of how memory is managed by Flash. I wanted to reiterate the importance of diligently clearing the stack memory of references to the heap memory in order to minimize the work of the collector in the Mark and Sweep phase.

You, as the developer, can optimize your code by helping the Mark and Sweep phases of garbage collection occur less often. By keeping your stack references cleared of objects on the heap, the zero count table algorithm can clean up the memory before mark and sweep has to occur.

Getter & Setter accessors with different namespaces

October 21, 2011 2 comments

Although the bug is still open, you are able to create a getter/setter combo for a property with different namespaces. Sweet!

You will get a compile error when trying to write to the read only property, and you will get a runtime error if you try bracket notation on the object to set the property.

<?xml version="1.0" encoding="utf-8"?>
<s:WindowedApplication 
	xmlns:fx="http://ns.adobe.com/mxml/2009"
	xmlns:mx="library://ns.adobe.com/flex/mx"
	xmlns:s="library://ns.adobe.com/flex/spark">

	<fx:Script>
		<![CDATA[
			import mx.events.FlexEvent;

			private var _myVar:Boolean;

			public function get myVar():Boolean
			{
				return _myVar;
			}

			//Private/Protected/Internal/etc...
			private function set myVar(value:Boolean):void
			{
				_myVar = value;
			}
		]]>
	</fx:Script>
</s:WindowedApplication>

Categories: Uncategorized

ButtonBar radio logic hack

September 30, 2011 Leave a comment

Update: Set the requireSelection property to true.

When the button bar is used as a navigation tool for a set of tabs, it doesn’t make sense for the selected button to be unselected if the user clicks on it.

It is also fairly typical for a result handler of the IndexChangeEvent.CHANGED to utilize the button bar’s selectedItem property to access a piece of data. This causes runtime errors when the selected item is no longer selected because of a re-click on the selected button.

Read more…

Workspace in use or Cannot be Created

September 23, 2011 Leave a comment

If you close FlashBuilder and it doesn’t shut down correctly, sometimes a .lock file will be left in the .metadata directory of your workspace.

If you try and restart FB with the .lock file present, you will get an error message about the workspace being in use. Either make sure the java program is killed or remove the lock file manually in order to reload FB.

This seems to happen to me every time I shut down with the latest version ]:

mx Vertical Scroll Position

June 14, 2011 2 comments

In regards to my post about maintaining vertical scroll position, James asked how the same would be done for mx based components. Here is an example using an mx:DataGrid.

Read more…

Flex 4 <s:Rect/> height limit of 10,000?

In my post about vertical scroll speed I show a code example of a scroller with several nested groups. A typical design of websites these days is to have a content area in the middle with an ever-expanding height and some sort of repeating background or colors on the sides – Just look at the layout of the majority of blogs, including my own.

Writing a flex app with the same design where you can scroll a lot of content vertically with a solid background color is a pretty typical use-case, but you will quickly find a limitation with using the primitive class Rect as a background: maxHeight = 10,000.

Read more…

Simple TLF Text Editor

I found a great TLF editor that is simple and to the point, it is under the MIT license, and is of course open source.

I don’t remember the combination of search terms to find it, but I’ve looked for something like this before and was unable to find it despite it being written in Q3 last year. The other examples that I’ve seen are way too heavy or are just plain bad.

Flex 4 Vertical Scroll Speed

May 18, 2011 9 comments

By default, scrolling content when using the Scroller component occurs very slowly – Even down to 1px per event.

Try running the following example:

<?xml version="1.0" encoding="utf-8"?>
<s:Application xmlns:fx="http://ns.adobe.com/mxml/2009" 
			   xmlns:s="library://ns.adobe.com/flex/spark" 
			   xmlns:mx="library://ns.adobe.com/flex/mx" minWidth="955" minHeight="600">
	<s:Scroller width="100%" height="100%">
		<s:Group width="100%" height="100%">
			<s:Group width="100%" height="100%">
				<s:VGroup width="100%" height="100%" horizontalAlign="center">
					<s:Label text="I need to be scrolled, man!" height="50"/>
					<s:Label text="I need to be scrolled, man!" height="50"/>
					<s:Label text="I need to be scrolled, man!" height="50"/>
					<s:Label text="I need to be scrolled, man!" height="50"/>
					<s:Label text="I need to be scrolled, man!" height="50"/>
					<s:Label text="I need to be scrolled, man!" height="50"/>
					<s:Label text="I need to be scrolled, man!" height="50"/>
					<s:Label text="I need to be scrolled, man!" height="50"/>
					<s:Label text="I need to be scrolled, man!" height="50"/>
					<s:Label text="I need to be scrolled, man!" height="50"/>
					<s:Label text="I need to be scrolled, man!" height="50"/>
					<s:Label text="I need to be scrolled, man!" height="50"/>
					<s:Label text="I need to be scrolled, man!" height="50"/>
					<s:Label text="I need to be scrolled, man!" height="50"/>
					<s:Label text="I need to be scrolled, man!" height="50"/>
					<s:Label text="I need to be scrolled, man!" height="50"/>
					<s:Label text="I need to be scrolled, man!" height="50"/>
					<s:Label text="I need to be scrolled, man!" height="50"/>
					<s:Label text="I need to be scrolled, man!" height="50"/>
					<s:Label text="I need to be scrolled, man!" height="50"/>
					<s:Label text="I need to be scrolled, man!" height="50"/>
					<s:Label text="I need to be scrolled, man!" height="50"/>
					<s:Label text="I need to be scrolled, man!" height="50"/>
					<s:Label text="I need to be scrolled, man!" height="50"/>
					<s:Label text="I need to be scrolled, man!" height="50"/>
					<s:Label text="I need to be scrolled, man!" height="50"/>
					<s:Label text="I need to be scrolled, man!" height="50"/>
					<s:Label text="I need to be scrolled, man!" height="50"/>
					<s:Label text="I need to be scrolled, man!" height="50"/>
				</s:VGroup>
				<s:layout>
					<s:VerticalLayout paddingBottom="100" paddingLeft="100" paddingRight="100" paddingTop="100"/>
				</s:layout>
			</s:Group>
		</s:Group>
	</s:Scroller>
</s:Application>

In order to bring scrollable content using a Scroller up to normal web standards (say 50px or 100px per event) with a setup like the above, you have to override the VScrollbar and assign a custom skin to the scroller that uses the override.

Read more…

Categories: Flex 4 Examples