nathank000
06-20-2007, 04:57 PM
First, thanks for reading...
OK - I am totally new to OOP and relatively new to flex. I am designing an admin area for our web app, and I am having issues with my first class. What I am tring to do is develop a class that will tack on the appropriate $_GET arguments for a php file that returns all of the users movies for use in a dataGrid. I have a list of categories on the left, and I want to limit the list of movies to a specific category when the user clicks it. I think i am just missing a point in OOP that is obvious, but I have worked on this for 2 days and I am now asking for help.
in my FLEX app I have the following code and componenents (all abbreviated...):
<mx:Script>
<![CDATA[
//create a class to make all the data calls CAN DO!!!
//import necessary classes
import mx.controls.Alert;
import mx.events.CloseEvent;
import jp.select.MovieSelect;
//create a new instance of the selectService
var selectService:MovieSelect = new MovieSelect();
]]>
</mx:Script>
<mx:Accordion x="0" y="182" width="100%" height="100%">
<mx:Canvas label="View All" width="100%" height="100%">
</mx:Canvas>
<mx:Canvas label="Categories" width="100%" height="100%">
<mx:DataGrid dropEnabled="true" x="0" y="0" id="categorySort" width="100%" height="100%" editable="false" dataProvider="{divisionalData.lastResult.divisions.category}" change="selectService.limitToCategory(categorySort.selecte dItem.recno);" >
<mx:columns>
<mx:DataGridColumn headerText="Title" dataField="title"/>
</mx:columns>
</mx:DataGrid>
</mx:Canvas>
<mx:Canvas label="Styles" width="100%" height="100%">
<mx:DataGrid x="0" y="0" width="100%" height="100%" editable="false" dataProvider="{divisionalData.lastResult.divisions.styles}">
<mx:columns>
<mx:DataGridColumn headerText="Title" dataField="col1"/>
</mx:columns>
</mx:DataGrid>
</mx:Canvas>
<mx:Canvas label="Playlists" width="100%" height="100%">
<mx:DataGrid x="0" y="0" width="100%" height="100%" editable="false" dataProvider="{divisionalData.lastResult.divisions.playlist}">
<mx:columns>
<mx:DataGridColumn headerText="Title" dataField="title"/>
</mx:columns>
</mx:DataGrid>
</mx:Canvas>
</mx:Accordion>
<mx:DataGrid dragEnabled="true" doubleClickEnabled="true" click="stopPlayback(); enableMovieOptions();" id="movieGrid" x="0" y="0" width="100%" height="100%" rowHeight="30">
<mx:columns>
<mx:DataGridColumn headerText="Preview" dataField="thumbnail" paddingLeft="10" itemRenderer="mx.controls.Image"/>
<mx:DataGridColumn headerText="Status" dataField="status" editable="true"/>
<mx:DataGridColumn headerText="Title" dataField="title"/>
<mx:DataGridColumn headerText="Filesize" dataField="filesize"/>
<mx:DataGridColumn headerText="Size" dataField="width"/>
<mx:DataGridColumn headerText="Duration" dataField="duration"/>
<mx:DataGridColumn headerText="Category" dataField="category"/>
<mx:DataGridColumn headerText="Style" dataField="style"/>
</mx:columns>
</mx:DataGrid>
in my class file I have the following code:
package jp.select {
//import stuff
import mx.rpc.http.HTTPService;
import mx.rpc.events.ResultEvent;
import mx.controls.Alert;
import flash.events.Event;
public class MovieSelect
{
//create a new instance (?) of the httpservice obj
private var _movieSelectService:HTTPService;
//create the first function which initializes the class (?)
//below is a constructor
//it should have the same name as the class
//it SHOULD NOT declare a return type or return value.
public function MovieSelect(){
_movieSelectService = new HTTPService();
_movieSelectService.send();
//for local testing
//_movieSelectService.url = "http://localhost/jetpac/userMoviesSelectLocal.php";
//for remote testing
//_movieSelectService.url = "http://jetpac.tv/iv_anager/adminData/userMoviesSelect.php";
}
public function limitToCategory(catRecno:String):void{
//set the url to the url limiter
_movieSelectService.url = "http://jetpac.tv/iv_manager/adminData/userMoviesSelect.php?limit=" +catRecno +"&limitType=category";
//alert to see if it's working
//var qicklert:Alert = Alert.show("You have invoked the limt to cat method");
//show the busy cursor while working
//_movieSelectService.showBusyCursor = true;
//add an event listner(?)
_movieSelectService.addEventListener(ResultEvent.R ESULT, updateMovieList);
//do it
_movieSelectService.send();
}
/* public function limitTopPlaylist(plRecno:String){
}
public function limitToStyle(styleRecno:String){
} */
//create an updater function to update the movie list
private function updateMovieList(event:ResultEvent):void {
var qicklert:Alert = Alert.show("You have invoked the limt to cat method");
movieGrid.dataProvider = _movieSelectService.lastResult.movies.movie;
//var movieGridData = _movieSelectService.lastResult.movies.movie;
}
}
}
so when the user clicks a category - I want the class to get the file with the appropriate arguments tacked on and then bind those results to the movie grid. Where am I going wrong?
OK - I am totally new to OOP and relatively new to flex. I am designing an admin area for our web app, and I am having issues with my first class. What I am tring to do is develop a class that will tack on the appropriate $_GET arguments for a php file that returns all of the users movies for use in a dataGrid. I have a list of categories on the left, and I want to limit the list of movies to a specific category when the user clicks it. I think i am just missing a point in OOP that is obvious, but I have worked on this for 2 days and I am now asking for help.
in my FLEX app I have the following code and componenents (all abbreviated...):
<mx:Script>
<![CDATA[
//create a class to make all the data calls CAN DO!!!
//import necessary classes
import mx.controls.Alert;
import mx.events.CloseEvent;
import jp.select.MovieSelect;
//create a new instance of the selectService
var selectService:MovieSelect = new MovieSelect();
]]>
</mx:Script>
<mx:Accordion x="0" y="182" width="100%" height="100%">
<mx:Canvas label="View All" width="100%" height="100%">
</mx:Canvas>
<mx:Canvas label="Categories" width="100%" height="100%">
<mx:DataGrid dropEnabled="true" x="0" y="0" id="categorySort" width="100%" height="100%" editable="false" dataProvider="{divisionalData.lastResult.divisions.category}" change="selectService.limitToCategory(categorySort.selecte dItem.recno);" >
<mx:columns>
<mx:DataGridColumn headerText="Title" dataField="title"/>
</mx:columns>
</mx:DataGrid>
</mx:Canvas>
<mx:Canvas label="Styles" width="100%" height="100%">
<mx:DataGrid x="0" y="0" width="100%" height="100%" editable="false" dataProvider="{divisionalData.lastResult.divisions.styles}">
<mx:columns>
<mx:DataGridColumn headerText="Title" dataField="col1"/>
</mx:columns>
</mx:DataGrid>
</mx:Canvas>
<mx:Canvas label="Playlists" width="100%" height="100%">
<mx:DataGrid x="0" y="0" width="100%" height="100%" editable="false" dataProvider="{divisionalData.lastResult.divisions.playlist}">
<mx:columns>
<mx:DataGridColumn headerText="Title" dataField="title"/>
</mx:columns>
</mx:DataGrid>
</mx:Canvas>
</mx:Accordion>
<mx:DataGrid dragEnabled="true" doubleClickEnabled="true" click="stopPlayback(); enableMovieOptions();" id="movieGrid" x="0" y="0" width="100%" height="100%" rowHeight="30">
<mx:columns>
<mx:DataGridColumn headerText="Preview" dataField="thumbnail" paddingLeft="10" itemRenderer="mx.controls.Image"/>
<mx:DataGridColumn headerText="Status" dataField="status" editable="true"/>
<mx:DataGridColumn headerText="Title" dataField="title"/>
<mx:DataGridColumn headerText="Filesize" dataField="filesize"/>
<mx:DataGridColumn headerText="Size" dataField="width"/>
<mx:DataGridColumn headerText="Duration" dataField="duration"/>
<mx:DataGridColumn headerText="Category" dataField="category"/>
<mx:DataGridColumn headerText="Style" dataField="style"/>
</mx:columns>
</mx:DataGrid>
in my class file I have the following code:
package jp.select {
//import stuff
import mx.rpc.http.HTTPService;
import mx.rpc.events.ResultEvent;
import mx.controls.Alert;
import flash.events.Event;
public class MovieSelect
{
//create a new instance (?) of the httpservice obj
private var _movieSelectService:HTTPService;
//create the first function which initializes the class (?)
//below is a constructor
//it should have the same name as the class
//it SHOULD NOT declare a return type or return value.
public function MovieSelect(){
_movieSelectService = new HTTPService();
_movieSelectService.send();
//for local testing
//_movieSelectService.url = "http://localhost/jetpac/userMoviesSelectLocal.php";
//for remote testing
//_movieSelectService.url = "http://jetpac.tv/iv_anager/adminData/userMoviesSelect.php";
}
public function limitToCategory(catRecno:String):void{
//set the url to the url limiter
_movieSelectService.url = "http://jetpac.tv/iv_manager/adminData/userMoviesSelect.php?limit=" +catRecno +"&limitType=category";
//alert to see if it's working
//var qicklert:Alert = Alert.show("You have invoked the limt to cat method");
//show the busy cursor while working
//_movieSelectService.showBusyCursor = true;
//add an event listner(?)
_movieSelectService.addEventListener(ResultEvent.R ESULT, updateMovieList);
//do it
_movieSelectService.send();
}
/* public function limitTopPlaylist(plRecno:String){
}
public function limitToStyle(styleRecno:String){
} */
//create an updater function to update the movie list
private function updateMovieList(event:ResultEvent):void {
var qicklert:Alert = Alert.show("You have invoked the limt to cat method");
movieGrid.dataProvider = _movieSelectService.lastResult.movies.movie;
//var movieGridData = _movieSelectService.lastResult.movies.movie;
}
}
}
so when the user clicks a category - I want the class to get the file with the appropriate arguments tacked on and then bind those results to the movie grid. Where am I going wrong?