ÓÉÓÚFlexÖ»ÊÇÒ»ÖÖ¿Í»§¶Ë¼¼ÊõÆä±¾Éí²¢²»ÄÜÖ±½ÓͬÊý¾Ý¿â½»»¥£¬ÔÚʵ¼ÊµÄÓ¦Óÿª·¢¹ý³ÌÖÐFlexÌṩÁËÈçURLRequest¡¢HTTPService¡¢RemoteObject¡¢WebServiceµÈÀàÒÔʵÏÖͬ·þÎñÆ÷µÄͨѶºÍÊý¾Ý½»»¥£¬ÏÂÃæ×öһЩ½éÉܺÍʵÀý½âÎö:
1¡¢Ê¹ÓÃURLRequestÏò·þÎñÆ÷·¢ËÍÇëÇó£¬Ê¹ÓÃURLLoader½ÓÊÕ·þÎñÆ÷·µ»ØµÄÊý¾Ý:
URLRequestÀà¿É²¶»ñµ¥¸ö HTTP ÇëÇóÖеÄËùÓÐÐÅÏ¢£¬¿ÉÒÔ½« URLRequest ¶ÔÏ󴫵ݸø Loader¡¢URLStream ºÍ URLLoader ÀàÒÔ¼°ÆäËû¼ÓÔØ²Ù×÷µÄ load() ·½·¨ÒÔÆô¶¯ URL ÏÂÔØ;ĬÈÏÇé¿öÏ£¬´«µÝ¸ø url ²ÎÊýµÄ URL ±ØÐëÓëÖ´Ðе÷ÓÃµÄ SWF ÎļþÔÚÍêÈ«ÏàͬµÄÓò£¬°üÀ¨×ÓÓò¡£Èç¹ûÒª´ÓÆäËüÓòÖмÓÔØÊý¾Ý£¬ÇëÔÚ³ÐÔØÊý¾ÝµÄ·þÎñÆ÷ÉÏ·ÅÖÃÒ»¸ö¿çÓò²ßÂÔÎļþ¡£ÓйØURLRequestÏêϸ¿É²Î¿´http://help.adobe.com/zh_CN/AIR/1.1/jslr/flash/net/URLRequest.html
URLVariablesÀàÖ÷ÒªÓÃÀ´ÔÚÓ¦ÓóÌÐòºÍ·þÎñÆ÷Ö®¼ä´«Êä²ÎÊý±äÁ¿;Ïêϸ²é¿´:http://livedocs.adobe.com/flex/3_cn/langref/flash/net/URLVariables.html
URLLoader ÀàÒÔÎı¾¡¢XML¡¢¶þ½øÖÆÊý¾Ý»ò URL ±àÂë±äÁ¿µÄÐÎʽ´Ó URL ·µ»ØÇëÇóµÄÊý¾ÝÏêϸÇë²Î¿´:http://livedocs.adobe.com/fl ......
/*============ʹÓÃ==========*/
var contextmenu:ContextMenuManager=new ContextMenuManager();
contextmenu.add("×î´ó»¯",menuHandle);//menuHandle´¦Àíº¯Êý
/**==================ContextMenuManager.as==========================*/
package file
{
import flash.display.InteractiveObject;
import flash.events.*;
import flash.errors.IllegalOperationError;
import flash.ui.*;
import flash.utils.getQualifiedClassName;
public class ContextMenuManager extends EventDispatcher
{
protected var menu:ContextMenu;
protected var target:InteractiveObject;
public function ContextMenuManager(target:InteractiveObject,hideBuiltInItems:Boolean=true)
{
this. ......
ÔÚ¿ª·¢ÏîĿʱ£¬ÏîĿԽ´ó£¬swfÉú³ÉµÄÌå»ýÔ½´ó£¬¶ÔÓÚ¾ÖÓòÍøÓ°Ïì²»´ó£¬µ«ÊǶÔÓÚ»¥ÁªÍø¾ÍºÜÍ·ÌÛÁË¡£
¼ÓÔØÒ»¸ö½çÃæÒªºÜ¾Ã¡£Ò»°ãÈ˸ù±¾Ã»ÄÍÐÔµÈÄã¼ÓÔØÍê¡£
ΪÁ˼õСswfÌå»ý£¬¸öÈË×ܽáÁËÁ½¸ö°ì·¨¡£°ì·¨ÈçÏ£º
µÚÒ»£¬¾¡Á¿Ê¹ÓÃmodule£¬ÉÙÁ¿Ê¹ÓÃ×Ô¶¨Òå×é¼þ£¬ÕâÑù¿ÉÒÔ¼õÉÙ¼ÓÔØµÄʱ¼ä
µÚ¶þ£¬Ê¹ÓÃRSL£¬¼õСswfÌå»ý¡£RSLʹÓÃÈçÏ£º
ÓÒ»÷ÄãµÄÏîÄ¿----->Properties------>flex Build Path----->Library Path---->Framework linkage:
Ñ¡ÔñRSL£¨Runtime Shared Library£©----->È·¶¨
-------------------------------------------------------------------------
ÔÚʹÓÃRSLºó£¬ÔËÐÐswfʱ³öÏÖÁËSecurityError: Error #2028
: ½öÏÞÓÚÎļþϵͳµÄ SWF Îļþ...
ºóÀ´¾¹ý²éѯ£¬ÖÕÓÚÓеãüĿ¡£RSLÐèÒªnetworkȨÏÞ£¬±ØÐèʹÓÃä¯ÀÀÆ÷ä¯ÀÀ¡£
Èçhttp://192.168.1.2:8080/project/bin/Main.html ......
·¶ÀýÈçÏ£º
var xml:XML=
<body>
text1
<bar>barText1</bar>
<bar>barText1</bar>
text2
</body>
trace(xml.text());//Êä³ö£ºtext1text2
trace(xml.text()[0]);//Êä³ö£ºtext1
trace(xml.text()[1]);//Êä³ö£º text2
trace(xml.child(1).toXMLString());//Êä³ö£º<bar>barText1</bar>
trace(xml.child(1).toString());//Êä³ö£ºbarText1
?
toXMLString()·½·¨£ºÊ¼ÖÕ·µ»ØXML ¶ÔÏóµÄ¿ªÊ¼±êÇ©¡¢ÊôÐԺͽáÊø±êÇ©µÄ×Ö·û´®ÐÍʽ¡£
toString()·½·¨£ºÖ»Êǰ´×Ö·û´®ÐÎʽ·µ»Ø½ÚµãµÄÄÚÈÝ¡£
text()·½·¨£ºÔòÊÇ·µ»ØXML Îı¾½ÚµãµÄËùÓÐ XML ÊôÐ﵀ XMLList ¶ÔÏó£¬ÉÏà ......
1£©XmlÎĵµÊ¾Àý£¨xmlsample.xml£©£º
Code
<?xml version="1.0" encoding="iso-8859-1" ?>
<music>
<song title="Oh,girl">
<artist>The Chi-lites</artist>
<genre>Soul</genre>
<album>A lonely man</album>
<year>1972</year>
</song>
<song title="What if">
<artist>Babyface</artist>
<genre>R&B</genre>
<album>unknown</album>
<year></year>
</song>
<song title="How come,how long">
<artist>Babyface</artist>
<genre>R&B</genre>
<album>The essential babyface</album>
& ......
1£©XmlÎĵµÊ¾Àý£¨xmlsample.xml£©£º
Code
<?xml version="1.0" encoding="iso-8859-1" ?>
<music>
<song title="Oh,girl">
<artist>The Chi-lites</artist>
<genre>Soul</genre>
<album>A lonely man</album>
<year>1972</year>
</song>
<song title="What if">
<artist>Babyface</artist>
<genre>R&B</genre>
<album>unknown</album>
<year></year>
</song>
<song title="How come,how long">
<artist>Babyface</artist>
<genre>R&B</genre>
<album>The essential babyface</album>
& ......
2£©ÈçºÎ´´½¨Ò»¸öxmlÎĵµ
ÓÉÓÚxmlʵÖÊÒ²Ö»ÊÇÒ»¸öÎı¾Îļþ£¬ËùÒÔ×î¼òµ¥Äã¿ÉÒÔÖ±½ÓʹÓÃSystem.IOϵÄÀàÉú³ÉÒ»¸öÎļþ£¬²¢´æ´¢³ÉxmlÎļþ£¬µ±È»£¬ÄãÐèÒªÊÖ¶¯±£Ö¤¸ÃÎļþÐÎʽÁ¼ºÃ£¬±ÈÈç±ØÐëÓиùÔªËØ¡¢±ØÐëÓйرձêÇ©¡¢±ØÐëÕýȷǶÌ׵ȵȡ£
Èç¹ûÄãÀÁµÃ×Ô¼ºÈ¥ÏëÎļþµÄÐÎʽ£¬¿ÉÒÔʹÓÃSystem.XmlϵÄÀà¡£
Code
XmlDocument xdoc = new XmlDocument();
XmlDeclaration xdcl = xdoc.CreateXmlDeclaration("1.0", "iso-8859-1", "");
xdoc.AppendChild(xdcl);
//XmlNode xnode = xdoc.CreateNode(XmlNodeType.XmlDeclaration, "", "");
//xdoc.AppendChild(xnode);
//Of course you can use CreateNode here(with the XmlNodeType.Element),
//so no more questions about 'what difference between this 2 methods?',
XmlElement root = xdoc.CreateElement("music");
xdoc.AppendChild(root);
XmlElement xelm = xdoc.CreateElement("song");
xelm.SetAttribute("title", "Oh,girl");
xelm.InnerText = "Oh,girl,i'd be in trouble if you left me now";
root.AppendChild(xelm);
try
{
xdoc.Save("xmlsample-1.xml");
}
c ......
2£©ÈçºÎ´´½¨Ò»¸öxmlÎĵµ
ÓÉÓÚxmlʵÖÊÒ²Ö»ÊÇÒ»¸öÎı¾Îļþ£¬ËùÒÔ×î¼òµ¥Äã¿ÉÒÔÖ±½ÓʹÓÃSystem.IOϵÄÀàÉú³ÉÒ»¸öÎļþ£¬²¢´æ´¢³ÉxmlÎļþ£¬µ±È»£¬ÄãÐèÒªÊÖ¶¯±£Ö¤¸ÃÎļþÐÎʽÁ¼ºÃ£¬±ÈÈç±ØÐëÓиùÔªËØ¡¢±ØÐëÓйرձêÇ©¡¢±ØÐëÕýȷǶÌ׵ȵȡ£
Èç¹ûÄãÀÁµÃ×Ô¼ºÈ¥ÏëÎļþµÄÐÎʽ£¬¿ÉÒÔʹÓÃSystem.XmlϵÄÀà¡£
Code
XmlDocument xdoc = new XmlDocument();
XmlDeclaration xdcl = xdoc.CreateXmlDeclaration("1.0", "iso-8859-1", "");
xdoc.AppendChild(xdcl);
//XmlNode xnode = xdoc.CreateNode(XmlNodeType.XmlDeclaration, "", "");
//xdoc.AppendChild(xnode);
//Of course you can use CreateNode here(with the XmlNodeType.Element),
//so no more questions about 'what difference between this 2 methods?',
XmlElement root = xdoc.CreateElement("music");
xdoc.AppendChild(root);
XmlElement xelm = xdoc.CreateElement("song");
xelm.SetAttribute("title", "Oh,girl");
xelm.InnerText = "Oh,girl,i'd be in trouble if you left me now";
root.AppendChild(xelm);
try
{
xdoc.Save("xmlsample-1.xml");
}
c ......