Jake Churchill

… on Flex, ColdFusion, FarCry, and much more …

  • Home
  • About

12

Aug

Flex Menu Expanding Over HTML content

Posted by Jake Churchill  Published in Flex

I’ve recently been tasked with figuring this out so I thought I’d share my results with everyone.

The Problem:

Create a Flash/Flex horizontal menu that will overlap the content below it. We don’t know how big the menu might get or what kind of content might end up below it. We do know that layering HTML and Flash does not always work as expected based on which browser you use. Sure, you can use the wmode=”transparent” and put the flash on top of the HTML, but it doesn’t allow you to hover over or click items under the flash.

The Solution:

Use Flex to interface with Javascript to change the SWF Object as needed based on events being listened to inside that same SWF Object. See http://reynacho.com/2008/08/12/flex-calls-to-javascript/ for a tutorial on how to get Flex to call javascript functions.

Read on for the code and example…

continue reading "Flex Menu Expanding Over HTML content"

no comment

12

Aug

Flex - Modify your default build template

Posted by Jake Churchill  Published in Flex

Modifying your default build template is quite simple. There is a template file that is used when building your project. It should reside in the html-template directory at the root of your project in Flex Builder. In Flex Builder 3, the template is named “index.template.html”.

Let’s say you want to modify default parameters in the flash object (one I use is wmode=”transparent” for flex widgets). You would add this to the AC_FL_RunContent() function call (around line 80) and to the noscript block (around line 101). 95% of people hitting the page will hit the AC_FL_RunContent() call so here’s an example of how to modify that:


continue reading "Flex - Modify your default build template"

no comment

12

Aug

Flex calls to Javascript

Posted by Jake Churchill  Published in Flex, Javascript

Flex is great! Javascript can be great! What if two great things got together?

This is a simple code hint which shows how to call javascript functions from Flex and pass data back and forth:

MXML Button:

<mx:Button
id = "button"
label = "Click Me!"
click = "handleButtonClick(event:MouseEvent)
/>

Flex Function:

private function handleButtonClick(event:MouseEvent):void
{
var functionName:String = "handleButtonClick";
var returnData:String = ExternalInterface.call(f, "You clicked the button!");
}

Javascript Function:

function handleButtonClick(message)
{
alert(message);
}

That’s really all there is to it. the ExternalInterface.call() handles everything for you.

By the way, if you wanted to actually return data from the javascript function, you’d just do a standard return and it’d be available in the returnData variable in Flex:

function handleButtonClick(message)
{
alert(message);
return "success";
}

1 comment

8

Aug

Custom Object Parsing Function

Posted by Jake Churchill  Published in Flex

I have been doing some work with AIR and SQLite recently and came across and issue that had to be solved. The issue was that most everything is a VARCHAR in SQLite and I was not able to insert apostrophes (’) into any string field because that is the string delimiter.

A quick Google search revealed that escaping an apostrophe is as simple as putting two of them together (i.e. “Jake’s Blog” becomes “Jake’’s Blog”). Quotation marks remain the same.

Now that I knew what the solution was, I had to implement it. I had about 10 custom VO objects, all with different numbers and kinds of properties. I needed a way to dig into each of them and do a quick string replace on String properties only.

continue reading "Custom Object Parsing Function"

1 comment

29

Jul

DateFormatter parseDateString workaround

Posted by Jake Churchill  Published in Flex

I ran into a situation recently which required me to parse a string into a Date object in Flex. After some searching I found that there’s a wonderful little method in the DateFormatter class called parseDateString. Unfortunately, that method is protected and I couldn’t gain access to it. Luckily, I came accross a blog post that provided a wonderful solution: http://flex2colombia.wordpress.com/2007/02/18/dateformatter-parsedatestring-replacement/

The basis is that the Date class has a static method for parsing dates (parse()) which accepts a single String as a parameter. Here is an example:

var dateString:String = "Tue Jul 29 13:40:56 GMT-0500 2008";
var d:Date = new Date(Date.parse(dateString));

Just like that, you have a Date object to work with in Flex.

