Brothers
22.11.2006, 18:01
Помогите пожалуйста, не могу понять в чём проблема. При сборке выдает ошибку 1061: Call to a possibly undefined method play through a reference with static type musicPlayer. Пробовал разбираться в примерах классов в документации Flex, но имел аналогичный результат. Заранее Спасибо!
musicPlayer.mxml:
<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" xmlns="*"
layout="vertical"
creationComplete = "initApp()" >
<mx:Script>
<![CDATA[
public var MyURL:String = "data/example.mp3";
public function initApp():void
{
var myP:musicPlayer = new musicPlayer;
myP.play("data/example.mp3");
}
]]>
</mx:Script>
<mx:TextArea id = "mainTxt" width="400" backgroundColor="#DDDDDD" editable="false" />
<mx:HBox width="400">
<mx:Label text="User Name:"/>
<mx:TextInput id="userNameTxt" width="100%" enter="mainTxt.text = Greeter.sayHello(userNameTxt.text);" />
</mx:HBox>
<mx:Button label="Play!" click="myP.play(MyURL);"/>
</mx:Application>
musicPlayer.as:
// ActionScript file
package {
import flash.media.Sound;
import flash.media.SoundChannel;
import flash.display.Sprite;
[Bindable]
public static class musicPlayer extends Sprite{
var mySound:Sound = new Sound();
var channel:SoundChannel;
public function play(url:String):void{
mySound.load(url);
channel = mySound.play();
}
}
}
musicPlayer.mxml:
<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" xmlns="*"
layout="vertical"
creationComplete = "initApp()" >
<mx:Script>
<![CDATA[
public var MyURL:String = "data/example.mp3";
public function initApp():void
{
var myP:musicPlayer = new musicPlayer;
myP.play("data/example.mp3");
}
]]>
</mx:Script>
<mx:TextArea id = "mainTxt" width="400" backgroundColor="#DDDDDD" editable="false" />
<mx:HBox width="400">
<mx:Label text="User Name:"/>
<mx:TextInput id="userNameTxt" width="100%" enter="mainTxt.text = Greeter.sayHello(userNameTxt.text);" />
</mx:HBox>
<mx:Button label="Play!" click="myP.play(MyURL);"/>
</mx:Application>
musicPlayer.as:
// ActionScript file
package {
import flash.media.Sound;
import flash.media.SoundChannel;
import flash.display.Sprite;
[Bindable]
public static class musicPlayer extends Sprite{
var mySound:Sound = new Sound();
var channel:SoundChannel;
public function play(url:String):void{
mySound.load(url);
channel = mySound.play();
}
}
}