2013-09-26 2 views
0

플렉스에서 사운드를 사용하려고합니다. urlrequest를 사용하여 출력물을 얻었습니다. 사운드 파일을 적게 사용하고 필요할 때마다로드 할 필요가 없습니다. 그래서 나는 그것을 CSS에서 그것을 넣어 사용하려고하지만 오류가 점점 오전 : 아래 TypeError: Error #1007: Instantiation attempted on a non-constructor.CSS에서 사운드를 플렉스로 삽입

것은 내 코드

<?xml version="1.0" encoding="utf-8"?> 
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute"> 

<mx:Style> 

draw 
{ 
    url:"Assets/Sound/Active.mp3"; 
} 

</mx:Style> 

<mx:Script> 
<![CDATA[ 

     import flash.media.Sound; 
     import flash.media.SoundTransform; 

    internal var sound:Sound; 
    internal var soundVolume:SoundTransform; 

public function playSound():void 
    { 
     var SoundClass:Class; 

    try 
    { 
      SoundClass = StyleManager.getStyleDeclaration("draw").getStyle("url") as Class; 
      soundVolume = new SoundTransform(1, 0); 
      trace("sound : "+sound); 
      sound = new SoundClass() as Sound; 
      sound.play(0, 0, soundVolume); 
    } 
    catch(E:Error) 
    { 
     trace("E "+E); 
    } 
    } 

]]> 
</mx:Script> 

<mx:Button click="playSound()" label="Discard"/> 
</mx:Application> 

답변

1
draw { 
    url:Embed(source="Assets/Sound/Active.mp3"); 
} 

참조입니다 그것은 근무 this

+0

'티모 페이 Davydik' 나, 고마워. – user1647017

+0

안녕하세요 @Timofei, 오랜 시간 후에 죄송합니다. 위의 코드는 저에게 효과적 이었지만 CSS는 '비트율 48000Hz의 사운드를 트랜스 코드 할 수 없습니다'라는 오류를 표시합니다. 비트율을 낮추면 소리가 이상해집니다. css에서 높은 비트 전송률 사운드를 추가하는 방법을 알려주세요. 내 사운드 파일 크기는 21kb-31kb이며 48000Hz 이상인 비트 전송률 (대략)입니다. 감사합니다 – user1647017

+0

죄송합니다, 잘 모르겠습니다 ... –

관련 문제