The following string formats are acceptable (all of which are recognized by Flex as a Date)

  • MM/DD/YYYY HH:MM:SS TZD
  • HH:MM:SS TZD Day Mon/DD/YYYY
  • Mon DD YYYY HH:MM:SS TZD
  • Day Mon DD HH:MM:SS TZD YYYY
  • Day DD Mon HH:MM:SS TZD YYYY
  • Mon/DD/YYYY HH:MM:SS TZD
  • YYYY/MM/DD HH:MM:SS TZD
no comment

20

May

Flex Datagrid Sorting

Posted by Jake Churchill  Published in Flex

I’ve been helping out with a flex project at work and have been learning some really cool things about it. Coming from a java background a lot of this is familiar but Flex has some really neat features built in.

One that I found recently is the Sort class in the collections package. Pretty much all UI components (Lists, Datagrids, etc) take some kind of collection as their data provider. The question came up, “How do you sort a datagrid manually?” We all know you can click the labels and the grid will sort itself but how do you do that in code. Here’s how:

// Create a new Sort Object
mySort = new Sort();

// Create a SortField Object
// The paramater is the field in the Array Collection to sort on
sortByLabel = new SortField("labelField");

// add Fields to your Sort Object.
// This is standard array notation so multiple sorts would be [sort1,sort2,sort3]
mySort.fields=[sortByLabel];

// set the sort object as the Array Collections sort
myArrayCollection.sort=mySort;

// refresh the Array Collection
myArrayCollection.refresh();

Now, assuming you have bound your data provider in your datagrid (i.e. dataProvider=”{myArrayCollection}”) the datagrid will sort as soon as the Array Collection is refreshed.

A big thanks to Bruce Phillips’ post for pointing me in the right direction.

no comment

Search

Blog Feed

  • Add blog to any reader
  • Comments Rss
August 2008
M T W T F S S
« Jul    
 123
45678910
11121314151617
18192021222324
25262728293031

Subscribe to Blog

Your email:  
Subscribe Unsubscribe  

Archives

Categories

  • Browsers (2)
  • CFEclipse (1)
  • ColdFusion (5)
  • CSS (8)
  • Farcry (32)
    • Farcry Examples (2)
    • Farcry Users (1)
  • Flash (1)
  • Flex (6)
  • Javascript (4)
  • Life & Fun (3)
  • Microsoft Office (1)
  • SQL (1)
  • Uncategorized (2)

Recent Posts

  • Flex Graduated Slider
  • Flex Menu Expanding Over HTML content
  • Flex - Modify your default build template
  • Flex calls to Javascript
  • Custom Object Parsing Function

Recent Comments

  • Jake Churchill » Post Topic » Flex Menu Expanding Over HTML content on Flex calls to Javascript
  • Dan Wilson on Custom Object Parsing Function
  • Jake Churchill on Javascript Popup with graceful fallback
  • Jake Churchill on Farcry Custom Config
  • Geoff Bowers on Farcry Custom Config

Recent Post

  • Flex Graduated Slider
  • Flex Menu Expanding Over HTML content
  • Flex - Modify your default build template
  • Flex calls to Javascript
  • Custom Object Parsing Function
  • DateFormatter parseDateString workaround
  • CSS Presentation
  • Farcry Custom Config
  • Flex Datagrid Sorting
  • ColdFusion Implementation of Virtual Merchant

Recent Comments

  • Jake Churchill » Post Topic &… in Flex calls to Javascript
  • Dan Wilson in Custom Object Parsing Function
  • Jake Churchill in Javascript Popup with graceful fallback
  • Jake Churchill in Farcry Custom Config
  • Geoff Bowers in Farcry Custom Config
  • Jake Churchill in Farcry Custom Config
  • Mark Kruger in Farcry Custom Config
  • Christopher Wigginton in Multiple langage sites in Farcry
  • selfprodigy in dmFlash Technique
  • Sebastiaan in Javascript Popup with graceful fallback
© 2008 Jake Churchill is proudly powered by WordPress
Theme designed by Roam2Rome