CFEclipse and Flex Builder 2

I just installed Flex Builder 2 as a plugin to Eclipse. Previously I was using it as stand-alone. That means it sits along side CFEclipse in the same IDE editor.

I must say, this is a big improvement over what I did yesterday ( with two IDEs opened side by side).

Although, it does look like I need separate projects for CF vs Flex. The ability to create a combined project that uses both technologies would be nice.

I've been experimenting with creating Flex 2 components (It seems like a natural way to build apps). I cannot figure out how create variables inside a component that are accessible from the application which contains the component.

Comments
James's Gravatar All mxml components inside your custom component are by default defined as public and by adding an 'id' property, you can reference them.
# Posted By James | 4/13/06 11:25 AM
João Fernandes's Gravatar Jeff,

You must define public bindable variables in your component

In your application you can use:

<mycomp myproperty="somevalue"/>

in mycomp:

[Bindable]
public var myproperty:myPropertyType;
# Posted By João Fernandes | 4/13/06 11:25 AM
Jeff Houser's Gravatar James,

I was trying to make an Actionscript variable accessible; but you are right the MXML components were accessible w/o problem.

(I discovered that right after I posted)

João,

Thanks that was exactly what I was trying to do. It seems like a much cleaner solution, to me, than creating invisible 'labels' to hold component data.
# Posted By Jeff Houser | 4/13/06 11:52 AM
Ryan Stewart's Gravatar Hey Jeff, I'm pretty sure you should be able to associate Flex/CF nature for a single project. If you right click on the project you should be able to click on "Apply CFE Nature" or if it's a CF project right click and Add Flex Project nature. Is that what you're looking to do or did I misunderstand?
# Posted By Ryan Stewart | 4/13/06 4:23 PM
Jeff Houser's Gravatar Ryan,

I did not know that existed. It seems like that is exactly what I was looking for. Thanks!
# Posted By Jeff Houser | 4/13/06 7:01 PM
David's Gravatar João,
Quick question - in the declaration of "somevalue" at the application level, do you have to declare that as [Bindeable] too?

David
# Posted By David | 4/14/06 8:20 AM
João Fernandes's Gravatar Jeff, all properties that use [Bindable] (even getters and setters) execute automaticaly when that value changes. So if you have a variable in your application that you want to propagate into your custom components when it has been changed, yes, you need to define it as [Bindable].
# Posted By João Fernandes | 4/14/06 9:27 AM
James's Gravatar [Bindable] wouldn't be used unless you'll be listening for changes (ie if the user is logged in)

So in an Application, you could just put 'public var foo:Boolean = true;' (w/out any metadata tags) and reference it as 'Application.application.foo' elsewhere in the app.
# Posted By James | 4/14/06 9:34 AM
David's Gravatar James,
Thanks for the tip - as a matter of interest, you have a double reference to "application" - as I'm new to Flex 2, I don't understand why that is - could you explain?

Thanks,

David
# Posted By David | 4/14/06 9:40 AM
James's Gravatar 'mx.core.Application.application' is a global reference to the top-level Application, but you could also reference the parent using 'uiComponentInstance.parentApplication'

And if there were an hierarchy of Application objects we could traverse up.
# Posted By James | 4/14/06 10:17 AM
David's Gravatar That's great - thanks.
# Posted By David | 4/14/06 10:42 AM
João Fernandes's Gravatar Jeff,

If you want to avoid mx.core.Application.application all over your app, you should take a look at cairgorm. Cairngorm is a MVC framework for Flex. For now is still alpha (for flex2).

If you have any questions about Flex you can contact me anytime.
# Posted By João Fernandes | 4/14/06 3:12 PM
All Content Copyright 2005, 2006, 2007 Jeffry Houser. May not be reused without permission
BlogCFC was created by Raymond Camden. This blog is running version 5.8.