CFFORM com ActionScript restrito, onde?
Para encerrar o ano de 2006, estou postando mais um filme sobre meus experimentos com CFFORM (CFMX 7.0.2) e ActionScript, espero que aprecie o mesmo tanto que apreciei.
youtube
ColdFusion RIA Flash Flex Apollo Webdesign WebDeveloper Flash Remoting Tutorial book meeting presentation website linux youtube google connect breeze mxstudio cf-brasil cfml mxml php xml javascript wsdl
<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml"
layout="absolute" creationComplete="myload.send()">
<mx:Panel layout="absolute" id="panel1" title="Tree" cornerRadius="13"
width="321" height="236">
<mx:Tree x="10" y="10" width="282" height="146" id="myTree"
dataProvider="{listDP}" labelField="@id"></mx:Tree>
</mx:Panel>
<mx:Script>
<![CDATA[
import mx.rpc.events.ResultEvent;
import mx.collections.XMLListCollection;
import mx.controls.Alert;
[Bindable]
private var listDP:XMLListCollection = new XMLListCollection(new XMLList());
private function loadResult(event:ResultEvent):void{
var keys:Object = {
faturamento:["id","diafatura","empresa","cliente","valor"],
empresas:["id","codigo","razaoSocial","cnpj","observacao","created_at","updated_at","lock_version"]
};
var i:Number = 0;
var strNode:String = "";
var newNode:XML;
for(var x:String in myload.lastResult.tabela){
newNode = XML("<tabela id='"+x+"' data='"+x+"' />");
listDP.addItem(newNode);
for(var y:Number = 0; y < event.result.tabela[x][keys[x][0]].length;y++){
strNode = "<registro ";
for(var z:Number = 0 ; z < keys[x].length ;z++){
strNode += keys[x][z]+"='"+event.result.tabela[x][keys[x][z]][y]+"' ";
}
strNode += " />";
newNode = XML(strNode);
listDP[i].appendChild(newNode);
}
i++;
}
}
]]>
</mx:Script>
<mx:HTTPService id="myload" url="http://localhost:8080/cfusion/file.xml" result="loadResult(event)" />
</mx:Application>
<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml"
layout="absolute" creationComplete="init();"
viewSourceURL="srcview/index.html">
<mx:Script>
<![CDATA[
import mx.controls.treeClasses.TreeListData;
import mx.events.TreeEvent;
import mx.controls.Alert;
import mx.collections.XMLListCollection;
import mx.utils.ObjectUtil;
[Bindable]
private var dbTree:XML;
private function init():void
{
dbTree =
<node label="root" data="data">
<node label="label 0" data="data" />
<node label="label 1" data="data" />
</node>;
}
private function addNodeAt(e:Event):void
{
if(arvore.selectedItem != null){
var i:Number = (arvore.selectedItem as XML).children().length();
var n:XML = XML("<node label='label "+i+
"' data='data' />");
arvore.selectedItem.item = n;
//arvore.selectedItem = null;
arvore.validateNow();
}else{
Alert.show("Selecione um item","Error");
}
}
private function removeNode(e:Event):void
{
if(arvore.selectedItem != null){
try{
var target:XML = arvore.getParentItem(arvore.selectedItem);
delete target.node[arvore.selectedItem.childIndex()];
} catch(e:Error){
for(var i:String in arvore.dataProvider){
if(arvore.dataProvider[i].@label==arvore.selectedItem.@label){
arvore.dataProvider.removeItemAt(i);
break;
}
}
}
arvore.selectedItem = null;
arvore.validateNow();
}else{
Alert.show("Selecione um item","Error");
}
}
]]>
</mx:Script>
<mx:Tree
width="300"
height="300"
id="arvore"
labelField="@label"
dataProvider="{dbTree.children()}"
openDuration="0"
></mx:Tree>
<mx:Button id="addNode" y="310" width="80"
label="addNode" click="addNodeAt(event)" />
<mx:Button id="delNode" y="310" x="90" width="80"
label="delNode" click="removeNode(event)" />
</mx:Application>
package lib
{
import mx.core.UIComponent;
import flash.display.Sprite;
import flash.events.MouseEvent
public class Circle extends UIComponent{
private var c:Sprite;
public function Circle(){
super();
c = new Sprite();
c.graphics.beginFill(0xFFCC00);
c.graphics.drawCircle(100, 100, 50);
this.addChild(c);
}
private function DownHandler(event:MouseEvent):void
{
var sprite:Sprite = Sprite(event.target);
sprite.startDrag();
}
private function UpHandler(event:MouseEvent):void{
var sprite:Sprite = Sprite(event.target);
sprite.stopDrag();
}
[Inspectable(category="General")]
public function enableDrag(enable:Boolean):void{
if(enable){
c.addEventListener(MouseEvent.MOUSE_DOWN, DownHandler);
c.addEventListener(MouseEvent.MOUSE_UP, UpHandler);
}else{
c.removeEventListener(MouseEvent.MOUSE_DOWN, DownHandler);
c.removeEventListener(MouseEvent.MOUSE_UP, UpHandler);
}
}
}
}