Flex增删改查
我是初学者,现在自学Flex,谁能给我一个Flex增删改查的小demo,与Oracl数据库交互的,非常感谢!!!
[解决办法]
flex+php
<?xml version="1.0" encoding="utf-8"?>
<s:Application xmlns:fx="http://ns.adobe.com/mxml/2009"
xmlns:s="library://ns.adobe.com/flex/spark"
xmlns:mx="library://ns.adobe.com/flex/mx" minWidth="955" minHeight="600"
>
<fx:Script>
<![CDATA[
import mx.collections.ArrayCollection;
import mx.controls.Alert;
import mx.rpc.events.ResultEvent;
import mx.events.FlexEvent;
import mx.rpc.events.FaultEvent;
//spark.components
import spark.components.NavigatorContent;
//mx.modules.ModuleLoader
import mx.modules.ModuleLoader;
import mx.events.ModuleEvent;
import mx.modules.ModuleManager;
import mx.modules.IModuleInfo;
//creationComplete="application1_creationCompleteHandler(event)"
protected function application1_creationCompleteHandler(event:FlexEvent):void
{
login_user.url="http://192.168.0.5/login.php";
login_user.method="POST";
login_user.send();
}
private function checkLogin(evt:ResultEvent):void
{
/*
if(evt.result.loginsuccess == "yes")
{
Alert.show("Logged In");
}
if(evt.result.loginsuccess == "no")
{
Alert.show("Invalid username/password");
}
*/
Alert.show(evt.result.aa);
Alert.show(evt.result.username);
//Alert.show(login_user.lastResult.aa);
}
protected function service_faultHandler(event:FaultEvent):void
{
//Alert.show("");
Alert.show(event.message.toString(),"请求异常");
}
protected function button1_clickHandler(event:MouseEvent):void
{
// TODO Auto-generated method stub
try
{
displayModule("main/main.swf");
}
catch(e:Error)
{
Alert.show(e.toString());
}
}
/*
private function loadModule(moduleUrl:String):void {
var moduleInfo:IModuleInfo = ModuleManager.getModule(moduleUrl);
//moduleInfoRef 是一个Object,每次加载的时候持有ModuleInfo实例的引用
moduleInfoRef[moduleUrl]=moduleInfo;
moduleInfo.addEventListener(mx.events.ModuleEvent.READY, onModuleReady ) ;
moduleInfo.addEventListener(mx.events.ModuleEvent.UNLOAD,onModuleUnload);
moduleInfo.load(ApplicationDomain.currentDomain);
}
//模块加载完成的监听
private function onModuleReady(event:mx.events.ModuleEvent):void {
var flexModuleFactory:IFlexModuleFactory =event.module.factory;
var module:mx.modules.Module = flexModuleFactory.create() as mx.modules.Module;
module.percentHeight=100;
module.percentWidth=100;
//create a new NavigaorContent to hold the module instance
var container:NavigatorContent = new NavigatorContent();
//set the module url to the NavigatorContent id
container.id=event.module.url;
container.percentWidth = 100;
container.percentHeight = 100;
container.addElement(module);
//vsModules is a ViewStack
vsModules.addElement(container);
vsModules.selectedChild=container;
}
//模块Unlaod的监听,每次移除的时候,这个方法都会执行 ,但是很多时候 控制台没有打出 [卸装 SWF] XXXX.swf。
private function onModuleUnload(event:mx.events.ModuleEvent):void {
trace(event.module.url+" has been unloded!");
}
//---------------
//unload the module
private function removeModule(nav:NavigatorContent):void{
if(nav==null) return;
nav.removeAllElements();
vsModules.removeChild(nav);
var moduleInfo:IModuleInfo = moduleInfoRef[nav.id] as IModuleInfo;
moduleInfo.release();
moduleInfo.unload();
moduleInfo.removeEventListener(mx.events.ModuleEvent.READY, onModuleReady ) ;
moduleInfo.removeEventListener(mx.events.ModuleEvent.ERROR, onModuleError ) ;
moduleInfo.removeEventListener(mx.events.ModuleEvent.UNLOAD, onModuleUnload ) ;
//set to null
moduleInfoRef[moduleUrl]=null;
moduleInfo=null;
//force gc here
try
{
new LocalConnection().connect( "somethingDoesNotExist" );
new LocalConnection().connect( "somethingDoesNotExist" );
}
catch (e:Error) {}
}
*/
private function displayModule(moduleURL:String):void
{
var url:String=moduleLoader.url;
if(url==moduleURL)return;//如果url和传递进来的一样的话,不进行处理
if(url!=null)moduleLoader.unloadModule();//如果url和传递进来的不一样且不为空时,卸载url指定的模块
moduleLoader.url=moduleURL;//给ModulerLoader指定url
}
]]>
</fx:Script>
<fx:Declarations>
<!-- 将非可视元素(例如服务、值对象)放在此处 -->
<mx:HTTPService
id="login_user" result="checkLogin(event);"
fault="service_faultHandler(event);"
useProxy="false" >
<mx:request xmlns="">
<username>{username.text}</username>
<password>{password.text}</password>
</mx:request>
</mx:HTTPService>
</fx:Declarations>
<mx:ModuleLoader id="moduleLoader"/>
<s:Panel x="126" y="50" width="404" height="257">
<s:Label x="32" y="43" text="username"/>
<s:Label x="33" y="122" text="password"/>
<s:Button id="sumbit" x="49" y="167" label="sumbit" click="login_user.send();"/>
<s:TextInput id="username" x="98" y="43"/>
<s:TextInput id="password" x="103" y="112"/>
<s:Button x="206" y="168" label="按钮" click="button1_clickHandler(event)"/>
<s:ModuleLoader id="moduleTest" x="327" y="67">
</s:ModuleLoader>
</s:Panel>
</s:Application>
[解决办法]
Flex增删改查 基本上都是用BlazeDS 通过后端进行增删改查的操作。