源贴地址 http://www.riachina.com/showtopic.aspx?topicid=8556#
由于Localconncetion的某些限制(一台客户只可以使用特定名字的一个连接,这样的程序如果开两个窗口就会发生异常),今天闲着没事做了一个这样的试验。让Flash CS3和Flex的代码可以相互调用,为了显示效果,在双方的界面分别放置了一个文本输入框和一个按钮。
这是Flex端的代码:
<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml">
<mx:Script>
<![CDATA[
//把当前的application引用告诉swf
private function onSwfLoaded(event:Event):void{
Object(myloader.content).setApp(this);
}
//准备给swf调用的方法
public function appshowtext(str:String):void{
textinput.text=str;
}
]]>
</mx:Script>
<mx:SWFLoader id="myloader" source="local.swf" creationComplete="onSwfLoaded(event)"/>
<mx:TextInput id="textinput"/>
<mx:Button label="send to local.swf" click="Object(myloader.content).swfshowtext(textinput ......
只是简单实现了一下计算。主要是练下手。
实现了鼠标跟键盘的事件响应。
-----------------------------
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute"
width="198" height="224" fontSize="12" themeColor="#4D8853" borderColor="#B1C2CE" backgroundGradientAlphas="[1.0, 1.0]"
backgroundGradientColors="[#DFDCDC, #196722]"
applicationComplete="initApp();"
>
<mx:Script>
<!--[CDATA[
var one:int = 0; //第一个数
var two:int = 0; //第二个数
var jg:int = 0; //结果
var other = 0; //操作符0,没.1,+,2-,3*,4/
var sate:int = 1; //1是输入第一个数,2是第二个
//临时存储文本框中的数字
internal function but_1():void
{
sum.text += 1;
}
internal function but_2():void
{
sum.text += 2;
}
internal function but_3():void
{
sum.text += 3;
}
internal function but_4():void
{
sum.text += 4;
}
internal function but_5():void
{
sum.text += 5;
}
......
<mx:TextInput id="userName" maxChars="4" restrict="a-zA-Z" />
restrict属性确实可以输入正则表达式,进行输入的验证。
但是在程序执行的时候如果为userName.text = "999"还是可以成功的。
待续。。。。学习中。。。 ......
上次听朋友提起现在再用Flex做项目,闲暇之余在自己的电脑上配置了Flex + myeclipse的开发环境。虽然开发环境搭建花了不少的时间,也遇到了不少问题。再解决这些问题的时候,也找了不少的资料,学到了不少东西。呵呵
继续研究学习................... ......
<?php
include('xml.php');
$data = XML_unserialize($xml);
?>
$xml即是xml文件的内容,$data是解析出的数组;
<?php
include('xml.php');
$xml = XML_serialize($data);
?>
以上为使用实例,分别解析xml文档和生成xml格式的数据
xml.php源码
<?php
###################################################################################
#
# XML Library, by Keith Devens, version 1.2b
# http://keithdevens.com/software/phpxml
#
# This code is Open Source, released under terms similar to the Artistic License.
# Read the license at http://keithdevens.com/software/license
#
###################################################################################
###################################################################################
# XML_unserialize: takes raw XML as a parameter (a string)
# and returns an equivalent PHP data structure
###################################################################################
function & XML_unserialize(&$xml ......
在Button上触摸按下的时候,Button有focused,pressed和default状态,可以使用不同的图片来显示这三种状态。
先定义一个名为btnselector.xml文件,代码如下:
<?xml version="1.0" encoding="UTF-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item
android:state_focused="true"
android:state_pressed="false"
android:drawable="@drawable/focused"
></item>
<item
android:state_focused="true"
android:state_pressed="true"
android:drawable="@drawable/focusedpressed"
></item>
<item
android:state_focused="false"
android:state_pressed="true"
android:drawable="@drawable/pressed"
></item>
<item
android:drawable="@drawable/default"
></item>
</selector>
ImageButton使用btnselector.xml如下:
<ImageButton
android:id="@+id/stop"
android:layout_width="wrap_content"
android:l ......