2 Replies Latest reply on Feb 14, 2011 10:59 AM by Lady Lilly

    Burrito - problem with embedding sounds (source from XML)

    Lady Lilly

       

      Hi!

       

      I’m trying to build Dictionary in Burrito. And I have problem with embedding sounds.

       

      I’m working with XML. Here’s example of my XML data:

       

       

      <?xml version="1.0" encoding="utf-8"?>

       

      <list>

       

                      <phrase>

       

                      <id>1</id>

       

                      <kan>おはようございます</kan>

       

                      <rom>ohayougozaimasu</rom>

       

                      <pol>Dzień dobry. (rano)</pol>

       

                      <source>phr/sou/1.mp3</source>

       

           </phrase>

       

                      <phrase>

       

                      <id>2</id>

       

                      <kan>こんにちは。</kan>

       

                      <rom>konnichiha</rom>

       

                      <pol>Dzień dobry. (po południu)</pol>

       

                      <source>phr/sou/2.mp3</source>

       

           </phrase>

       

      </list>

       

       

       

      I have (of course in an interesting part of project) two files: First.mxml and PhraseDetails.mxml:

       

       

      <?xml version="1.0" encoding="utf-8"?>

       

      <s:View xmlns:fx="http://ns.adobe.com/mxml/2009"

       

                  xmlns:s="library://ns.adobe.com/flex/spark" title="First" creationComplete="srv.send()">

       

           

       

            <fx:Declarations>

       

                  <s:HTTPService id="srv" url="phr/first.xml"/>

                 

            </fx:Declarations>

            <s:List id="list" top="0" bottom="0" left="0" right="0"

                        dataProvider="{srv.lastResult.list.phrase}"

                        change="navigator.pushView(PhraseDetails, list.selectedItem)">

                  <s:itemRenderer>

                        <fx:Component>

                       

                              <s:MobileIconItemRenderer label="{data.pol}" messageField="kan"/>

           

                        </fx:Component> </s:itemRenderer>

            </s:List>

           

           

            <s:actionContent>

                  <s:Button icon="@Embed('img/h.png')" click="navigator.popView()"/>

            </s:actionContent>

           

      </s:View>

       

       

       

       

      <?xml version="1.0" encoding="utf-8"?>

      <s:View xmlns:fx="http://ns.adobe.com/mxml/2009"

                  xmlns:s="library://ns.adobe.com/flex/spark"

                  title="Phrase Details">

            <fx:Script>

                  <![CDATA[

                       

                       

                        import flash.net.*;

                        import mx.events.*;

                       

                        public var link:URLRequest = new URLRequest("phr/sou/1.mp3");

                        public var sound:Sound = new Sound(link);

                    

           

                     ]]>

                 

                 

       

            </fx:Script>

            <s:HGroup verticalAlign="middle">

                  <s:VGroup>

                        <s:Label/>

                        <s:Label text="kanji:"/>

                        <s:Label text="{data.kan}"/>

                        <s:Label/>

                        <s:Label text="romanaji:"/>

                        <s:Label text="{data.rom}"/>

                        <s:Label/>

                        <s:Label text="polski:"/>

                        <s:Label text="{data.pol}"/>

                        <s:Button  label="dźwięk" click="sound.play();" />

                  </s:VGroup>

                 

                 

            </s:HGroup>

            <s:navigationContent>

                  <s:Button icon="@Embed('img/h.png')" click="navigator.popView()"/>

            </s:navigationContent>

      </s:View>

       

       

       

      In first View of application I have list of phrases. When we choose the phrase, we go to her details. All text displays good. But I have problem with sounds. When I write the exact path (public var link:URLRequest = new URLRequest("phr/sou/1.mp3");)all is OK. But I must write source from XML. And I don’t have any idea. I’m trying write sounds just as text in Label, but {data.source} don’t work in <![CDATA[ … ]]> I’m trying write some function, but unsuccessfully.

       

      I'll be thankful for any suggest.