PDA

View Full Version : Video won't load uopn single click


camcim
06-21-2007, 06:00 AM
Hi all,
I am in the process of developing a dynamic video player using flash/php/mysql.
You can view it here: http://www.pmpak.com/mypackage/mptv/
Everything appears to be running fine however if you select an Episode (say Episode 1) and proceeed to click on a video from the list it will play that video just fine. If i then choose another video to play i have to click on the video twice. If i eventually play them all they will play upon one click (i guess because they are cached or perhaps even a bug???).
Can anyone offer advice into how i can make it load the selected video upon one click?

Here is my code:

import mx.remoting.*;
import mx.rpc.*;
import mx.remoting.debug.NetDebug;

NetDebug.initialize();


//NetServices.setDefaultGatewayUrl("http://localhost/flashservices/gateway.php");
//Remote details
NetServices.setDefaultGatewayUrl("http://www.mypackage.flvhost.com/flashservices/gateway.php");
//NetServices.setDefaultGatewayUrl("http://www.pmpak.com/flashservices/gateway.php");
var gatewayConnection = NetServices.createGatewayConnection();
var service = gatewayConnection.getService("mptvData", this);

unloadMovie("column_1");

show_col2_mc = attachMovie("column_2", "column_2", this.getNextHighestDepth());
show_col2_mc._x = 32
show_col2_mc._y = 478

show_col2_mc.eplist.enabled = true;
show_col2_mc.eplist._alpha = 100;

var callServer = service.getSeries();

// Get series into combobox
getSeries_Result = function(rs){
if(rs!="error"){
combobox = rs;

seriesCombobox = new Array();

seriesCombobox.push({label:"On Display Video's",data:"On Display Video's"});
column_2.seriesCombo.setDataProvider(seriesCombobo x);
column_2.seriesCombo.setSize(165,22);

//************************************************** *
// Selection function for series combobox
//************************************************** *



var callServer = service.getEpisodes();

getEpisodes_Result = function(rs){
if(rs!="error"){

show_col2_mc.eplist.enabled = true;
show_col2_mc.eplist._alpha = 100;

return_query = rs;

episodes = new Array();

for (var i = 0; i<return_query.length; i++) {
episodes.push({label:return_query[i]['cat_name'],data:return_query[i]['cat_id']});
}

show_col2_mc.eplist.setDataProvider(episodes);
show_col2_mc.eplist.setSize(165,130);

show_col_3 = attachMovie("column_1", "column_1", this.getNextHighestDepth());
show_col_3._x = 242
show_col_3._y = 478

//************************************************** *
// Selection function for episodes combobox
//************************************************** *

var epListener:Object = new Object();
// Create event handler function.
epListener.change = function (evt_obj:Object) {
if(evt_obj.target.selectedItem.data != ""){

unloadMovie("column_1");

show_col_3 = attachMovie("column_3", "column_3", this.getNextHighestDepth());
show_col_3._x = 242
show_col_3._y = 478

var callServer = service.getVideos(evt_obj.target.selectedItem.data );

getVideos_Result = function(rs){

if(rs!="error"){

return_query = rs;

videos = new Array();

for (var i = 0; i<return_query.length; i++) {

ln0 = show_col_3.scrollPane.getScrollContent();
company_detail_mc = ln0.attachMovie("blueMovie", "blue"+i, ln0.getNextHighestDepth(), {_y:ln0._height+5, _x:5, vName:return_query[i]['file_name']});
show_col_3.scrollPane.setSize(375, 180);
show_col_3.scrollPane.refreshPane();

company_detail_mc.container.loadMovie("thumbs/"+return_query[i]['thumb_img']+".jpg", "container");
company_detail_mc.container._x = 8;
company_detail_mc.container._y = 8;
company_detail_mc.new_tag._alpha = 0;
company_detail_mc.vid_title.htmlText = return_query[i]['video_title'];
company_detail_mc.vid_duration.htmlText = return_query[i]['video_duration'];

if (return_query[i]['new_flag'] == "1"){
company_detail_mc.new_tag._alpha = 100;
}


company_detail_mc.i = i;
company_detail_mc.onPress = function() {

// this traces correctly upon one click however the associate video only loads upon two clicks
trace(return_query[this.i]['file_name']);
var server:String = "198.64.172.160";
var appName:String = "test_video/_definst_/movies/mypackagefcs";
var vidName:String = return_query[this.i]['file_name'];
myDisplay.playStream(vidName, server, appName);

}

}

show_col_3.vidlist.setDataProvider(videos);
show_col2_mc.vidlist.setSize(150,130);

}
}

getVideos_Error = function(rs){
trace("Error");
}

} else {

}

}
// Add event listener.
show_col2_mc.eplist.addEventListener("change", epListener);

}
}

getEpisodes_Error = function(rs){
trace("Error");
}




/////////////////////////////////////////////

}
}

getSeries_Error = function(rs){
trace("Error");
}


This is where i create the video select list:

company_detail_mc.i = i;
company_detail_mc.onPress = function() {

// this traces correctly upon one click however the associate video only loads upon two clicks
trace(return_query[this.i]['file_name']);
var server:String = "198.64.172.160";
var appName:String = "test_video/_definst_/movies/mypackagefcs";
var vidName:String = return_query[this.i]['file_name'];
myDisplay.playStream(vidName, server, appName);

}

camcim
06-23-2007, 09:04 AM
Anyone got a possible solution?