2 Replies Latest reply on Aug 4, 2006 5:55 PM by cubum

    String from PHP

    cubum
      I have news.php file return
      $Return = "<news>";
      $Return .="<pageCount>$MaxPage</pageCount>";
      $Return .= "</news>";
      I want to assign txt_pagecount=pageCount but error :(
      i try: var txt_pagecount:String = newsRequest.lastResult.news.pageCount;
        • 1. Re: String from PHP
          jrunrandy Adobe Employee
          Can you please post the mx:HTTPService tag used to retrieve the xml from php?
          • 2. Re: String from PHP
            cubum Level 1
            <?xml version="1.0" encoding="utf-8"?>
            <mx:Canvas xmlns:mx=" http://www.adobe.com/2006/mxml" width="100%" height="100%"
            creationComplete="newsRequest.send();initApp()">
            <mx:Script>
            <![CDATA[
            import mx.controls.Text;
            import mx.controls.Alert;
            private var pageIdx:int;
            [Bindable]
            public var numPageCount: Array = new Array();
            public function initApp():void {
            bntBack.visible = false;
            var i:int;
            var strPageCount:String = newsRequest.lastResult.news.pageCount;
            //var strPageCount:String = "4";
            for (i=1; i<=int(strPageCount); i++) {
            numPageCount.push({label:i, idx:i});
            }
            }
            private function goPage(): void{
            newsRequest.url=" http://localhost/flex/news.php?PageNo="+listPage.selectedItem.idx;
            pageIdx = listPage.selectedItem.idx-1;

            if(pageIdx<=0){
            bntBack.visible = false;
            }
            else{
            bntBack.visible = true;
            }

            if(pageIdx==3){
            bntNext.visible = false
            }
            else{
            bntNext.visible = true;
            }

            newsRequest.send();
            }
            ]]>
            </mx:Script>
            <mx:HTTPService id="newsRequest" url=" http://localhost/flex/news.php" useProxy="false" method="POST" >
            <mx:request xmlns="">
            <nid>{dgNews.selectedItem.nid}</nid>
            </mx:request>
            </mx:HTTPService>
            <mx:VDividedBox left="5" top="25" bottom="10" right="5" liveDragging="true">
            <mx:VBox height="100%" width="100%">
            <mx:DataGrid width="100%" height="100%" id="dgNews"
            dataProvider="{newsRequest.lastResult.news.info}" updateComplete="listPage.selectedIndex=pageIdx">
            <mx:columns>
            <mx:DataGridColumn headerText="Tiêu đề" dataField="title" width="75"/>
            <mx:DataGridColumn headerText="Ngày đăng" dataField="date" width="25"/>
            </mx:columns>
            </mx:DataGrid>
            <mx:HBox width="100%" backgroundColor="#F5F5F5" height="25" verticalAlign="middle" horizontalAlign="right" horizontalGap="1">
            <mx:Text text="{newsRequest.lastResult.news.pageCount}" id="numPage"/>
            <mx:Text id="pCount"/>
            <mx:Label text="Trang:" paddingTop="4" paddingLeft="2"/>
            <mx:Button label="&lt;" toolTip="Lui 1 trang" click="listPage.selectedIndex=pageIdx-1;goPage()" id="bntBack"/>
            <mx:ComboBox id="listPage" width="59" dataProvider="{numPageCount}" change="goPage();" labelField="label" />
            <mx:Button label="&gt;" toolTip="Tới 1 trang" click="listPage.selectedIndex=pageIdx+1;goPage()" id="bntNext"/>
            </mx:HBox>
            </mx:VBox>
            <mx:TextArea width="100%" height="100%" editable="false" paddingLeft="3" paddingRight="3">
            <mx:htmlText>
            {dgNews.selectedItem.content}
            </mx:htmlText>
            </mx:TextArea>
            </mx:VDividedBox>
            </mx:Canvas>