PDA

View Full Version : e4x and images


stonyx
06-26-2006, 09:55 PM
hi everyone
my question i think is simple but i'm really new in flex and ActionScript

i have this mxml
<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.macromedia.com/2005/mxml" xmlns="*"
creationComplete="srv.send()" viewSourceURL="srcview/index.html">
<mx:Style source="main.css"/>

<mx:Script>

<![CDATA[
import mx.styles.StyleManager;

private function filterProduct(item:Object):Boolean
{
return item.name.match(new RegExp("^" + inputText.text, "i\*" + /abc|xyz/));
}

]]>
</mx:Script>
<mx:HTTPService id="srv" url="datos/datos2.xml"
resultFormat="e4x" />
<mx:XMLListCollection id="xlc"
source="{srv.result.*}"
filterFunction="filterProduct"/>
<mx:Panel width="568" height="569" layout="absolute" backgroundColor="#800000">
<mx:DataGrid dataProvider="{xlc}" height="485"
editable="false" width="150" id="datagrid" scroll="true" change="xlc.refresh()">
<mx:layoutConstraints>
<mx:Anchor top="5" left="5"/>
</mx:layoutConstraints>
<mx:columns>
<mx:Array>
<mx:DataGridColumn columnName="name"/>
</mx:Array>
</mx:columns>
</mx:DataGrid>

<mx:TextArea width="353" height="291" textAlign="justify" htmlText="{datagrid.selectedItem.desc}"
wordWrap="true" styleName="main.css">
<mx:layoutConstraints>
<mx:Anchor right="25" top="5"/>
</mx:layoutConstraints>
</mx:TextArea>
<mx:Image x="374" y="304" width="164" height="181" source="{datagrid.selectedItem.imagen}"/>
<mx:ControlBar>
<mx:layoutConstraints>
<mx:Anchor bottom="0"/>
</mx:layoutConstraints>
<mx:TextInput id="inputText" width="154"
change="xlc.refresh()" text="Buscar" backgroundColor="#f0eff1"/>
</mx:ControlBar>
</mx:Panel>

</mx:Application>



this is part of the xml file
<?xml version="1.0"?>
<catalog>
<libro>
<name>A orillas de una laguna.</name>
<desc><![CDATA[Libro de Edmundo Batres Ledón, Roque ]]> Ballinas Ballinas, Francisco Fonz Chan,</desc>
<imagen>A orillas de una laguna.jpg</imagen>
<audio>AUDIO/1.mp3</audio>
<video>VIDEOS/lema.flv</video>
<otros>OTROS/Discurso por el instituto.pdf</otros>
</libro>
<libro>
<name>Abdo Andrade, Alberto. </name>
<desc><![CDATA[Médico cirujano. Nació el 13 de mayo de 1957, originario de Tabasco. ]]></desc>
<imagen>FOTOS/Abdo Andrade, Alberto. jpg</imagen>
<audio>AUDIO/2.mp3</audio>
</libro>
<libro>
<name>Abdo Arias, Williams Alejandro. </name>
<desc><![CDATA[Maestro en Derecho Constitucional y Amparo. ]]></desc>
<imagen>FOTOS/Abdo Arias, Williams Alejandro. jpg</imagen>
<audio>AUDIO/3.mp3</audio>
</libro>
<libro>
<name>Abdo Francis, Jorge.</name>
<desc><![CDATA[10 de abril de 1958. Licenciado y doctorado en Derecho por la UNAM. Ha sido profesor en la ]]></desc>
<imagen>FOTOS/Abdó, Jorge.jpg</imagen>
</libro>
<libro>
<name>Abogado General. </name>
<desc><![CDATA[Área que depende directamente de la Rectoría de la <B>UJAT</B>; tiene como objetivo representar ]]></desc>
<imagen>Abogado General. </imagen>
</libro>
what i want to do is to show the image when i click on any name on the datagrid
when i run the file it gives me an error but if i erase the code of the mx:image it runs perfect

thanks

stonyx
06-30-2006, 07:18 PM
any one
helloooooooooooooooo"

so nobody has work with e4x before?, or you just to busy to answer?:eek:

at least answer something like i don't know or stoo asking stupid questions:mad:

CyanBlue
06-30-2006, 07:20 PM
I don't know... and I don't know why I am responding when I don't know the answer... :)

nirth
07-01-2006, 05:21 PM
i could be wrong, but maybe it is becouse your server does not "understand" spaces in file names ie FOTOS/Abdo Arias, Williams Alejandro. jpg

Tell me does flex plays mp3 or you have similar problem?

stonyx
07-03-2006, 05:00 PM
i could be wrong, but maybe it is becouse your server does not "understand" spaces in file names ie FOTOS/Abdo Arias, Williams Alejandro. jpg

Tell me does flex plays mp3 or you have similar problem?


this project is for cd distribution so i don't think thats the problem
the mp3 files are ok
i know my problem is cause i'm a noob in ActionScript

is there any way i can trace
catalog.libro.imagen
when clicking on the datagrid and show
<imagen>FOTOS/Abdo Andrade, Alberto. jpg</imagen> in the mx:image:(

if i don't use e4x this is really easy i usually put
<mx:Image source="{datagrid.selectedItem.imagen}" />
and thats it

nirth
07-03-2006, 05:14 PM
try this

<mx:Image source="{datagrid.selectedItem.imagen.text()}" />

stonyx
07-03-2006, 07:29 PM
try this

<mx:Image source="{datagrid.selectedItem.imagen.text()}" />



sorry for my ignorance (and my english)
but isn't that code to display the text?
what i want is to display the image in the <mx:image/>
if i use
<mx:Image source="{datagrid.selectedItem.imagen}" />
everything is ok but the image won't display

nirth
07-04-2006, 02:25 PM
yeah sorry, text does not makes any changes ( it just returns same stuff)
this is probably some issue with data bindings

stonyx
07-19-2006, 10:11 PM
i already figure it out, thanks

goliatone
07-19-2006, 11:03 PM
hi stonix,
why dont you explain what was wrong in that code...so, this thread might be helpful for someone else...

take care

stonyx
08-07-2006, 08:14 PM
i only add a @ before imagen
<mx:Image x="374" y="304" width="164" height="181" source="{datagrid.selectedItem.@imagen}"/>

and thats it, took 1 week to figure it out, the problem was i'm using e4x but ones u understand it is easy to use :D

goliatone
08-07-2006, 08:16 PM
cool...
where ya from? saw some spanish in your code....

stonyx
08-07-2006, 08:30 PM
cool...
where ya from? saw some spanish in your code....

wow Fast reply
i'm from Tijuana,Mexico
ahorita viviendo en Tabasco Mucho calor