Jump to content
xisto Community

sanbeand

Members
  • Content Count

    52
  • Joined

  • Last visited

Posts posted by sanbeand


  1. hey hi guys..this is a code i used to print data from a datagrid and it is so useful in ur RIAs hope it helps...
    cheers!


    mybtn.onPress=function(){doPrint(mydg, true)}function doPrint(datagrid:mx.controls.DataGrid, fitPage:Boolean):Void {	if (fitPage == undefined) fitPage = true;	var pj:PrintJob = new PrintJob();	// position of currently visible rows stored	var prev_vPosition:Number = datagrid.vPosition;	var prev_width:Number = datagrid.width;	var prev_height:Number = datagrid.height;	var prev_vScroll = datagrid.vScrollPolicy;	var prev_selectedIndex = datagrid.selectedIndex;	var dgPrintWidth:Number = 0;	var dgPrintHeight:Number = 0;		if (pj.start() != true) {  return;	}	// hide scrollbar for print 	datagrid.vScrollPolicy = "off";	// hide the selection	datagrid.selectedIndex = undefined;		// datagrid width for printing	if (fitPage) {  dgPrintWidth = pj.pageWidth;	} else {  if (prev_width < pj.pageWidth) {  	dgPrintWidth = prev_width;  } else {  	dgPrintWidth = pj.pageWidth;  }	}	// number of rows per view, ignoring fractions (floor)	var rowsPerPage:Number = Math.floor((pj.pageHeight-datagrid.headerHeight)/datagrid.rowHeight);	// total number of pages to be printed, if there are any fractions, have one page for that (ceil)	var total_pages:Number = Math.ceil(datagrid.dataProvider.length/rowsPerPage);	// number of full pages to be printed, ignoring fractions (floor)	var full_pages:Number = Math.floor(datagrid.dataProvider.length/rowsPerPage);	// number of rows on last page if partial	var last_page_rows:Number = 0;	// height of last page if partial	var last_page_height:Number = 0;	// partial last page ? 	if (total_pages != full_pages) {  last_page_rows = datagrid.dataProvider.length - (full_pages*rowsPerPage);  last_page_height = datagrid.headerHeight + (datagrid.rowHeight * last_page_rows);	}	// datagrid height for printing	dgPrintHeight = datagrid.headerHeight + (datagrid.rowHeight * rowsPerPage);	datagrid.setSize(dgPrintWidth, dgPrintHeight);  	for (var i = 0; i<total_pages; i++) {  // if last page and partial - resize grid  if ((i == total_pages - 1) && (last_page_rows > 0)) {  	datagrid.setSize(dgPrintWidth, last_page_height);  }  // move the visible row position.  datagrid.vPosition = i*rowsPerPage;  // size box relative to the grid  var b = {xMin:0, xMax:datagrid.width, yMin:0, yMax:datagrid.height};  if (!fitPage && prev_width < pj.pageWidth) {  	var x0 = (pj.pageWidth - prev_width) / 2;  	b = {xMin:(-x0), xMax:(datagrid.width+x0), yMin:0, yMax:datagrid.height};  }  pj.addPage(datagrid, B);	}	pj.send();	delete pj;	// previous scrollPolicy	datagrid.vScrollPolicy = prev_vScroll;	// position of currently visible rows restored	datagrid.setSize(prev_width, prev_height);	datagrid.selectedIndex = prev_selectedIndex;	datagrid.vPosition = prev_vPosition;}

    Notice from BuffaloHELP:
    Last caution note. I PMed you about using CODE tags. You ignored it. Credits reduced.


  2. AMFPHP in a short way is a library of php files that let u manage in

    JUST ONE FILE what u would do in many files like for example queries

    to mysql. So u can have tons of queries to mysql and all of them in

    just ONE FILE!

     

    so what is a RIA? a RIA is a Rich Internet Application commonly given

    to flash applications, not the animations or presentations we see

    daily on the internet but very useful and cool programs made in flash.

     

    the fisrt step u need to take is to download the AMFPHP library

    directly from its site at http://www.amfphp.org/, in some free hosted sites

    the latest versions doesnt run but the .9 version does...happily at

    Xisto.net i could run the latest version 1 milestone 3 and some of

    the main changes (since the milestone 1) include the utf8_decode so u

    can store frech, spanish, german names, streets etc.

     

    ok now while u are downloading AMFPHP lets go to the flash side, u can

    download the latest version at macromedia.com (latest is 8) and as we

    want to trace every action we perform we should (for sure) download the

    remoting components (http://forums.xisto.com/no_longer_exists/) it helps to build easily our RIA..ok i'll wait

    while u download it... :D ... :D ... well i think u

    alredy downloaded it... so lets go to the construction of our first

    mini RIA: :P

     

    Installation NOTE: first install Flash 8 and then the remoting components

     

    the first time u open flash u'll see the welcome window and a bunch of

    typefiles u can choose from... and as we want to just start, choose

    the flash file (fla), after u load ur new document by default Flash

    has some opened panels but maybe the components panel is not! so if it

    is not opened in the right panel go to Window>Component Panel and u'll

    see that that new panel opens and some "compenent directories are

    shown", look very closely to the User Interface and Data Components

    that are the ones we are gonna use... oh! we finished downloading

    AMFPHP good!... we are not gonna change anything from any file just

    uncompress the folder and give a name like "flashservices" (just for

    fun :P ) and then opload the "flashservices" folder to ur

    hosting server, site or just move the folder if u are running a

    webserver in ur computer to the root folder of the folder that ur

    server use to use the files eg. for IIS the folder is

    C:\Inetpub\wwwroot and for apache in my computer is C:\Program

    Files\Apache Group\htdocs...

     

    now it fits just like this:

    >LOCALHOST/flashservices/<

     

    lets leave AMFPHP and continue with flash...now that we have seen the Groups's Components drag a Combobox, a DataGrid, a TextArea and Three buttons give each component an instance name for the combobox>cb, for the Datagrid> dg fo the textArea> ta_txt and for the buttons> btn1, btn2, btn3 and put each button below each component i mean below the combobox the btn1 and so on...

    ok now that u have the compoents positioned in the stage go again to the Components Panel and drag 3 Dataset from the Data group and 3 RemotinConnector from the Data Components Group(in flash 8, in previous versions both are under Data Componets) and give an instance name for each component such as ds_1 and r_con1 and so on....

    ok now lets bind each component to be able to drive the data to the correct place...

    select the r_con1 and in the component inspector(if it is not opend go to Window>Component Inspector) select BINDINGS and click on the big + and select Results:Object and then click ok...u'll see an item is added below, click the item and in its properties select "bound to:" and select the ds_1... do the same thing with the rest of the components...

    now u finished binding the components click on the FIRST frame and go to ACTIONS (if it is not opend press F9) and paste this code:

     

    btn1.onPress=function(){r_con1.trigger();}btn2.onPress=function(){r_con2.trigger();}btn3.onPress=function(){r_con3.trigger();}
    ooops! i almost forget select the remoting connectors and modify its gateway to ur current location (where u put the flash services folder) e.g. LOCALHOST/flashservices/gateway.php and for the service write myTest and for the method of each component write myCb for the remotingconnector of the combobox, myDg for the datagrid's and myText for the TextArea's...

     

    ok now we finished the flash side :D:P ..now lets finish the last part...

     

    in amfphp files are stored as classes it means the name of the file is gonna be called as the class conatained in it... also is good to mention that u must declare each function that is gonna be used in order to be recognized by php...

    copy this file under flashservices>services folder and save the file as myTest.php

     

     

    <?phpclass myTest{        //change to match your needs        var $dbhost = "localhost";        var $dbname = "ur database name";        var $dbuser = "ur user";         var $dbpass = "ur password";      function myTest(){        $this->methodTable = array(         "myDg" => array(              "description" => "Returns products table",              "access" => "remote" // available values are private, public, remote               //"arguments" => array ("message")            ),            "myCb" => array(              "description" => "Returns products table",               "access" => "remote" // available values are private, public, remote              //"arguments" => array ("message")            ),            "myText" => array(               "description" => "Echoes the passed argument back to Flash (no need to set the return type)",              "access" => "remote", // available values are private, public, remote               "arguments" => array ("rs")            )        );                        // Initialize db connection                        $this->conn = mysql_pconnect($this->dbhost, $this->dbuser, $this->dbpass);                        mysql_select_db ($this->dbname); }      function myDg(){        return mysql_query("select * from mydg");      }      function myCb(){        return mysql_query("select * from mycombo");      }        function myText(){          return mysql_query("select myText from mytext")}?>
    ok we are almost done... now set up three tables with phpMyAdmin called "mydg, mycombo and mytext" for the mydg table set up these fields ID, Name; for the mycombo set up JUST myNames and for text use ID and myText...

    in the mydg table write new records as follows:

    ID Name

    1 Andr�s

    2 G�ero

     

    fo mycombo table set:

     

    myNames

    Andr�s

    G�ero

     

    and finally for myText:

    Andr�s is a G�ero friend

     

     

    after u save all this info u can return to flash publish ur work and pressed ur buttons to see the results! and using the utf8_decode....

     

    now we are done! :( u can start building powerful applications and RIAs!! hope it helps....

    cheers!

     

    Notice from BuffaloHELP:
    Too busy posting forgot to add CODE tags? Tisk tisk...

  3. hey hi man.. yeah me.. if u just downloaded the Flash Media Server 2 and not using the Communications Server i dont know if it helps...ok i suppose u already have something done in Com if not well it doesnt matter but the folders used to "publish" ur work are under the Flash Communication Server and look for Applications and u'll see the swf of all samples applications it means it is the place where u have to leave a copy of ur swf in order to be useful in html runtime so u might ask urself "so do i have to leave a copy of my swf and also leave the swf with the html file?" and the answer is yeah.. u should..hope it helps..cheers!


  4. well i think u can set up a new swf and add some code to include the other two swf u want to be communicated and as now those two and the "loader" make one u can communicate easily without having problems...BUT u must be careful in calling this, _root and _parent because now the _root belongs to the "loader"load the other two in the loader like:_root.loadMovie("thenameofthefirstmovie");_root.loadMovie("thenameofthesecondmovie");


  5. well there are many applications now spread all over the internet with the Flash Lite player and the player not just includes the pda but cellphones... u can see and download examples of which mobile devices, included cellphones are supported for flash lite at http://www.adobe.com/marketing-cloud/mobile-marketing.html?promoid=CUOM, also both of them need a VM in order to be played the bad thing is that java(in my own and personal opionion) the JVM is so heavy in contrast the flash player is so light and both of them offer almost the same results...

     

    cheers!


  6. i was going around the macromedia's page and then i saw a video related to the new flash and its new player, it was a presentation of a japan or chinese tv with flash player support it has a built in equalizer that equalizes in flash environment using the new Bitmap classes... unfortunately it is gonna be a long time in order to have a TV like that..cheers! :P


  7. hey guys thanx for reply... all that info rocks! but then if i have to register my domain name with some other guy... how do they do? i mean... i have my win 2003 server running with IIS and other stuff about dns and so on, and maybe they have the same server i have or how these companies work, do they share a super database or something? they are friends with the server in the garage and have a LAN? thats what i would like to know... cos i dont think microsoft pays to eg. godaddy.com for the domain do they?...


  8. so what does java and Flash Lite are? ok both of them are cross plattform, it means they can be "Played" in some Devices without having to change any code, and both of them let u have very powerful games, apps or even programs... ^_^ as u have seen most of the new cell phones and mobile devices can support both plattforms but why dont use just one of them?... as a flsah developer i think is much easier to work with a graphic environment, where u can experiment lots of things and also with a very cool skin... but then why Java is there too?.. well most of the applications is Java let us communicate with the most internal part of the computer or in this case our cell phone something Flash Lite (the version for mobile devices such as phones use) doesnt do... so if we want to have a game in flash or a little page loaded on the cell-phone or even a little application, its nice to use flash but if we want a program that uses resources from the devices such as the camera, or mic to record, the best choice is Java...both of them are good but u have to decide whether or not one should be chosen instead of the other... :lol:


  9. hey hi all!...as many of u might know macromedia has released its second version of the flex server "alpha", i was so happy beacause of the new components and all that stuff... i downloaded my copy of flex 2 with the new version of the flash player (8.5) and the new classes in ActionScript 3 and when i compile the help files i couldnt believe that the complete components were not at all quite good as the previous versions of the flex environment... im one of those users that dont care writing tons of code to demonstrate the powerful toy inside the understandable and cool skin the flash or flex environment...well in my very personal opinion macromedia must be scared of the new microsoft's"toy" codename "sparkle" or something like dat... but why should macromedia be scared about sparkle?... well the answer is beacause microsoft pretends developers to program in its new "almost" released Windows Vista and with this new version we will be able to see things that in a typical windows and sometimes boring environment we couldnt like for example to resize windows without minimize them or like see the pics in a very cool little window that opens if u put ur mose over, a big clock if u havent found the one in ur computer :lol: a black task bar, big icons(if u think the "Back" button of the explorer is big, wait for the next ones ^_^ )..but going back to the point sparkle gives the chance to the programmer to create RIA(rich internet applications) and 3D web videos or games all in only one program or being able to program the program in the program itself and so on...well it will be interesting to see what happens at the end when both programs are released...happy flashing...!

×
×
  • Create New...

Important Information

Terms of Use | Privacy Policy | Guidelines | We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.