Monday, June 23, 2008

Automation.swc locks application

Hi, I had a strange problem at work last week. The problem was when I added automation.swc and automation_agent.swc to a new project I am working on, all controls was lokced. I was not able to click on any objects. But as soon as I removed the swc files, everything worked great.

I did not have the time to take a closer look at the problem until today. And searched flexcoders (a great group by the way for information about Flex and Actionscript), to see if anyone else been through the same thing. And what do you know :-) At this post, I got to this site.

The problem seems to be that if you have an invisible container of some sort that overlaps other containers, that container will steal all the focus from any other container.

The solution to this problem is to add an eventlistener to the stage to be able to locate the container. And when you have discovered the container, add mouseEnabled="false" to it. Then everything should be working!

Thursday, June 12, 2008

Use FunFX together with Watir

Usually Flex applications uses a regular HTML pages for authentication or by other support. When this is the case, FunFX alone is not able to get to the Flex part. In these situations you can use the excellent tool Watir.

To make Watir work together with FunFX you do the same setup as usually with FunFX, but you also require watir, and attaches Watir to the browser FunFX started. With the example below I use the the title of the page to make Watir understand what browser to choose.

@ie = Funfx.instance@ie.start(true)
@ie.speed = 1
@ie.goto("http://localhost/flexapplication.html", "flexapplication")
$browser = Watir::IE.attach(:title, "PageTitle")


When you have done this, both the FunFX instance and the Watir instance is able to control the browser. But one thing you should watch out for is that when FunFX enter the Flex application, it must set the flex object again, so either if you use FunFX to navigate to the Flex application, you can define the flex object in the goto statement. Or you can use the setFlexObject method.

@ie.goto("www.google.com", nil)
$browser.text_field(:name, "q").set "pickaxe"
$browser.button(:name, "btnG").click
@ie.goto("http://localhost/flexapplication.html", "flexapplication")
@ie.button("buttonName").click


@ie.set_flex_object("flexapplication")