A Flash Developer Resource Site

Results 1 to 6 of 6

Thread: Printing a dynamic textField

  1. #1
    Junior Member
    Join Date
    May 2008
    Posts
    19

    Question Printing a dynamic textField

    I have a dynamic text field with a UIScrollbar. I am have problems with printing the content of the textField. If I set the print function to print the textField I get the following error -

    TypeError: Error #1034: Type Coercion failed: cannot convert flash.text:


    Any help would be welcome

  2. #2
    Senior Member cancerinform's Avatar
    Join Date
    Mar 2002
    Location
    press the picture...
    Posts
    13,449
    What is your code for typing the textfield content?
    - The right of the People to create Flash movies shall not be infringed. -

  3. #3
    Junior Member
    Join Date
    May 2008
    Posts
    19
    tf is the textfield which is within a movieclip named tfmc.

    Code:
    function BasicPrintExample() : void {
    		//var textPrint = tfmc.tf.text;
                    var myPrintJob:PrintJob = new PrintJob();
                    myPrintJob.start();
                    myPrintJob.addPage(tfmc.tf);
                    myPrintJob.send();
                }

  4. #4
    Junior Member
    Join Date
    May 2008
    Posts
    19
    Ok I have overcome the text printing issue by placing the textfield within a sprite (movieclip) and printing the sprite instead of the textfield.

    Now if the text is too long to fit on one page I would like to print multiple pages. Similar to a word processor. Can I use pageHeight to determine if the printjob should continue onto another page?

    Thanks

  5. #5
    Senior Member cancerinform's Avatar
    Join Date
    Mar 2002
    Location
    press the picture...
    Posts
    13,449
    You can use textheight and textfield height to calculate the amount of text fitting on one page and then compare with paperHeight.

    Then all you do is have as many PrintJob.addPage() as you need to cover the whole text.
    PrintJob.start();
    PrintJob.addPage();
    PrintJob.addPage();
    PrintJob.send();
    Last edited by cancerinform; 10-27-2008 at 11:27 AM.
    - The right of the People to create Flash movies shall not be infringed. -

  6. #6
    Junior Member
    Join Date
    May 2008
    Posts
    19
    Yeah, that's what I'm trying right now using textHeight to determine what text needs to go on a new addpage. Hopefully it should work. Thanks.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  




Click Here to Expand Forum to Full Width

HTML5 Development Center