Still not working it says it cannot "connect" to the filterInput and genresInput and those two are located in MovieView.mxml
--- In [email protected], "Michael Labriola" <[EMAIL PROTECTED]> wrote: > > > In your result handler, call the refresh method after you set the > filterFunction. > > --Mike > > --- In [email protected], "pioplacz" <icep87@> wrote: > > > > Yes, i want to put my filter function in the main mxml file where > all my HTTPServices are > > locates. I have already apply my filterfunction in the result > handler in the HTTPService the > > problem is that i cannot get it to connect with the textinput > located in a MXML ViewStack > > component. > > > > I pass my code here for both Main.MXML and MovieView.MXML. > > > > Hopes this help you all to help me. > > > > Main.MXML: > > > > <?xml version="1.0" encoding="utf-8"?> > > <mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" xmlns="*" > > layout="absolute" > > horizontalAlign="center" verticalAlign="middle" > > backgroundGradientColors="[#000000, #000000]" > > width="100%" height="100%" creationComplete="initApp()" > > viewSourceURL="srcview/index.html" > > > > > <mx:HTTPService id="movieService" > url="http://192.168.25.200/PHP/katalog.php" > > useProxy="false" > > result="srv_results(event)" fault="msFaultHandler(event);" > invoke="msInvokeHandler > > (event);"/> > > <!-- HTTPSerivce for the tv-shows starts here --> > > <mx:HTTPService id="tvService" > url="http://192.168.25.200/PHP/tvshows.php" > > useProxy="false" result="tv_results(event)"/> > > <mx:HTTPService id="epService" > url="http://192.168.25.200/PHP/tvepisodes.php" > > useProxy="false" result="ep_results(event)"/> > > <!-- END --> > > <!--<mx:Model id="ipService" source="data/ip.xml"/>--> > > <mx:Style source="katalog2main.css"/> > > <mx:Script> > > <![CDATA[ > > import mx.managers.CursorManager; > > import mx.collections.IViewCursor; > > import mx.rpc.events.ResultEvent; > > import mx.rpc.events.FaultEvent; > > import mx.rpc.events.InvokeEvent; > > import mx.collections.ArrayCollection; > > import mx.events.ItemClickEvent; > > import mx.controls.Alert; > > import mx.events.CloseEvent; > > import flash.events.Event; > > > > private function initApp():void > > { > > movieService.send(); > > tvService.send(); > > epService.send(); > > } > > > > private function msFaultHandler(event:FaultEvent):void > > { > > > > // There was an error in loading the XML > > Alert.show (event.fault.message); > > > > // Hide the busy cursor > > CursorManager.removeBusyCursor(); > > } > > > > // Gets called when HTTPService is invoked to > > // request the XML. > > private function msInvokeHandler(event:InvokeEvent):void > > > > { > > // Display the busy cursor > > CursorManager.setBusyCursor(); > > } > > > > public function srv_results(event:ResultEvent):void > > { > > movieCollection = event.result.helakatalog.katalog as > ArrayCollection; > > movieCollection.filterFunction=movieFilter; > > //Hide the busy cursor > > CursorManager.removeBusyCursor(); > > } > > > > public function tv_results(event:ResultEvent):void > > { > > tvCollection = event.result.helakatalog.katalog as > > ArrayCollection; > > //tvCollection.filterFunction=tvshowsFilter; > > } > > > > public function ep_results(event:ResultEvent):void > > { > > epCollection = event.result.helakatalog.katalog as > > ArrayCollection; > > //epCollection.filterFunction=episodeFilter; > > } > > > > [Bindable] > > private var movieCollection:ArrayCollection; > > > > [Bindable] > > private var tvCollection:ArrayCollection; > > > > [Bindable] > > private var epCollection:ArrayCollection; > > > > // Filter function > > public function movieFilter(item:Object):Boolean > > { > > var result:Boolean=false; > > if (!item.title.length > > || > item.title.toUpperCase().indexOf(filterInput.text.toUpperCase()) >= 0) > > if (!item.genres.length > > || > item.genres.toUpperCase().indexOf(genresInput.selectedItem.data.toUpperCase > > ()) >= 0) > > result=true; > > > > return result; > > } > > > > > > ]]> > > </mx:Script> > > <mx:VBox width="85%" height="100%" verticalCenter="20" > horizontalCenter="0" > > top="0"> > > <mx:ViewStack id="mainViewStack" width="100%" height="100%" > creationPolicy="all"> > > <!--MovieView HERE --> > > <MovieView id="mView" label="Filmer" > movieCollection="{movieCollection}" > > movieFilter="movieFilter"/> > > <!--HomeView HERE--> > > <mx:Canvas id="home" label="Start" width="100%" height="100%"> > > <mx:VBox width="100%" height="100%" id="startVbox" > horizontalCenter="0" > > bottom="0"> > > <mx:Canvas width="100%" height="400" > > id="questionCanvas" > > horizontalCenter="0" top="0" > > > <mx:Image source="assets/question.png" autoLoad="true" > > horizontalCenter="0" top="0"/> > > <mx:Image source="assets/movie_start.png" > > autoLoad="true" > > horizontalCenter="-99" bottom="134" > click="mainViewStack.selectedChild=mView;"/> > > <mx:Image source="assets/tv_start.png" autoLoad="true" > > horizontalCenter="98" bottom="134" > click="mainViewStack.selectedChild=tvView;"/> > > </mx:Canvas> > > <mx:ApplicationControlBar id="dockedBar" dock="true" > width="100%" height="40"> > > <mx:HBox horizontalAlign="right" paddingBottom="5" > paddingTop="5"> > > <mx:Spacer width="100%" id="spacer1"/> > > </mx:HBox> > > <mx:HBox horizontalAlign="left" width="100%"> > > <mx:Image source="assets/star.png" > > autoLoad="true" > height="16" > > verticalAlign="middle" scaleContent="false" id="image1"/> > > <mx:Text text="SopranKatalog Ver.2.1 BETA" > > color="#ffffff" > > fontWeight="bold" fontSize="12" fontFamily="Arial" textAlign="right" > id="text1"/> > > </mx:HBox> > > </mx:ApplicationControlBar> > > <mx:HBox id="footer" width="100%"> > > <mx:Spacer width="100%" /> > > </mx:HBox> > > </mx:VBox> > > </mx:Canvas> > > <!-- TVView HERE --> > > <TvView id="tvView" label="TV" epCollection="{epCollection}" > > tvCollection="{tvCollection}"/> > > > > </mx:ViewStack> > > > > </mx:VBox> > > > > </mx:Application> > > > > MovieView.MXML: > > > > <?xml version="1.0" encoding="utf-8"?> > > <mx:Canvas xmlns:mx="http://www.adobe.com/2006/mxml" xmlns="*" > width="100%" > > height="100%"> > > <mx:Script> > > <![CDATA[ > > import mx.collections.ArrayCollection; > > import mx.events.ItemClickEvent; > > import mx.controls.Alert; > > import mx.events.CloseEvent; > > > > [Bindable] > > var movieCollection:ArrayCollection; > > > > > > public var u:URLRequest; > > > > // Event listener to open URL when in dataGrid view > > private function dgMovieListClick(eventObj:Event):void { > > u = new > URLRequest("http://192.168.25.200/Movies/" + > > dgMovieList.selectedItem.link); > > navigateToURL(u); > > Alert.show("Högerklicka på filnamnet och tryck > spara som..", "Påbörja din > > nerladdning", Alert.OK); > > } > > // Event listener to open URL when in tileList view > > private function dgTileListClick(eventObj:Event):void { > > u = new > URLRequest("http://192.168.25.200/Movies/" + > > tilelist1.selectedItem.link); > > navigateToURL(u); > > Alert.show("Högerklicka på filnamnet och tryck > spara som..", "Påbörja din > > nerladdning", Alert.OK); > > } > > // Event listener to open Internet URL when in dataGrid view > > private function dgInternetClick(eventObj:Event):void { > > u = new > URLRequest("http://sopran.dnsalias.com/Movies/" + > > dgMovieList.selectedItem.link); > > navigateToURL(u); > > Alert.show("Högerklicka på filnamnet och tryck > spara som..", "Påbörja din > > nerladdning", Alert.OK); > > } > > // Event listener to open Internet URL when in tileList view > > private function internetClick(eventObj:Event):void { > > u = new > URLRequest("http://sopran.dnsalias.com/Movies/" + > > tilelist1.selectedItem.link); > > navigateToURL(u); > > Alert.show("Högerklicka på filnamnet och tryck > spara som..", "Påbörja din > > nerladdning", Alert.OK); > > } > > ]]> > > </mx:Script> > > <!-- An ArrayCollection with an array of objects. --> > > <mx:ArrayCollection id="genres"> > > <mx:Array> > > <mx:Object label="Alla" data=""/> > > <mx:Object label="Action" data="Action"/> > > <mx:Object label="Animerat" data="Animerat"/> > > <mx:Object label="Drama" data="Drama"/> > > <mx:Object label="Komedi" data="Komedi"/> > > <mx:Object label="Thriller" data="Thriller"/> > > </mx:Array> > > </mx:ArrayCollection> > > <mx:states> > > <!-- MovieList Grid Starts Here --> > > <mx:State name="Grid"> > > <mx:RemoveChild target="{tilelist1}"/> > > <mx:RemoveChild target="{dockedBar}"/> > > <mx:AddChild relativeTo="{mainVbox}" > > position="lastChild" > > target="{dockedBar}"/> > > <mx:SetEventHandler target="{stchange}" name="click" > > handler="currentState=''"/> > > <mx:AddChild relativeTo="{tilecanvas}" > > position="lastChild"> > > <mx:DataGrid id="dgMovieList" width="100%" > > height="100%" > > dataProvider="{movieCollection}" doubleClickEnabled="true" > > itemDoubleClick="dgMovieListClick(event);" editable="false" > borderStyle="none" y="0"> > > <mx:columns> > > <mx:DataGridColumn > > headerText="Titel" dataField="title"/ > > > > > <mx:DataGridColumn > > headerText="Kategori" > > dataField="genres"/> > > <mx:DataGridColumn > > headerText="År" dataField="year"/> > > <mx:DataGridColumn > > headerText="Utgivare" > > dataField="publisher"/> > > </mx:columns> > > </mx:DataGrid> > > </mx:AddChild> > > <mx:RemoveChild target="{footer}"/> > > <mx:AddChild relativeTo="{mainVbox}" > > position="lastChild" > > target="{footer}"/> > > <mx:SetProperty target="{counterText}" name="height" > > value="20"/> > > <mx:RemoveChild target="{linkbutton1}"/> > > <mx:RemoveChild target="{image1}"/> > > </mx:State> > > <!-- Tv-Shows List Starts Here --> > > <!-- Tv-Shows END --> > > <!-- MovieList Grid END --> > > </mx:states> > > <!-- Define the effects for the transitions between states --> > > <mx:transitions> > > <!-- Define the transition from the base state to the Grid > state.--> > > <mx:Transition id="toGrid" fromState="*" toState="Grid"> > > <mx:Sequence target="{tilecanvas}" > > > <mx:Parallel target="{tilecanvas}"> > > <mx:Fade alphaFrom="0" alphaTo="1" > > duration="1500"/> > > <mx:Move yFrom="1500" yBy="-1500" duration="1000"/> > > </mx:Parallel> > > </mx:Sequence> > > </mx:Transition> > > > > <!-- Define the transition from the TvShows state to the > TvEpisodes state.--> > > <mx:Transition id="toEpisodes" fromState="TvShows" > toState="TvEpisodes"> > > <mx:Sequence target="{tilecanvas}" > > > <mx:WipeUp duration="1000" /> > > </mx:Sequence> > > </mx:Transition> > > <!-- Define the transition from the Grid state to the base > state.--> > > <mx:Transition id="toDefault" fromState="Grid" toState="*"> > > <mx:Sequence target="{tilecanvas}" > > > <mx:Parallel target="{tilecanvas}"> > > <mx:Fade alphaFrom="0" alphaTo="1" > > duration="1500"/> > > <mx:Move yFrom="1500" yBy="-1500" > > duration="1000"/> > > </mx:Parallel> > > </mx:Sequence> > > </mx:Transition> > > </mx:transitions> > > <!-- Transition effects END --> > > > > <mx:VBox width="100%" height="100%" id="mainVbox" > horizontalCenter="0" top="0"> > > <mx:Canvas width="100%" height="80%" id="tilecanvas" > > > <mx:TileList id="tilelist1" width="100%" height="100%" > itemRenderer="thumbnail" > > dataProvider="{movieCollection}" > > horizontalScrollPolicy="off" borderStyle="none" top="19" > > doubleClickEnabled="true" > > itemDoubleClick="dgTileListClick(event);" > > allowMultipleSelection="false" horizontalCenter="0"/> > > </mx:Canvas> > > <mx:ApplicationControlBar id="dockedBar" dock="true" width="100%"> > > <mx:HBox horizontalAlign="right" paddingBottom="5" > paddingTop="5"> > > <mx:Image source="assets/zoom.png" autoLoad="true" > height="100%" > > verticalAlign="middle" scaleContent="false"/> > > <mx:TextInput id="filterInput" text="" > change="movieCollection.refresh();" > > width="166" toolTip="Skriv.."/> > > <mx:Spacer width="100%" id="spacer1"/> > > <mx:Image source="assets/color_swatch.png" > autoLoad="true" height="100%" > > verticalAlign="middle" scaleContent="false"/> > > <mx:Text text="Kategori" color="#ffffff" fontSize="12" > fontFamily="Arial" > > fontWeight="bold" textAlign="left" selectable="false"/> > > <mx:ComboBox id="genresInput" dataProvider="{genres}" > > enabled="true" > > color="#ffffff" change="movieCollection.refresh();"/> > > </mx:HBox> > > <mx:HBox horizontalAlign="right" width="100%" paddingBottom="5" > > paddingTop="5"> > > <mx:Image source="assets/application_cascade.png" > autoLoad="true" > > height="100%" verticalAlign="middle" scaleContent="false" id="image2"/> > > <mx:LinkButton id="stchange" label="Byta läge" > textAlign="left" width="69" > > click="currentState='Grid'"/> > > <mx:Image source="assets/film.png" autoLoad="true" > height="100%" > > verticalAlign="middle" scaleContent="false" id="image3"/> > > <mx:Text id="counterText" > text="{movieCollection.length}" paddingTop="2" > > color="#ffffff" fontWeight="bold" textAlign="left" width="30" > height="20" > > selectable="false" toolTip="Antal filmer som visas"/> > > <!--<mx:LinkButton id="intlink" label="Download" />--> > > </mx:HBox> > > </mx:ApplicationControlBar> > > <mx:HBox id="footer" width="100%"> > > <mx:LinkButton id="tvchange" label="TvShows"/> > > <mx:Spacer width="100%" /> > > <mx:Text text="FilmKatalog Ver.2 BETA" color="#ffffff" > fontWeight="bold" > > fontSize="12" fontFamily="Arial" textAlign="right" id="text1"/> > > <mx:Image source="assets/world_link.png" autoLoad="true" > height="100%" > > verticalAlign="middle" scaleContent="false" id="image1"/> > > <mx:LinkButton label="Internet" width="63" > click="internetClick(event);" > > textAlign="left" toolTip="Klicka här om du befinner dig utanför hemmet" > > id="linkbutton1"/> > > </mx:HBox> > > </mx:VBox> > > </mx:Canvas> > > > > > > --- In [email protected], "Michael Labriola" <labriola@> wrote: > > > > > > > > > If I understand your question correctly (and I am not sure that I do), > > > I would personally put your filter function in the file that currently > > > calls the HTTPService and gets the result. Unless you are using one of > > > the, or your own, common frameworks, most people seem to put this in > > > their main application file. > > > > > > Depending a lot on how your code is constructed, you can probably > > > apply this filter function in the result handler for your > HTTPService. > > > > > > If I am missing the point, or your setup is more complex, let me know. > > > > > > As an aside, please take a look at the refresh method of the > > > ListCollectionView. If you are not actually replacing the whole > > > collection, you could use this to simply apply the filter. > > > > > > --Mike > > > > > > --- In [email protected], "pioplacz" <icep87@> wrote: > > > > > > > > Hi! > > > > > > > > I was just wondering is it possible to make a filterfunction work > > > between ViewStack > > > > components. What i mean is i'm calling the HTTP service in my > > > main.mxml but showing > > > > the results in MovieView.mxml passing the data works fine. But i > > > can't figure out where i > > > > should write the filter function: > > > > > > > > // Filter function > > > > public function movieFilter(item:Object):Boolean > > > > { > > > > var result:Boolean=false; > > > > if (!item.title.length > > > > || > > > item.title.toUpperCase().indexOf(filterInput.text.toUpperCase()) >= 0) > > > > if (!item.genres.length > > > > || > > > > item.genres.toUpperCase().indexOf(genresInput.selectedItem.data.toUpperCase > > > > ()) >= 0) > > > > result=true; > > > > > > > > return result; > > > > } > > > > > > > > and where i should put: > > > > > > > > movieCollection.filterFunction=movieFilter; > > > > > > > > From the beginning i had all that in my Main.mxml and it worked > > > fine. Can somebody help > > > > me, if you even get what i mean ? > > > > > > > > > > -- Flexcoders Mailing List FAQ: http://groups.yahoo.com/group/flexcoders/files/flexcodersFAQ.txt Search Archives: http://www.mail-archive.com/flexcoders%40yahoogroups.com Yahoo! Groups Links <*> To visit your group on the web, go to: http://groups.yahoo.com/group/flexcoders/ <*> Your email settings: Individual Email | Traditional <*> To change settings online go to: http://groups.yahoo.com/group/flexcoders/join (Yahoo! ID required) <*> To change settings via email: mailto:[EMAIL PROTECTED] mailto:[EMAIL PROTECTED] <*> To unsubscribe from this group, send an email to: [EMAIL PROTECTED] <*> Your use of Yahoo! Groups is subject to: http://docs.yahoo.com/info/terms/

