wood burning stoves 2.0*
The moose likes Flex and the fly likes flex 4 Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


JavaRanch » Java Forums » Frameworks » Flex
Bookmark "flex 4" Watch "flex 4" New topic
Author

flex 4

jp roberts
Greenhorn

Joined: Feb 19, 2009
Posts: 14
Will/can one use flex objects in a web page like one can use a dojo widget. Like just using a flex datagrid embedded on a web page and having the ability to communicate with it via javascript?
Paul Sturrock
Bartender

Joined: Apr 14, 2004
Posts: 10336

Yes and no. You can embed Flash applications in web pages, and Flex provides a mechanism (ExternalInterface) to interface with JavaScript running in the host page. But you can't embed the component directly, you need to embed an Application (though there is nothing to prevent the application just containug a DataGrid).

(NB: please UseAMeaningfulSubjectLine when posting)


JavaRanch FAQ HowToAskQuestionsOnJavaRanch
Dan Orlando
author
Ranch Hand

Joined: Mar 04, 2010
Posts: 31
Your DataGrid would be compiled to a SWF which would then be embedded via the html object tag. You can then use the ExternalInterface API (part of AS3) to communicate with javascript. Using this method, you can make direct calls to your JS methods, passing arguments, and assign callback functions. This is a bi-directional relationship that is initialized at runtime as well. In other words, the communication does not have to be initiated by Flex (the SWF). Its actually quite easy when you realize its just like one object talking to another, but each with their own API. Hope this makes sense.


Dan Orlando
Adobe Community Professional
Author, Flex 4 in Action (Manning Press)
Joel Hooks
author
Greenhorn

Joined: Feb 17, 2010
Posts: 15
jp roberts wrote:Will/can one use flex objects in a web page like one can use a dojo widget. Like just using a flex datagrid embedded on a web page and having the ability to communicate with it via javascript?


One thing about Flex is the size of the framework in the embedded swfs. It is rather large. However, Adobe provides the framework in signed runtime-shared-libraries (RSL) that are cached by the Flash Player. This means that if the visitor has already cached the RSLs then they don't need to retrieve the framework. It makes your SWFs acceptable in terms of size. As Dan says, communicating with the SWF via the ExternalInterface is really easy. The SWF object is a first-class JavaScript citizen. You can do some really cool things this way.
 
GeeCON Prague 2014
 
subject: flex 4