高度和宽度的SWF文件的HTML宽度、高度、文件、SWF

2023-09-09 21:45:28 作者:只剩骄傲

在以下code只有按钮图像已被嵌入到C $ c.But柔性$的HTML对象或嵌入标签,为什么高度和宽度都必须specified.Even,虽然这是一个正常的按钮,如果我们不指定高度和宽度似乎有一定的误差

HTML

 <分区对齐=中心>
    < BR />
    < D​​IV的风格=显示:块;宽度:100像素,高度:100像素; ID =音频
        类=testsoundALIGN =中心/>
    &其中,P类=点击>
        <对象的classid =CLSID:D27CDB6E-AE6D-11CF-96B8-444553540000
        宽度=400的高度=100ID =myMovieName>
            < PARAM NAME =电影值=/媒体/播放器/ testsound.swf/>
            < PARAM NAME =soundurl值=/媒体/播放器/ music.mp3/>
            < PARAM NAME =质量值=高/>
            < PARAM NAME =BGCOLOR值=#FFFFFF/>
            <嵌入WIDTH =100HEIGHT =100HREF =/媒体/播放器/ testsound.swf
                SRC =/媒体/播放器/ testsound.swf
                Flash变量=soundUrl = /媒体/播放器/ music.mp3
                品质=高BGCOLOR =#FFFFFF
                NAME =myMovieName循环=假ALIGN =
                TYPE =应用程序/ x-冲击波闪光>
            < /嵌入>
        &所述; /对象>
    &所述; / P>
< / DIV>
 

MXML

 < XML版本=1.0&GT?;
