Skip to content

Instantly share code, notes, and snippets.

@aanoaa
Created March 8, 2010 07:01
Show Gist options
  • Save aanoaa/324952 to your computer and use it in GitHub Desktop.
Save aanoaa/324952 to your computer and use it in GitHub Desktop.
sound_effect.loadJavascript('strastar.js'); // 사이즈별 이슈를 없애기 위해..
component='startWnd';
readXML('contents.xml'); // config file
var tmp=[handset_type(), g_contents['index_bg'][0], 'jpg'];
eval(component).bgImage=tmp.join('.'); // WQVGA.bg.jpg
var remainder_height=SCREEN_H; // 400
var remainder_width=SCREEN_W; // 320
var g_fart_seq=1;
var MAX_FART_SEQ=3;
if(SCREEN_H==QVGA_H) {
makeButton(35, 60, 3, 4, 50, 50, 10);
}
else if(SCREEN_H==WQVGA_H) {
makeButton(20, 80, 3, 4, 60, 60, 10);
}
else {
makeButton(20*2, (20)*2, 3*2, 4*2, 60*2, 60*2, 10*2);
}
function makeButton(x, y, row, column, width, height, interval) {
logprint('debug', 'makeButton');
logprint('info', 'row: '+row, 'column: '+column, 'width: '+width, 'height: '+height, 'interval: '+interval);
var k=0;
for(var i=0; i<column; i++) {
var b_x, b_y;
if(i==0) {
b_y=y;
}
else {
b_y=y+(height+interval)*i;
}
for(var j=0; j<row; j++) {
if(j==0) {
b_x=x;
}
else {
b_x=x+(width+interval)*j;
}
button_init('button'+k, b_x, b_y, width, height, 'sound_on');
var tmp=[handset_type(), g_contents['unfocus_prefix'][0], g_contents['sound'][k], 'png'];
eval('button'+k).bgImage=tmp.join('.');
var tmp=[handset_type(), g_contents['focus_prefix'][0], g_contents['sound'][k], 'png'];
eval('button'+k).focusedBgImage=tmp.join('.');
k++;
}
}
}
var audio=new Audio(eval(this.name));
audio.callback=audio_callback;
function sound_on(sender) {
logprint('debug', 'sound_on');
logprint('debug', 'sender: '+sender.name);
var fileType='mmf';
var mimeType='Yamaha_MA3';
var index=sender.name.match(/\d+$/);
var song_name=g_contents['sound'][index];
if(song_name=='방구') {
song_name+=g_fart_seq;
g_fart_seq++;
if(g_fart_seq>MAX_FART_SEQ) {
g_fart_seq=1;
}
}
if(platform()=="Windows Mobile") {
fileType='mp3';
mimeType='audio/mp3';
}
song_name+='.'+fileType;
logprint('info', 'song_name: '+song_name, 'fileType: '+fileType, 'mimeType: '+mimeType);
var status=audio.getStatus();
if(status==1 || status==2) {
audio.stop();
audio.close();
}
if(audio.open(song_name, mimeType)) {
logprint('debug', 'opened');
audio.volume=100;
//audio.isRepeated=true;
audio.play();
}
else {
logprint('error', 'open failed');
}
}
function audio_callback(status)
{
logprint('debug', 'audi_callback');
logprint('info', 'status: '+status);
if(status == 4) {
audio.close();
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment