Ask a Question related to Macromedia Flex General Discussion, Design and Development.
-
fisad #1
Content is not allowed in prolog
I try php code attached (tree_source.php), but, in Flex Builder 3 application,
line 43:
<mx:XML id="dp" source="data/tree_source.php" />
Flex show the error:
"Problem parsing external XML: C:\xampp\htdocs\Tree
Gallery\src\data\tree_source.php - (line 43) Content is not allowed in prolog."
??? Any help me, please.
Thnak in advance
tree_source.php
--------------------------------------------------
<?php
$path = "images";
echo '<?xml version="1.0" encoding="UTF-8"?>' . "\n";
echo "<root>"."\n";
structure($path,$path);
echo "</root>";
// Function
function structure($rootdirpath,$dir)
{
unset($root);
if($dp = @opendir($rootdirpath))
{
for($i=0;($file=readdir($dp))!==false;$i++)
{
if (is_dir($rootdirpath."/".$file) && $file != "." && $file != "..")
{
echo "<node label=\"".$file."\">"."\n";
structure($rootdirpath."/".$file,$dir);
echo "</node>\n\r";
}
}
}
closedir($dp);
}
?>
------------------------------------------------
Flex Builder 3 code:
------------------------------------------------------
<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml"
layout="absolute"
width="100%" height="100%">
<mx:Script>
<![CDATA[
import mx.events.ListEvent;
import mx.collections.ICollectionView;
import mx.events.ListEvent;
private function tree_itemClick(evt:ListEvent):void {
var t:Tree = evt.currentTarget as Tree;
var dataObj:Object = evt.itemRenderer.data;
var item:Object = Tree(evt.currentTarget).selectedItem;
if (tree.dataDescriptor.isBranch(item)) {
tree.expandItem(item, !tree.isItemOpen(item), true);
}
if (dataObj.hasOwnProperty("@src")) {
swfLoader.source = dataObj.@src;
} else if (t.dataDescriptor.isBranch(t.selectedItem)) {
swfLoader.source = null;
panel.status = "";
}
}
private function tree_labelFunc(item:Object):String {
var suffix:String = "";
if (tree.dataDescriptor.isBranch(item)) {
suffix = " (" + item.children().length() + ")";
}
return item.@label + suffix;
}
private function swfLoader_complete(evt:Event):void {
panel.status = (swfLoader.bytesTotal/1024).toFixed(2) + 'KB';
}
]]>
</mx:Script>
<mx:XML id="dp" source="data/tree_source.php"></mx:XML>
<mx:HDividedBox width="100%" height="100%" horizontalCenter="12"
verticalCenter="12">
<mx:Panel width="200" height="100%">
<mx:Tree id="tree"
dataProvider="{dp}"
labelFunction="tree_labelFunc"
showRoot="false"
width="100%"
height="100%"
itemClick="tree_itemClick(event);" />
</mx:Panel>
<mx:Panel id="panel"
width="100%"
height="100%"
backgroundColor="white">
<mx:SWFLoader id="swfLoader"
scaleContent="true"
width="100%"
height="100%"
complete="swfLoader_complete(event);" horizontalAlign="center"
verticalAlign="middle"/>
<mx:ControlBar>
<mx:LinkButton label="{swfLoader.source.toString()}" />
</mx:ControlBar>
</mx:Panel>
</mx:HDividedBox>
</mx:Application>
-----------------------------------------------------
fisad Guest
-
Literal content is not allowed within a CustomControl?
Is there a way to put content between tags of a custom control so that it will populate the defaultproperty such as my TabLabel property? When I... -
Need help with Content-Disposition Content-Type
I am trying to use the following script to allow users to download files with some of the file name stripped off. This script is for use on my... -
PDF security - printing allowed but changes not allowed?
Adobe Acrobat 6 Professional - on a PC. how can i restrict changes to a pdf while allowing printing? i don't want to have to give passwords or... -
Prolog like facilities.
Somebody asked me to do something that was partially solved by tsort, but the next step exceeds the limitations of tsort. After a bit of thought... -
levancho #2
Re: Content is not allowed in prolog
execute this : C:\xampp\htdocs\Tree Gallery\src\data\tree_source.php
in your browser and make sure xml has no spaces or some other chars on top, or somewhere else, it must be well formed xml.
levancho Guest
-
fisad #3
Re: Content is not allowed in prolog
I execute code in browser and don't show has no spaces or some other chars
somewhere, I saved with notepad in correct format but nothing.
I have following code for create xml file with php, this xml file read correct
in Flex:
-------------------------------------
<?php
$path = "images";
$fp=fopen("data/tree_source.xml","w");
fwrite($fp,'<?xml version="1.0" encoding="UTF-8"?>' . "\n");
fwrite($fp,"<root>"."\n");
structure($path,$fp,$path);
fwrite($fp,"</root>");
fclose($fp);
// Function
function structure($rootdirpath,$fp,$dir)
{
unset($root);
if($dp = @opendir($rootdirpath))
{
for($i=0;($file=readdir($dp))!==false;$i++)
{
if (is_dir($rootdirpath."/".$file) && $file != "." && $file != "..")
{
fwrite($fp,"<node label=\"".$file."\">"."\n");
structure($rootdirpath."/".$file,$fp,$dir);
fwrite($fp,"</node>\n\r");
}
}
}
closedir($dp);
}
?>
------------------------------
I need know how execute this code from Flex at any time for refresh contens of
tree, one at start application, other when de directory structure has changed.
Any example code for help me, please.
Thank in advance-
fisad Guest



Reply With Quote

