Prev | Current Page 625 | Next

L. McColl-Sylvester and F. Ponticelli

"Professional haXe and Neko"

The Sound constructor accepts as an argument an instance of MovieClip or
Button ; when this argument is passed the Sound object is anchored to such an instance and it regulates
only the sounds associated to it.
import flash.Sound;
class Main
{
public static function main()
{
var s = new Sound(null);
s.loadSound(???sound.mp3???, true);
}
}
Loading a Sound in Flash 9
The Sound class is in the flash.media package. The load() method is used to load an audio file;
alternatively it is possible to specify a file directly as an argument of the constructor. After the loading
action, it is necessary to invoke the play() method to actually execute the file.
import flash.media.Sound;
import flash.net.URLRequest;
class Main
{
public static function main()
{
var s = new Sound(new URLRequest(???sound.mp3???));
s.play();
}
}
Loading Values
Loading text values from the server can be very useful and it is at the base of AJAX applications. The
Flash environment offers a very simple way to communicate with the server using the LoadVars class
in Flash 6 to 8 or the URLLoader class in Flash 9.


Pages:
613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637