클릭 가능한 이미지가 포함되어 있어도 Application
의 너비와 높이를 주 mxml에 지정해야합니다! 당신이 width: 400px
및 height: 100px
의 플렉스 이미지 (버튼을 ??)가 당신의 페이지를 원하는 경우
, 다음 Application
태그가 같이해야합니다 그럼에도 불구하고
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" width="400" height="100">
그리고, 당신의 HTML에서, 당신은 둘 다 있어야 당신의 object
및 embed
태그는 동일한 width
및 height
이어야하며 embed
태그의 align
속성에도 값을 지정해야합니다 (예 : align="middle"
). 귀하의 object
태그
<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>
이 가 어디 sndClass 선언 다른 유사합니다
?당신이 MP3가 내장 된 것이있는 경우, 스크립트 태그를 포함해야합니다 : 당신이 HTML에서 당신의 mp3 파일의 경로를 지정하려는 경우, 당신은 this post for reference 볼 수
<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>
.
업데이트 2
다음과 같이 플렉스 버튼의 크기에 따라 HTML object
의 폭과 높이, 당신은 응용 프로그램 MXML 코드를 업데이트해야 설정하려면 : 그 처음
<?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>
주 이 응용 프로그램은 1x1 픽셀입니다 (적은 경우, 초기화되지 않습니다!).
onCreationComplete
처리기에서 단추의 크기와 일치하도록 크기가 변경됩니다.
이 값 (폭과 높이) 당신은 또한 업데이트해야 자바 스크립트 기능 onFlashAppInited
에 전달됩니다 정확히 할 SWF에 맞게 수행해야 어떤 제안 나던 게시물에서
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";
}
나는 mxml 및 html.But에서 높이와 너비를 설정하는 것에 대해 동의합니다. 기본적으로 flex의 버튼 크기를 알지 못하므로 기본 버튼이 지정된 경우 높이를 알아야합니다 너비와 html로 설정하는 방법 ..? – Naveen
: -? flex의 onCreationComplete 메소드에서 버튼의 크기 (너비/높이)를 가져 와서 javacript로 전달할 수 있습니다 (flashAppInited 메소드를 매개 변수로 사용). 이렇게하면 자바 스크립트 측에서 버튼의 너비에 대한 알림을 받고 swf 객체의 크기를 똑같은 크기로 조정할 수 있습니다. – rekaszeru
K .. 내가 어떻게 검색 할 수있는 링크를 알려주시겠습니까? 내가 ur 사이트를 보았습니다. 그 기능은 이미 차가워졌습니다. – Naveen