TAILIEUCHUNG - Học Actionscript 3.0 - p 34

Changing Sound Volume and Pan and positive interim values reflect some degree of pan right. The following script sets the channel instance to a pan setting of full left: var trans:SoundTransform = new SoundTransform(); = -1; = trans; To transform all playing sounds at once, substitute the specified channel with the master SoundMixer class. For example, the following script mutes all sounds: var trans:SoundTransform = new SoundTransform(); = 0; = trans; Now let’s apply what we’ve learned to our ongoing player example. The following code can be found in the source file, and demonstrates both volume and pan by using mouse coordinates. Figure 11-2 shows how the mouse will affect the sound transformation. Moving the mouse. | Changing Sound Volume and Pan and positive interim values reflect some degree of pan right. The following script sets the channel instance to a pan setting of full left var trans SoundTransform new SoundTransform -1 trans To transform all playing sounds at once substitute the specified channel with the master SoundMixer class. For example the following script mutes all sounds var trans SoundTransform new SoundTransform 0 trans Now let s apply what we ve learned to our ongoing player example. The following code can be found in the source file and demonstrates both volume and pan by using mouse coordinates. Figure 11-2 shows how the mouse will affect the sound transformation. Moving the mouse left and right pans the sound left and right. Moving the mouse up and down fades the volume up and down. Hl stage origin x 0 y 0 center of stage default direction of increasing y values will be inverted for usability using ActionScript 1 I I I I I I I I I I I I J Ï I I I I I I I I I I I I I Figure 11-2. How the mouse affects sound volume and panning in the adaption made to the sound player project Line 104 creates a SoundTransform instance and lines 105 through 109 contain the onPlayProgress function that will set and apply the transformations. This function will be called from the enter frame event listener function created earlier which we ll adapt in a moment. Chapter 11 Sound 309 Download from Wow eBook Changing Sound Volume and Pan NOTE Again if you want to transform every sound playing at a given moment simply substituting SoundMixer for the specific channel in line 108 will accomplish the task. To set these changes with the mouse in a natural and intuitive way we need to think about ActionScript mouse coordinates and apply a little math. Line 106 sets the volume based on the y-coordinate of the mouse. By dividing the current vertical mouse coordinate mouseY by the

TAILIEUCHUNG - Chia sẻ tài liệu không giới hạn
Địa chỉ : 444 Hoang Hoa Tham, Hanoi, Viet Nam
Website : tailieuchung.com
Email : tailieuchung20@gmail.com
Tailieuchung.com là thư viện tài liệu trực tuyến, nơi chia sẽ trao đổi hàng triệu tài liệu như luận văn đồ án, sách, giáo trình, đề thi.
Chúng tôi không chịu trách nhiệm liên quan đến các vấn đề bản quyền nội dung tài liệu được thành viên tự nguyện đăng tải lên, nếu phát hiện thấy tài liệu xấu hoặc tài liệu có bản quyền xin hãy email cho chúng tôi.
Đã phát hiện trình chặn quảng cáo AdBlock
Trang web này phụ thuộc vào doanh thu từ số lần hiển thị quảng cáo để tồn tại. Vui lòng tắt trình chặn quảng cáo của bạn hoặc tạm dừng tính năng chặn quảng cáo cho trang web này.