从html到actionscript的路径引用

时间:2011-01-12 10:09:00

标签: html flex actionscript-3 mxml mxmlc

在下面的代码中,如何在动作脚本中如何说我的mp3存在于html标签中指定的路径

       <div style="display: inline;float:center;">
       <OBJECT
                                     classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000"
                                     WIDTH="50"
                                     HEIGHT="50"
                                     id="myMovieName">

                                   <PARAM NAME="movie" VALUE="mysound.swf" />
                                   <PARAM NAME="quality" VALUE="high" />
                                   <PARAM NAME="bgcolor" VALUE="#FFFFFF" />

                                   <EMBED
                                      href="mysound.swf"
                  src="mysound.swf"
                  flashvars="soundUrl=/var/mychannel/sound.mp3"
                                      quality=high
                                      bgcolor=#FFFFFF
                                      NAME="myMovieName"
                                      ALIGN=""
                                      TYPE="application/x-shockwave-flash">
                                   </EMBED>
                                   </OBJECT>

            </div>

动作脚本代码

<?xml version="1.0" encoding="utf-8"?>
<s:Application xmlns:fx="http://ns.adobe.com/mxml/2009" 
       xmlns:s="library://ns.adobe.com/flex/spark" 
       xmlns:mx="library://ns.adobe.com/flex/mx" minWidth="955" minHeight="600">
<fx:Script>
<![CDATA[
    import flash.display.Sprite;
    import flash.display.InteractiveObject;
    import flash.display.Sprite;
    import flash.media.*;
    import flash.net.*;
    import mx.controls.Alert;
    import mx.controls.Button;
    import flash.events.Event;
    import flash.media.Sound;
    import flash.net.URLRequest;



    private function clickhandler(event:Event):void
    {
        var s:Sound = new Sound();
        s.addEventListener(Event.COMPLETE, onSoundLoaded);
        //var req:URLRequest = new URLRequest("sound.mp3");   
        s.load(req);

    }


]]>
</fx:Script>
<fx:Declarations>
<!-- Place non-visual elements (e.g., services, value objects) here -->
</fx:Declarations>
<mx:Button id="play" label="PLAY" click="clickhandler(event)"  />

</s:Application>

1 个答案:

答案 0 :(得分:1)

试试这个: stage.loaderInfo.parameters.soundUrlstage.loaderInfo.parameters["soundUrl"]

罗布