简单扼要的说明一下怎么配置:用到技术 merapi
java:
main可以因为启动服务类。
package merapi.examples.helloworld;
import merapi.Bridge;
import merapi.examples.helloworld.handlers.HelloWorldHandler;
public class HelloWorldRunner
{
//--------------------------------------------------------------------------
//
// Static methods
//
//--------------------------------------------------------------------------
/**
* The main method that starts the Bridge and instantiates the HelloWorldHandler instance.
*/
public static void main( String[] args )
{
Bridge.open();
new HelloWorldHandler();
}
}
message:消息类! 首先必须声明一下消息类型 public static final String HELLO="hello";这句话就是声明消息 字符创可以任意,其他是简单javabean
package merapi.examples.helloworld.messages;
import merapi.messages.Message;
public class HelloWorldMessage extends Message
{
public static final String HELLO = "hello";
public HelloWorldMessage()
{
super();
}
private String helloText ;
public String getHelloText() {
return helloText;
}
public void setHelloText(String helloText) {
this.helloText = helloText;
}
}
handle:
package merapi.examples.helloworld.handlers;
import merapi.examples.helloworld.messages.HelloWorldMessage;
import merapi.handlers.MessageHandler;
import merapi.messages.IMessage;
public class HelloWorldHandler extends MessageHandler
{
// 这个类的第一部分是一个构造函数。
// 在这个构造函数里,我们调用super()这个函数,
// 并且从questionMessage类中传了一个静态变量给它。
// 这个变量是一个字符串类型的,
// 用于申明这个handler将会处理的消息类型的。
// 这个字符串的值可以是任意的,但是得和AIR应用程序中字符串的相匹配。
// 否则在handler将无法收到来自bridge中的消息。
public HelloWorldHandler()
{
super( HelloWorldMessage.HELLO );
}
public void handleMessage( IMessage message )
{
if ( message instanceof HelloWorldMessage )
{
HelloWorldMessage hwMessage = ( HelloWorldMessage ) message;
System.out.println( hwMessage.getHelloText() );
hwMessage.setHelloText( hwMessage.getHelloText() + " - response - " +
Long.toString( System.currentTimeMillis() ) );
// ,然后调用send()函数。调用send()函数将消息返回给bridge,在bridge中消息会等待AIR应用程序来接受它。
hwMessage.send();
}
}
}
ActionScript: 主要映射java类! 也就这个作用! 一定要一样
package merapi.examples.helloworld.messages
{
import merapi.messages.Message;
//这句话就是映射
[RemoteClass( alias="merapi.examples.helloworld.messages.HelloWorldMessage" )]
public class HelloWorldMessage extends Message
{
public static const HELLO : String = "hello";
public function HelloWorldMessage()
{
super( HELLO );
}
public var helloText : String = null;
}
}
MXML:
<?xml version="1.0" encoding="utf-8"?>
<mx:WindowedApplication
xmlns:mx="http://www.adobe.com/2006/mxml"
xmlns:merapiproject="http://merapiproject.net/2009"
xmlns:messages="merapi.examples.helloworld.messages.*"
layout="vertical">
<!-- ==== helloWorldMessage : The message sent accross the bridge 相当于new ======================== -->
<messages:HelloWorldMessage id="helloWorldMessage" helloText="Hello World!!!" />
<!-- ==== helloWorldHandler : The message handler for the HelloWorld.HELLO message type 哪个字段接受数据== -->
<merapiproject:MessageHandler id="helloWorldHandler" type="{ HelloWorldMessage.HELLO }" 消息类型就是与java定义哪里一样 result="handleResult(event)" 回调函数可以这么认为
/>
<mx:Script>
<![CDATA[
import mx.rpc.events.ResultEvent;
private function handleResult(e:ResultEvent):void{
helloWorldMessage=e.result as HelloWorldMessage;
aa.text=helloWorldMessage.helloText;
}
]]>
</mx:Script>
<mx:Button label="Say Hello" click="helloWorldMessage.send()" />
<mx:Label text="" id="aa" />
</mx:WindowedApplication>
jar swc 自己下! swc打包了! 解压即可
建立的都是标准的java Flex AIR项目
air 需要运行环境 自己在adobe下吧!
分享到:
相关推荐
AIR用Flex调用java连数据库和一些主要功能的实现。。如httpService...webSerivce 的调用等等
Java服務與Flex客戶端代码(因上传档案大小限制不含jar包), 附开发步骤详细说明文檔,。
Flex on Java Bernerd Allmon and Jeremy Anderson MEAP Began: May 2008 Softbound print: July 2010 (est.) | 375 pages ISBN: 1933988797 Part 1: Getting started 1. Some Flex with your Java 2. Beginning...
使用AIR/Flex/Action Script語言
Flex3 Java 中文教程 组件 AIR
1. Some Flex with your Java 2. Beginning with Java 3. Getting Rich with Flex 4. Connecting to Web Services Part 2: Strengthening the backend 5. BlazeDS remoting and logging 6. Flex messenging ...
flex在线考试系统 包括教师出题、学生答题、...采用flex plugin开发,前端flex,后端java,mysql数据库。 09年写的,当时还是用Flex3,请自行部署,见谅 放在角落里,有点发霉了,还是晒晒吧。 5分有点贵,但应该是值的
使用java api 编译flex(基于flex sdk4.5,但不依赖sdk) 可以实现自己的编译器 暂只支持编译flex ,as3代码没测试过,编译air未测试 如需要 需要把flexsdk目录中的frameworks/libs/air文件夹考进 flexCompile(当前上传...
Rich Internet Applications With Adobe Flex And Java 2007.pdf <br>Part2
Rich Internet Applications With Adobe Flex And Java 2007.pdf <br>Part1
对C语言、Java语言/JavaEE系统、Ruby on Rails、Flex、Ajax等领域都有深入的研究:国内第一个Flex企业级上线项目核心开发者,属于国内最早一批应用Flex进行企业级开发的软件工程师;国内第一批Ruly on Rails架构的...
3.0语法、Flex组件开发、CSS布局、美化界面、数据传输与交互、AIR平台应用和开发框架Cairngorm等。为了便于读者学习,本书最后两章分别对两个较综合的实例进行分析。详细讲解了Cairngorm开发框架的搭建、组件设计、...
这是一份日文资料,但由于是PPT文件,看图即可学到如何配置...難しいことは置いといて、取り合えず 「BlazeDS」 を使って、Flash、AIRアプリから Javaオブジェクトのメソッドを呼び出すための手順書(Windows版)
In this chapter, integration between Flex and Java is explored using remoting and messagingbased infrastructure. Most of the discussion hovers around BlazeDS, its alternatives and its possible ...
属于AdobeAIR,请用AdobeFlashBuilder打开,属于书《AIR范例精解 创建修改重用》清华大学出版社,第四周内容
FCG是一个开源的AIR应用程序,可以根据可视化的配置来生成Flex代码。 FCG有一些很有意思的特性,包括: 支持Cairngorm和PureMVC框架,当你选择使用其中之一来创建工程的时候,一个基本的框架文件结构会被建立起来。...