<! - 嵌入/ EmbedSound.mxml  - >
< MX:应用的xmlns:MX =htt​​p://www.adobe.com/2006/mxml>

    < MX:脚本>
        <![CDATA [

            进口flash.media *。

            公共变种SND:声音=新sndCls()的声音;
            公共变种sndChannel:的SoundChannel;

            公共职能playSound():无效{
                sndChannel = snd.play();
            }

        ]]≥
    < / MX:脚本>
    < MX:图片ID =loader1点击=playSound();
        来源=@嵌入(源=/选择/ cloodon /网站/媒体/ IMG / speaker.gif')/>
< / MX:用途>
 
如何在powerpoint中使用高版本的swf文件

解决方案

你应该在你的主MXML指定即使它包含但宽度和你的应用的高度可点击图片! 如果您想您的网页有宽柔性图像(按钮?):x 400像素高度:100像素,那么你的应用程序标签必须是这样的:

 < MX:应用的xmlns:MX =htt​​p://www.adobe.com/2006/mxmlWIDTH =400HEIGHT =100>
 

和尽管如此,在你的HTML,你应该同时拥有你的对象中嵌入标签具有相同的宽度高度,你应该指定一个值,你的中嵌入标签的调整属性为好,如: ALIGN =中间

对象标记应类似于

 <对象的classid =CLSID:D27CDB6E-AE6D-11CF-96B8-444553540000
    宽度=400的高度=100ID =myMovieName
    codeBase类=htt​​p://fpdownload.macromedia.com/get/flashplayer/current/swflash.cab>
    < PARAM NAME =电影值=/媒体/播放器/ testsound.swf/>
    < PARAM NAME =soundurl值=/媒体/播放器/ music.mp3/>
    < PARAM NAME =质量值=高/>
    < PARAM NAME =BGCOLOR值=#FFFFFF/>
    <! -  embed标签不具有href属性 - >
    <嵌入WIDTH =400HEIGHT =100
        SRC =/媒体/播放器/ testsound.swf
        Flash变量=soundUrl = /媒体/播放器/ music.mp3
        品质=高BGCOLOR =#FFFFFF
        NAME =myMovieName循环=假ALIGN =中间
        TYPE =应用程序/ x-冲击波闪光
        PLUGINSPAGE =htt​​p://www.adobe.com/go/getflashplayer>
    < /嵌入>
&所述; /对象>
 

其他 哪里是你的sndClass声明?如果您有MP3嵌入脚本标签应包含:

 < MX:脚本>
    <![CDATA [
        进口mx.core.SoundAsset;

        [嵌入('/媒体/播放器/ music.mp3')]
        私人VAR _sound:类;
        公共变种SND:了SoundAsset =新_sound()作为了SoundAsset;

        公共变种sndChannel:的SoundChannel;

        公共职能playSound():无效{
            sndChannel = snd.play();
        }

    ]]≥
< / MX:脚本>
 

如果你想指定的HTML你的MP3的路径,你可能看的这篇文章仅供参考。

更新2

要设置HTML 对象的宽度和高度根据你的Flex按钮的大小,您应该更新您的应用程序MXML code如下:

 < XML版本=1.0编码=UTF-8&GT?;
< MX:应用的xmlns:MX =htt​​p://www.adobe.com/2006/mxml布局=绝对
    宽度=1高度=1的backgroundColor =#bee3f6
    horizo​​ntalScrollPolicy =关verticalScrollPolicy =关闭
    的creationComplete =onCreationComplete()viewSourceURL =srcview / index.html的>
    < MX:脚本>
        <![CDATA [
            进口mx.events.FlexEvent;

            //此方法将改变按钮的标签==>宽度。
            公共职能sayWhat():无效{
                VAR _date:日期=新的日期();
                extButton.label =这是+(_date.getHours()+ 1)+:+ _date.getMinutes()+
                    ((_date.getMilliseconds()%2)== 0?好。:。很累了);
            }

            公共职能onCreationComplete():无效{
                //结合this.sayWhat到外部接口,所以从时
                // JavaScript的被称为编译SWF对象的sayWhat功能,
                //它将被转移到this.sayWhat。
                ExternalInterface.addCallback(sayWhat,sayWhat);

                //设置Flash应用程序的大小是准确按钮的大小。
                this.width = extButton.width;
                this.height = extButton.height;

                尝试
                {
                    // JS的功能:onFlashAppInited(宽,高);
                    //下面一行告诉外部接口(父应用程序:
                    //浏览器窗口),这个应用程序加载完毕,其
                    //随时可以使用。
                    //我们传递按钮的宽度和高度参数
                    //在JS中必须有与此名称的全局方法。
                    ExternalInterface.call(onFlashAppInited,extButton.width,extButton.height);
                }
                赶上(五:错误)
                {
                    跟踪(e.message +\ N+ e.getStackTrace(),e.​​name);
                }
            }

            保护功能onButtonUpdateComplete(事件:FlexEvent):无效
            {
                //如果按钮的大小发生了变化,我们通知的JavaScript设置
                //正确尺寸的对象标记了。
                如果((this.width!= extButton.width)||(this.height!= extButton.height))
                {
                    //设置应用程序的大小
                    this.width = extButton.width;
                    this.height = extButton.height;
                    //通知关于变更的JS
                    ExternalInterface.call(onFlashAppSizeChanged,this.width,this.height);
                }
            }

        ]]≥
    < / MX:脚本>
    < MX:按钮的ID =extButton标签=做点什么! updateComplete =onButtonUpdateComplete(事件)/>
< / MX:用途>
 

请注意,最初这个应用程序是唯一的1x1像素的(如果不那么,它不会初始化!)。 在 onCreationComplete 处理它的大小被改变以匹配按钮的大小。

这些值(宽度和高度)传递给JavaScript函数 onFlashAppInited ,您也应该更新:

 函数onFlashAppInited(宽,高){
    警报(Flash应用程序inited!);
    appInited = TRUE;

    onFlashAppSizeChanged(宽度,高度);

    //删除临时SWF容器:TMP
    document.body.removeChild(的document.getElementById(TMP));
}

功能onFlashAppSizeChanged(宽度,高度){
    flashApp.width =宽度+PX;
    flashApp.height =身高+像素;
}
 

In the following code Only the button image has been embeded into the flex code.But in the html object or embed tag why the height and width has to be specified.Even though for this is a normal button if we do not specify the height and width there seems to be some error

html

<div align="center">
    <br />
    <div style="display:block;width:100px;height:100px;" id="audio" 
        class="testsound" align="center"/>
    <p class="clickable">
        <object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" 
        width="400" height="100" id="myMovieName">
            <param name="movie" value="/media/players/testsound.swf"/>
            <param name="soundurl" value="/media/players/music.mp3"/>
            <param name="quality" value="high"/>
            <param name="bgcolor" value="#FFFFFF"/>
            <embed width="100" height="100" href="/media/players/testsound.swf" 
                src="/media/players/testsound.swf" 
                flashvars="soundUrl=/media/players/music.mp3" 
                quality="high" bgcolor="#FFFFFF" 
                name="myMovieName" loop="false" align=""
                type="application/x-shockwave-flash">
            </embed>
        </object>
    </p>
</div>

MXML

<?xml version="1.0"?>
<!-- embed/EmbedSound.mxml -->
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml">

    <mx:Script>
        <![CDATA[

            import flash.media.*; 

            public var snd:Sound = new sndCls() as Sound; 
            public var sndChannel:SoundChannel;

            public function playSound():void {
                sndChannel=snd.play();
            }   

        ]]>
    </mx:Script>
    <mx:Image id="loader1" click="playSound();"
        source="@Embed(source='/opt/cloodon/site/media/img/speaker.gif')" />
</mx:Application>

解决方案

you should specify in your main mxml the width and height of your Application even though it contains but a clickable image! If you'd like your page to have a flex image (button??) of width: 400px and height: 100px, then your Application tag must look like:

<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" width="400" height="100">

And nonetheless, in your html you should have both your object and embed tags to have the same width and height, and you should specify a value to your embed tag's align attribute as well, eg: align="middle".

Your object tag should look similar to

<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" 
    width="400" height="100" id="myMovieName"
    codebase="http://fpdownload.macromedia.com/get/flashplayer/current/swflash.cab">
    <param name="movie" value="/media/players/testsound.swf"/>
    <param name="soundurl" value="/media/players/music.mp3"/>
    <param name="quality" value="high"/>
    <param name="bgcolor" value="#FFFFFF"/>
    <!-- the embed tag does not have href attribute  -->
    <embed width="400" height="100"  
        src="/media/players/testsound.swf" 
        flashvars="soundUrl=/media/players/music.mp3" 
        quality="high" bgcolor="#FFFFFF" 
        name="myMovieName" loop="false" align="middle"
        type="application/x-shockwave-flash"
        pluginspage="http://www.adobe.com/go/getflashplayer">
    </embed>
</object>

Other Where is your sndClass declared? If you have that mp3 embedded, your script tag should contain:

<mx:Script>
    <![CDATA[
        import mx.core.SoundAsset; 

        [Embed('/media/players/music.mp3')]
        private var _sound:Class;
        public var snd:SoundAsset = new _sound() as SoundAsset;

        public var sndChannel:SoundChannel;

        public function playSound():void {
            sndChannel=snd.play();
        }   

    ]]>
</mx:Script>

If you'd like to specify your mp3's path from html, you might look at this post for reference.

Update 2

To set the html object's width and height based on your flex button's size, you should update your application mxml code as follows:

<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute" 
    width="1" height="1" backgroundColor="#bee3f6"
    horizontalScrollPolicy="off" verticalScrollPolicy="off"
    creationComplete="onCreationComplete()" viewSourceURL="srcview/index.html">
    <mx:Script>
        <![CDATA[
            import mx.events.FlexEvent;

            //This method will change the button's label ==> width.
            public function sayWhat():void {
                var _date:Date = new Date();
                extButton.label = "It's " + (_date.getHours() + 1) + ":" + _date.getMinutes() + 
                    ((_date.getMilliseconds() % 2) == 0 ? ". nice." : ". very tired.");
            }

            public function onCreationComplete():void {
                // binds this.sayWhat to the external interface, so when from   
                // javascript is called the compiled swf object's sayWhat function,
                // it will be transferred to this.sayWhat. 
                ExternalInterface.addCallback("sayWhat", sayWhat);

                // set the flash application's size to be exact the button's size.
                this.width = extButton.width;
                this.height = extButton.height;

                try 
                {
                    // The js function: onFlashAppInited(width, height);
                    // The next line tells the external interface (the parent application:
                    // browser window), that this application has finished loading, its 
                    // ready to be used. 
                    // We're passing the button's width and height as parameters
                    // In js there has to be a global method with this name.
                    ExternalInterface.call("onFlashAppInited", extButton.width, extButton.height);
                }
                catch (e:Error)
                {
                    trace(e.message + "\n" + e.getStackTrace(), e.name);
                }
            }        

            protected function onButtonUpdateComplete(event:FlexEvent):void
            {
                // if the button's size has changed, we notify the javascript to set the 
                // correct size to the object tag too.
                if ((this.width != extButton.width) || (this.height != extButton.height))
                {
                    // set the application size
                    this.width = extButton.width;
                    this.height = extButton.height;
                    // notify the js about the change
                    ExternalInterface.call("onFlashAppSizeChanged", this.width, this.height);
                }
            }

        ]]>             
    </mx:Script>
    <mx:Button id="extButton" label="Do something!" updateComplete="onButtonUpdateComplete(event)" />
</mx:Application>

Note, that initially this application is only 1x1 pixel (if less, it won't initialize!). In the onCreationComplete handler its size is changed to match the button's size.

These values (width and height) are passed to the javascript function onFlashAppInited, which you should also update:

function onFlashAppInited(width, height) {
    alert("Flash app inited!");
    appInited = true;

    onFlashAppSizeChanged(width,height);

    // remove the temporary swf container: tmp
    document.body.removeChild(document.getElementById("tmp"));
}

function onFlashAppSizeChanged(width, height) {
    flashApp.width = width + "px";
    flashApp.height = height + "px";
}