Playsound error in Flash mode but working fine in HTML5 mode.(updated)

  • Hi:)

    I setup a sound in each scene:

    Code
    <scene name="a01">
       ...
          <sound file="a01.mp3|a01.ogg" />
       </scene>

    and I put a icon to play it:

    Code
    <layer name="playmusic" keep="true" url="audio.png"   onclick="playsound(bgsound,get(sound.file),0,0);" />

    This run good in Chome HTML5 mode, but in Chrome Flash mode, After I click the playmusic icon, no music played, and all hotspots lose effectiveness. there was no error log show.

    And if I put a hard-coded in xml:

    Code
    <layer name="playmusic" keep="true" url="audio.png"   onclick="playsound(bgsound,a01.mp3|a01.ogg,0,0);" />


    it run good in Chrome flash mode now.


    What do I do wrong ?

    Jove.

    _____________________________update________________________________


    The custom label inside <scene> node just like:

    Code
    <scene name="a01">
    ...
    <sound file="a01.mp3|a01.ogg" />
    </scene>


    In HTML5 mode, trace(get(sound.file)) can get the value:"a01.mp3|a01.ogg"
    But in Flash mode, trace(get(sound.file)) get null.


    Why?

    5 Mal editiert, zuletzt von jove (3. Juli 2015 um 18:24)

  • Do something like this:

    Code
    <scene name="a01" . . . . . sound_file="a01.mp3|a01.ogg" >
       ...
    </scene>


    and

    Code
    <layer name="playmusic" keep="true" url="audio.png"   onclick="playsound(bgsound,get(scene[get(xml.scene)].sound_file),0,0);" />

    If still you have troubles share link to your code to explore.

  • Thanks!
    But I got a question:
    The custom label inside <scene> node just like:

    Code
    <scene name="a01">
       ...
          <sound file="a01.mp3|a01.ogg" />
       </scene>


    In HTML5 mode, trace(get(sound.file)) can get the value:"a01.mp3|a01.ogg"
    But in Flash mode, trace(get(sound.file)) get null.


    What do I do wrong ?
    Jove.

  • Thanks sachagriffin


    I understand now. the custom child element "sound" is an Array. and should be access use sound[index] or sound[name].


    And maybe I can use:

    Code
    sound[ get(scene[get(xml.scene)].index) ].file


    or

    Code
    scene[get(xml.scene)].child[sound].file




    to access such child element value?

  • If its in the scene, it won't exist twice when you enter other scenes. When you change scenes those structures are overwritten. Actually, its overwritten. If you want to destroy them, you have to set their count to 0.
    If you always have the sound structure, trace(sound[0].file); will always show the right files.
    Or you can always put the whole thing in the <scene tag
    <scene sound="test.mp3"

    No, you can't access children of the scene like that. I'm not sure why. Other elements yes..
    like layer[storage].slideshow[%slideshow_step].delay

    Code
    <layer name="storage"><slideshow name="a0" action="rotate360(continue,,45)" wait="true" />
    <slideshow name="c10" action="show_photo_single(test.jpg);" delay="3"/>
  • Thanks so much sachagriffin.
    sound[0].file will always show the right files. this solved my problem.

    Just the strange thing is both sound[0].file and sound.file can work in HTML5 mode.


    Jove.

Jetzt mitmachen!

Sie haben noch kein Benutzerkonto auf unserer Seite? Registrieren Sie sich kostenlos und nehmen Sie an unserer Community teil!