mx Application xmlns mx http www adobe com 2006 mxml xmlns inx com inx

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml"
xmlns:inx="com.inx.utilities.*"
xmlns:c="com.inx.control.*"
xmlns:sp="com.inx.view.soundPlayer.*"
xmlns:equalizer="com.inx.eq.everydayflash.equalizer.*"
creationComplete="{initApp()}" layout="vertical">
<mx:Metadata>
[ResourceBundle("resources")]
</mx:Metadata>
<mx:Style source="assets/themes/default/css/style.css"/>
<mx:Script>
<![CDATA[
import mx.rpc.events.FaultEvent;
import mx.rpc.events.ResultEvent;
import mx.events.ListEvent;
import mx.events.ItemClickEvent;
import mx.events.FlexEvent;
import com.inx.eq.everydayflash.equalizer.color.SolidBarColor;
import com.inx.eq.everydayflash.equalizer.Equalizer;
import com.inx.eq.everydayflash.equalizer.EqualizerSettings;
import mx.events.SliderEvent;
import com.inx.utility.SoundFactory;
import mx.controls.Alert;
import com.inx.utility.I18N;
[Bindable]
private var i18n:I18N = I18N.getInstance();
[Bindable]
private var soundFactory:SoundFactory = SoundFactory.getInstance();
private var isSliderThumbOnDrag:Boolean;
private function initApp():void {
//soundFactory.urlRequest = "http://muzx.net/inf/ma/Player & Remady - I Am Not A Superstar (DJ Decameron Edit).mp3";
//soundFactory.urlRequest = "http://muzx.net/files/mmp/2/Olien - Galaxxenter.mp3";
soundFactory.urlRequest = "http://old.muzx.net/files/mmp/2/Prahlad - Shantified.mp3";
soundFactory.addEventListener(SoundFactory.PLAYING, handlePlay);
soundFactory.addEventListener(SoundFactory.STOPING, handleStop);
volume.value = soundFactory.volume;
srv.addEventListener(ResultEvent.RESULT, resultHandler);
srv.addEventListener(FaultEvent.FAULT, faultHandler);
srv.getOperation("get_string").send();
}
public function resultHandler(event:ResultEvent):void {
Alert.show("jjj");
}
public function faultHandler(event:FaultEvent):void {
Alert.show("fault");
}
private function handlePlay(event:Event):void {
if(!isSliderThumbOnDrag && event.type!=MouseEvent.MOUSE_DOWN) {
slider.value = soundFactory.playHeadPosition;
}
}
private function handleStop(event:Event):void {
slider.value = soundFactory.playHeadPosition;
}
private function localeComboBox_changeHandler(event:Event):void {
i18n.locale = localeComboBox.selectedLabel;
}
private function handleSliderChange(event:SliderEvent):void {
var newPlayheadPosition:Number = slider.value;
soundFactory.rewind(newPlayheadPosition);
isSliderThumbOnDrag = false;
}
private function handleSliderThumbDrag(event:SliderEvent):void {
slider.value = event.value;
isSliderThumbOnDrag = true;
}
private function handleSliderThumbReleas(event:SliderEvent):void {
isSliderThumbOnDrag = false;
soundFactory.rewind(event.value);
}
private function handleVolumeChange(event:SliderEvent):void {
soundFactory.volume = event.value;
}
private function handleVolumeThumbDrag(event:SliderEvent):void {
soundFactory.volume = event.value;
}
private function handlePanChange(event:SliderEvent):void {
soundFactory.pan = event.value;
}
private function handlePanThumbDrag(event:SliderEvent):void {
soundFactory.pan = event.value;
}
private function playTrack():void {
soundFactory.play();
if(getChildByName("eq") == null) {
var es:EqualizerSettings = new EqualizerSettings();
es.numOfBars = 64;
es.height = 64;
es.barSize = 1;
es.vgrid = true;
es.hgrid = 2;
es.colorManager = new SolidBarColor(0xffffffff);
es.effect = EqualizerSettings.FX_REFLECTION;
var e:Equalizer = new Equalizer();
e.name = "eq";
e.update(es);
e.x = 100;
e.y = 100;
addChild(e);
addEventListener(Event.ENTER_FRAME, e.render);
}
}
private function handleTrackClick(event:ListEvent):void {
if(soundFactory.isPlaying) {
soundFactory.stop();
}
soundFactory.urlRequest = dataGrid.selectedItem.url;
soundFactory.play();
}
]]>
</mx:Script>
<c:SoundPlayerController/>
<sp:main/>
<mx:RemoteObject
id="srv"
endpoint="http://77.126.20.54:9000/music/gateway/"
source="service"
destination="none"
showBusyCursor="true">
</mx:RemoteObject>
<mx:HBox width="200">
<mx:HSlider id="slider" value="0"
thumbDrag="handleSliderThumbDrag(event)" thumbRelease="handleSliderThumbReleas(event)"
maximum="{soundFactory.trackLength}" change="{handleSliderChange(event)}"/>
</mx:HBox>
<mx:HBox width="500">
<mx:Text id="locale" text="{i18n.decode('resources', 'helloWorld')}" fontSize="10"/>
<mx:Text id="percent" text="{soundFactory.percentLoaded.toFixed(1)}%" fontSize="10"/>
<mx:Text id="length" text="{soundFactory.elapsedTime}" fontSize="10"/>
<mx:ComboBox id="localeComboBox" dataProvider="{[I18N.en_US, I18N.ru_RU, I18N.he_IL]}"
change="localeComboBox_changeHandler(event)"/>
<mx:Button label="{i18n.decode('resources', 'play')}" click="{playTrack()}"/>
<mx:Button label="{i18n.decode('resources', 'pause')}" click="{soundFactory.pause();}"/>
<mx:Button label="{i18n.decode('resources', 'stop')}" click="{soundFactory.stop();}"/>
</mx:HBox>
<mx:VSlider id="volume" maximum="1" change="handleVolumeChange(event)" thumbDrag="handleVolumeThumbDrag(event)"/>
<mx:HSlider value="{soundFactory.pan}" id="pan" minimum="-1" maximum="1" change="handlePanChange(event)" thumbDrag="handlePanThumbDrag(event)"/>
<mx:XML id="playlist" source="assets/mp3List.xml"/>
<mx:XMLListCollection id="trackList"
source="{playlist.Track}" />
<mx:DataGrid id="dataGrid" dataProvider="{trackList}" width="400"
itemClick="handleTrackClick(event)">
<mx:columns>
<mx:DataGridColumn dataField="artist" headerText="Artist"/>
<mx:DataGridColumn dataField="title" headerText="Title"/>
<mx:DataGridColumn dataField="album" headerText="Album"/>
</mx:columns>
</mx:DataGrid>
</mx:Application>