Re: [Flashcoders] PRINTJOB HELL, PRINTJOB NIGHTMARE with several PAGES

2006-08-21 Thread Meinte van't Kruis

Very cool idea Haikal! Certainly seems the best option for text printing,
I'm going to try it one day.

thanks,
-Meinte

On 8/21/06, Haikal Saadh [EMAIL PROTECTED] wrote:


My approach to printing oodles of multiline text is to let the browser
do it:

* When the print button is pressed, save the contents of the text
  field to a Local Shared Object
* Open up an empty HTML page, which has as invisible flash movie
  which can then:
  o Read that shared object.
  o Pass the data that needs to be printed to a JS function
which...
  o ...uses DOM to inject that data onto the page.

Simple, and quite elegant, if I say so my self. I've done this before
for arrays of objects, and it has worked a treat. The Flash/Javascript
bridge comes in handy here as well.



Peter O'Brien wrote:
 I have the same problem as the original poster.

 I don't suppose anyone can provide more info as a solution than Hans, or
 Hans if you're there I would love to see some code.

 What are flash mc dimensions to match an A4 page?  Doesn't it vary
 according
 to screen resolution?

 How can you efficiently fill a textfield to the point in which you
 know it
 is completely full?

 Cheers,
 Pete



--
Haikal Saadh
Applications Programmer
ICT Resources, TALSS
QUT Kelvin Grove
___
Flashcoders@chattyfig.figleaf.com
To change your subscription options or search the archive:
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders

Brought to you by Fig Leaf Software
Premier Authorized Adobe Consulting and Training
http://www.figleaf.com
http://training.figleaf.com


___
Flashcoders@chattyfig.figleaf.com
To change your subscription options or search the archive:
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders

Brought to you by Fig Leaf Software
Premier Authorized Adobe Consulting and Training
http://www.figleaf.com
http://training.figleaf.com


Re: [Flashcoders] PRINTJOB HELL, PRINTJOB NIGHTMARE with several PAGES

2006-08-20 Thread Peter O'Brien

Hey guys thanks for the code and input.

The route I think I'm taking because it's html text and formatted, is to
keep trimming at br's and checking if page is not too high.

The page to print symbol I'm using has an aspect ratio for an A4 page (1:
1.414) and one big html text field (with 20px blank padding around it)

Here's the code (which works) so far:


private function processPagesToPrint():Void
   {
   _pagesToPrint=[];
   _excessText=entireHtmlFormattedTextContent;// can be a few lines or
pages
   constructPage();
   }

   private function constructPage():Void
   {
   var pageToPrint=this.attachMovie
('pageToPrint_justText','p'+(_pagesToPrint.length+1),getNextHighestDepth(),{_x:720});
   _pagesToPrint.push(pageToPrint);
   var tf:TextField=pageToPrint.tf;
   tf.styleSheet=STYLESHEET;
   tf.htmlText=_excessText;
   // if the page is not too high without having to trim we're good to
go
   if(tf.textHeight=tf._height){
   trace('pages processed, and number to print
='+_pagesToPrint.length);
   // display this info to user so they know before they hit print
   }
   // otherwise we'll trim and then construct another page
   else{
   _excessText=;
   trimPage(tf);
   }
   }

   private function trimPage(tf:TextField):Void
   {
   // cut the text after the last 'br'
   var str:String=tf.htmlText;
   var lastBr=str.lastIndexOf('br');
   tf.htmlText=str.substring(0,lastBr);
   _excessText=str.substring(lastBr,str.length)+_excessText;
   // if page is trimmed enough
   if(tf.textHeight=tf._height){
   constructPage();
   }
   // otherwise keep trimmin
   else{
   trimPage(tf);
   }
   }

   private function printPages():Void
   {
   _printJob=new PrintJob();
   if(_printJob.start()){
   var len=_pagesToPrint.length;
   for(var i=0;ilen;i++){
   _printJob.addPage(_pagesToPrint[i]);
   }
   _printJob.send();
   }
   }


On 8/18/06, Danny Kodicek [EMAIL PROTECTED] wrote:


 How can you efficiently fill a textfield to the point in which you know
it
 is completely full?

Here's a revised version using a word array. But as I said, including
formatting would be more difficult and significantly slower. I tend to
agree
with Meinte that in this case you're better off using scrolling (although
the function below may be of interest in any case)

function fillField(fld:TextField, txt:Array, curr:String) {
if (curr == undefined) {
curr = ;
}
var len:Number = txt.length;
if (len == 0) {
} else if (len == 1) {
fld.text = curr + txt[0];
if (fld.textHeight  fld._height) {
fld.text = curr;
}
} else {
var half:Array = txt.slice(0, len / 2);
fld.text = curr + half.join( );
if (fld.textHeight  fld._height) {
fillField(fld, half, curr);
} else {
fillField(fld, txt.slice(len / 2), fld.text + 
);
}
}
}

I tested it with
fillField(test, src.text.split( ));

Danny

___
Flashcoders@chattyfig.figleaf.com
To change your subscription options or search the archive:
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders

Brought to you by Fig Leaf Software
Premier Authorized Adobe Consulting and Training
http://www.figleaf.com
http://training.figleaf.com


___
Flashcoders@chattyfig.figleaf.com
To change your subscription options or search the archive:
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders

Brought to you by Fig Leaf Software
Premier Authorized Adobe Consulting and Training
http://www.figleaf.com
http://training.figleaf.com


Re: [Flashcoders] PRINTJOB HELL, PRINTJOB NIGHTMARE with several PAGES

2006-08-20 Thread Haikal Saadh

My approach to printing oodles of multiline text is to let the browser
do it:

   * When the print button is pressed, save the contents of the text
 field to a Local Shared Object
   * Open up an empty HTML page, which has as invisible flash movie
 which can then:
 o Read that shared object.
 o Pass the data that needs to be printed to a JS function which...
 o ...uses DOM to inject that data onto the page.

Simple, and quite elegant, if I say so my self. I've done this before
for arrays of objects, and it has worked a treat. The Flash/Javascript
bridge comes in handy here as well.



Peter O'Brien wrote:

I have the same problem as the original poster.

I don't suppose anyone can provide more info as a solution than Hans, or
Hans if you're there I would love to see some code.

What are flash mc dimensions to match an A4 page?  Doesn't it vary 
according

to screen resolution?

How can you efficiently fill a textfield to the point in which you 
know it

is completely full?

Cheers,
Pete




--
Haikal Saadh
Applications Programmer
ICT Resources, TALSS
QUT Kelvin Grove
___
Flashcoders@chattyfig.figleaf.com
To change your subscription options or search the archive:
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders

Brought to you by Fig Leaf Software
Premier Authorized Adobe Consulting and Training
http://www.figleaf.com
http://training.figleaf.com


Re: [Flashcoders] PRINTJOB HELL, PRINTJOB NIGHTMARE with several PAGES

2006-08-18 Thread Peter O'Brien

I have the same problem as the original poster.

I don't suppose anyone can provide more info as a solution than Hans, or
Hans if you're there I would love to see some code.

What are flash mc dimensions to match an A4 page?  Doesn't it vary according
to screen resolution?

How can you efficiently fill a textfield to the point in which you know it
is completely full?

Cheers,
Pete


On 4/24/06, Van De Velde Hans [EMAIL PROTECTED] wrote:


You get your text from the textarea and you do this:

Dynamically attach a movieclip from the library with a preformatted
textfield that exactly fits an A4 page (set movieclip to _visible = false
to
do it invisibly)
and fill the textfield up with the text from your textarea until the
textfield is full.

Then you add to movieclip to the printjob and push the reference to the
movieclip to an array.

Cut the remaining text and fill up the next one...
Create a loop of this to write out all your text.

After all text is written out, you execute the printjob and remove all
the movieclips with removeMovieClip by looping the array of movieclips.

NOTE : this is easier than it seems.


Been there, done that,

Regards,

Hans.




-Original Message-
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] On Behalf Of julian
atienza
Sent: maandag 24 april 2006 17:26
To: flashcoders@chattyfig.figleaf.com
Subject: [Flashcoders] PRINTJOB HELL, PRINTJOB NIGHTMARE with several
PAGES

Hi.
I wanted to Print contents of a long Scrollable textArea  with Flash, but
it's a kind of nightmare.

I tried to made a class to manage Printing (with a PrintJob object inside)
,
and one empty swf that Creates Dynamically the TextArea and the Class to
ManagePrinting, who feeds textArea with contents and scroll TextArea
adding
page by page contents.

Problems:

- The Scrolled area in Screen doesn't appeared to be the same than the
printable area (each Page, i see repeated contents... why? i just don't
know
. IT's like the scroll doesn't scroll propertly).

- Of course, sometimes, appeared incomplete text (with a cut at the
middle)
because i don't know any mechanism to avoid it at the moment.


Somebody have any idea - the contents to print will be sometimes of 5 or
6
pages DIN A-4

thanks in advance
___
Flashcoders@chattyfig.figleaf.com
To change your subscription options or search the archive:
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders

Brought to you by Fig Leaf Software
Premier Authorized Adobe Consulting and Training
http://www.figleaf.com
http://training.figleaf.com

___
Flashcoders@chattyfig.figleaf.com
To change your subscription options or search the archive:
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders

Brought to you by Fig Leaf Software
Premier Authorized Adobe Consulting and Training
http://www.figleaf.com
http://training.figleaf.com


___
Flashcoders@chattyfig.figleaf.com
To change your subscription options or search the archive:
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders

Brought to you by Fig Leaf Software
Premier Authorized Adobe Consulting and Training
http://www.figleaf.com
http://training.figleaf.com


Re: [Flashcoders] PRINTJOB HELL, PRINTJOB NIGHTMARE with several PAGES

2006-08-18 Thread hank williams

Yeah, I asked this question on Flexcoders but got no answer at all.
Any code would be greatly appreciated :)

The funny thing is this printing a block of multipage text seems like
such a basic thing but there are no examples in the docs and it seems
as thought this issue was never considered as a basic thing people
would need to do.

Regards,
Hank

On 8/18/06, Peter O'Brien [EMAIL PROTECTED] wrote:

I have the same problem as the original poster.

I don't suppose anyone can provide more info as a solution than Hans, or
Hans if you're there I would love to see some code.

What are flash mc dimensions to match an A4 page?  Doesn't it vary according
to screen resolution?

How can you efficiently fill a textfield to the point in which you know it
is completely full?

Cheers,
Pete


On 4/24/06, Van De Velde Hans [EMAIL PROTECTED] wrote:

 You get your text from the textarea and you do this:

 Dynamically attach a movieclip from the library with a preformatted
 textfield that exactly fits an A4 page (set movieclip to _visible = false
 to
 do it invisibly)
 and fill the textfield up with the text from your textarea until the
 textfield is full.

 Then you add to movieclip to the printjob and push the reference to the
 movieclip to an array.

 Cut the remaining text and fill up the next one...
 Create a loop of this to write out all your text.

 After all text is written out, you execute the printjob and remove all
 the movieclips with removeMovieClip by looping the array of movieclips.

 NOTE : this is easier than it seems.


 Been there, done that,

 Regards,

 Hans.




 -Original Message-
 From: [EMAIL PROTECTED]
 [mailto:[EMAIL PROTECTED] On Behalf Of julian
 atienza
 Sent: maandag 24 april 2006 17:26
 To: flashcoders@chattyfig.figleaf.com
 Subject: [Flashcoders] PRINTJOB HELL, PRINTJOB NIGHTMARE with several
 PAGES

 Hi.
 I wanted to Print contents of a long Scrollable textArea  with Flash, but
 it's a kind of nightmare.

 I tried to made a class to manage Printing (with a PrintJob object inside)
 ,
 and one empty swf that Creates Dynamically the TextArea and the Class to
 ManagePrinting, who feeds textArea with contents and scroll TextArea
 adding
 page by page contents.

 Problems:

 - The Scrolled area in Screen doesn't appeared to be the same than the
 printable area (each Page, i see repeated contents... why? i just don't
 know
 . IT's like the scroll doesn't scroll propertly).

 - Of course, sometimes, appeared incomplete text (with a cut at the
 middle)
 because i don't know any mechanism to avoid it at the moment.


 Somebody have any idea - the contents to print will be sometimes of 5 or
 6
 pages DIN A-4

 thanks in advance
 ___
 Flashcoders@chattyfig.figleaf.com
 To change your subscription options or search the archive:
 http://chattyfig.figleaf.com/mailman/listinfo/flashcoders

 Brought to you by Fig Leaf Software
 Premier Authorized Adobe Consulting and Training
 http://www.figleaf.com
 http://training.figleaf.com

 ___
 Flashcoders@chattyfig.figleaf.com
 To change your subscription options or search the archive:
 http://chattyfig.figleaf.com/mailman/listinfo/flashcoders

 Brought to you by Fig Leaf Software
 Premier Authorized Adobe Consulting and Training
 http://www.figleaf.com
 http://training.figleaf.com

___
Flashcoders@chattyfig.figleaf.com
To change your subscription options or search the archive:
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders

Brought to you by Fig Leaf Software
Premier Authorized Adobe Consulting and Training
http://www.figleaf.com
http://training.figleaf.com


___
Flashcoders@chattyfig.figleaf.com
To change your subscription options or search the archive:
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders

Brought to you by Fig Leaf Software
Premier Authorized Adobe Consulting and Training
http://www.figleaf.com
http://training.figleaf.com


Re: [Flashcoders] PRINTJOB HELL, PRINTJOB NIGHTMARE with several PAGES

2006-08-18 Thread Meinte van't Kruis

my solution is scrolling the text and printing as you go, here's the
function.
(beware though, it's been ages since writing this, it works tho)

function buildPrinter() {
   _root.print.onPress = function() {
   var p_length = Math.round(Math.floor
(parseInt(_root.test.maxscroll)/_root.line_length));
   _root.pj = new PrintJob();
   if (_root.pj.start()) {
   //_root.printer.pj=pj;
   for (var i = 0; i=p_length; i++) {
   _root.test.scroll = i*_root.line_length;
   _root.pj.addPage(_root.test);
   }
   var empty =
((p_length+1)*_root.line_length)-_root.test.maxscroll;
   for (var i = 0; iempty; i++) {
   _root.test.text = _root.test.text+\n;
   }
   _root.test.scroll = _root.test.maxscroll;
   _root.pj.addPage(_root.test);
   _root.pj.send();
   }
   delete _root.pj;
   };
}

On 8/18/06, hank williams [EMAIL PROTECTED] wrote:


Yeah, I asked this question on Flexcoders but got no answer at all.
Any code would be greatly appreciated :)

The funny thing is this printing a block of multipage text seems like
such a basic thing but there are no examples in the docs and it seems
as thought this issue was never considered as a basic thing people
would need to do.

Regards,
Hank

On 8/18/06, Peter O'Brien [EMAIL PROTECTED] wrote:
 I have the same problem as the original poster.

 I don't suppose anyone can provide more info as a solution than Hans, or
 Hans if you're there I would love to see some code.

 What are flash mc dimensions to match an A4 page?  Doesn't it vary
according
 to screen resolution?

 How can you efficiently fill a textfield to the point in which you know
it
 is completely full?

 Cheers,
 Pete


 On 4/24/06, Van De Velde Hans [EMAIL PROTECTED] wrote:
 
  You get your text from the textarea and you do this:
 
  Dynamically attach a movieclip from the library with a preformatted
  textfield that exactly fits an A4 page (set movieclip to _visible =
false
  to
  do it invisibly)
  and fill the textfield up with the text from your textarea until the
  textfield is full.
 
  Then you add to movieclip to the printjob and push the reference to
the
  movieclip to an array.
 
  Cut the remaining text and fill up the next one...
  Create a loop of this to write out all your text.
 
  After all text is written out, you execute the printjob and remove all
  the movieclips with removeMovieClip by looping the array of
movieclips.
 
  NOTE : this is easier than it seems.
 
 
  Been there, done that,
 
  Regards,
 
  Hans.
 
 
 
 
  -Original Message-
  From: [EMAIL PROTECTED]
  [mailto:[EMAIL PROTECTED] On Behalf Of julian
  atienza
  Sent: maandag 24 april 2006 17:26
  To: flashcoders@chattyfig.figleaf.com
  Subject: [Flashcoders] PRINTJOB HELL, PRINTJOB NIGHTMARE with several
  PAGES
 
  Hi.
  I wanted to Print contents of a long Scrollable textArea  with Flash,
but
  it's a kind of nightmare.
 
  I tried to made a class to manage Printing (with a PrintJob object
inside)
  ,
  and one empty swf that Creates Dynamically the TextArea and the Class
to
  ManagePrinting, who feeds textArea with contents and scroll TextArea
  adding
  page by page contents.
 
  Problems:
 
  - The Scrolled area in Screen doesn't appeared to be the same than the
  printable area (each Page, i see repeated contents... why? i just
don't
  know
  . IT's like the scroll doesn't scroll propertly).
 
  - Of course, sometimes, appeared incomplete text (with a cut at the
  middle)
  because i don't know any mechanism to avoid it at the moment.
 
 
  Somebody have any idea - the contents to print will be sometimes of 5
or
  6
  pages DIN A-4
 
  thanks in advance
  ___
  Flashcoders@chattyfig.figleaf.com
  To change your subscription options or search the archive:
  http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
 
  Brought to you by Fig Leaf Software
  Premier Authorized Adobe Consulting and Training
  http://www.figleaf.com
  http://training.figleaf.com
 
  ___
  Flashcoders@chattyfig.figleaf.com
  To change your subscription options or search the archive:
  http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
 
  Brought to you by Fig Leaf Software
  Premier Authorized Adobe Consulting and Training
  http://www.figleaf.com
  http://training.figleaf.com
 
 ___
 Flashcoders@chattyfig.figleaf.com
 To change your subscription options or search the archive:
 http://chattyfig.figleaf.com/mailman/listinfo/flashcoders

 Brought to you by Fig Leaf Software
 Premier Authorized Adobe Consulting and Training
 http://www.figleaf.com
 http://training.figleaf.com

___
Flashcoders@chattyfig.figleaf.com
To change your subscription options or search the archive:
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders

Brought 

Re: [Flashcoders] PRINTJOB HELL, PRINTJOB NIGHTMARE with several PAGES

2006-08-18 Thread Meinte van't Kruis

_root.test is the textfield, _root.line_length is the lines fitting on one
page.

good luck!

-Meinte

On 8/18/06, Meinte van't Kruis [EMAIL PROTECTED] wrote:


my solution is scrolling the text and printing as you go, here's the
function.
(beware though, it's been ages since writing this, it works tho)

function buildPrinter() {
_root.print.onPress = function() {
var p_length = Math.round(Math.floor
(parseInt(_root.test.maxscroll)/_root.line_length));
_root.pj = new PrintJob();
if (_root.pj.start()) {
//_root.printer.pj=pj;
for (var i = 0; i=p_length; i++) {
_root.test.scroll = i*_root.line_length;
_root.pj.addPage(_root.test);
}
var empty =
((p_length+1)*_root.line_length)-_root.test.maxscroll;
for (var i = 0; iempty; i++) {
_root.test.text = _root.test.text+\n;
}
_root.test.scroll = _root.test.maxscroll;
_root.pj.addPage(_root.test);
_root.pj.send();
}
delete _root.pj;
};

}

On 8/18/06, hank williams [EMAIL PROTECTED] wrote:

 Yeah, I asked this question on Flexcoders but got no answer at all.
 Any code would be greatly appreciated :)

 The funny thing is this printing a block of multipage text seems like
 such a basic thing but there are no examples in the docs and it seems
 as thought this issue was never considered as a basic thing people
 would need to do.

 Regards,
 Hank

 On 8/18/06, Peter O'Brien [EMAIL PROTECTED] wrote:
  I have the same problem as the original poster.
 
  I don't suppose anyone can provide more info as a solution than Hans,
 or
  Hans if you're there I would love to see some code.
 
  What are flash mc dimensions to match an A4 page?  Doesn't it vary
 according
  to screen resolution?
 
  How can you efficiently fill a textfield to the point in which you
 know it
  is completely full?
 
  Cheers,
  Pete
 
 
  On 4/24/06, Van De Velde Hans  [EMAIL PROTECTED] wrote:
  
   You get your text from the textarea and you do this:
  
   Dynamically attach a movieclip from the library with a preformatted
   textfield that exactly fits an A4 page (set movieclip to _visible =
 false
   to
   do it invisibly)
   and fill the textfield up with the text from your textarea until the
   textfield is full.
  
   Then you add to movieclip to the printjob and push the reference to
 the
   movieclip to an array.
  
   Cut the remaining text and fill up the next one...
   Create a loop of this to write out all your text.
  
   After all text is written out, you execute the printjob and remove
 all
   the movieclips with removeMovieClip by looping the array of
 movieclips.
  
   NOTE : this is easier than it seems.
  
  
   Been there, done that,
  
   Regards,
  
   Hans.
  
  
  
  
   -Original Message-
   From: [EMAIL PROTECTED]
   [mailto:[EMAIL PROTECTED] ] On Behalf Of
 julian
   atienza
   Sent: maandag 24 april 2006 17:26
   To: flashcoders@chattyfig.figleaf.com
   Subject: [Flashcoders] PRINTJOB HELL, PRINTJOB NIGHTMARE with
 several
   PAGES
  
   Hi.
   I wanted to Print contents of a long Scrollable textArea  with
 Flash, but
   it's a kind of nightmare.
  
   I tried to made a class to manage Printing (with a PrintJob object
 inside)
   ,
   and one empty swf that Creates Dynamically the TextArea and the
 Class to
   ManagePrinting, who feeds textArea with contents and scroll TextArea
   adding
   page by page contents.
  
   Problems:
  
   - The Scrolled area in Screen doesn't appeared to be the same than
 the
   printable area (each Page, i see repeated contents... why? i just
 don't
   know
   . IT's like the scroll doesn't scroll propertly).
  
   - Of course, sometimes, appeared incomplete text (with a cut at the
   middle)
   because i don't know any mechanism to avoid it at the moment.
  
  
   Somebody have any idea - the contents to print will be sometimes of
 5 or
   6
   pages DIN A-4
  
   thanks in advance
   ___
   Flashcoders@chattyfig.figleaf.com
   To change your subscription options or search the archive:
   http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
  
   Brought to you by Fig Leaf Software
   Premier Authorized Adobe Consulting and Training
   http://www.figleaf.com
   http://training.figleaf.com
  
   ___
   Flashcoders@chattyfig.figleaf.com
   To change your subscription options or search the archive:
   http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
  
   Brought to you by Fig Leaf Software
   Premier Authorized Adobe Consulting and Training
   http://www.figleaf.com
   http://training.figleaf.com
  
  ___
  Flashcoders@chattyfig.figleaf.com
  To change your subscription options or search the archive:
  http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
 
  Brought to you by Fig Leaf 

RE: [Flashcoders] PRINTJOB HELL, PRINTJOB NIGHTMARE with several PAGES

2006-08-18 Thread Danny Kodicek

 I have the same problem as the original poster.

 I don't suppose anyone can provide more info as a solution than Hans, or
 Hans if you're there I would love to see some code.

 What are flash mc dimensions to match an A4 page?  Doesn't it
 vary according
 to screen resolution?

As long as it's the right aspect ratio (1:1.414), it should scale up
correctly


 How can you efficiently fill a textfield to the point in which you know it
 is completely full?

It depends on how much you know about the contents. If you know the text is
all of a single line-height and not wrapping, then you can do it very
quickly. If you don't know any of these things then you have to do it by
trial and error (no equivalent in Flash of Director's lovely locToCharPos
function, unfortunately). A simple and quick recursive method is:

function fillField(fld:TextField, txt:String, curr:String) {
if (curr == undefined) {
curr = ;
}
var len:Number = txt.length;
if (len == 0) {
} else if (len == 1) {
fld.text = curr + txt;
if (fld.textHeight  fld._height) {
fld.text = curr;
}
} else {
var half:String = txt.substr(0, len / 2);   
fld.text = curr + half;
if (fld.textHeight  fld._height) {
fillField(fld, half, curr);
} else {
fillField(fld, txt.substr(len / 2), curr + half);
}
}
}


However, this literally fills the field as far as it will go, up to the very
last letter; and of course it doesn't respect formatting. The same principle
can be applied with formatting, but it gets more complicated. To make it
respect word breaks, it would probably be simplest to convert the text to an
array of words.

Danny

___
Flashcoders@chattyfig.figleaf.com
To change your subscription options or search the archive:
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders

Brought to you by Fig Leaf Software
Premier Authorized Adobe Consulting and Training
http://www.figleaf.com
http://training.figleaf.com


RE: [Flashcoders] PRINTJOB HELL, PRINTJOB NIGHTMARE with several PAGES

2006-08-18 Thread Danny Kodicek
 How can you efficiently fill a textfield to the point in which you know it
 is completely full?

Here's a revised version using a word array. But as I said, including
formatting would be more difficult and significantly slower. I tend to agree
with Meinte that in this case you're better off using scrolling (although
the function below may be of interest in any case)

function fillField(fld:TextField, txt:Array, curr:String) {
if (curr == undefined) {
curr = ;
}
var len:Number = txt.length;
if (len == 0) {
} else if (len == 1) {
fld.text = curr + txt[0];
if (fld.textHeight  fld._height) {
fld.text = curr;
}
} else {
var half:Array = txt.slice(0, len / 2);
fld.text = curr + half.join( );
if (fld.textHeight  fld._height) {
fillField(fld, half, curr);
} else {
fillField(fld, txt.slice(len / 2), fld.text +  );
}
}
}

I tested it with
fillField(test, src.text.split( ));

Danny

___
Flashcoders@chattyfig.figleaf.com
To change your subscription options or search the archive:
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders

Brought to you by Fig Leaf Software
Premier Authorized Adobe Consulting and Training
http://www.figleaf.com
http://training.figleaf.com


RE: [Flashcoders] PRINTJOB HELL, PRINTJOB NIGHTMARE with several PAGES

2006-04-24 Thread Van De Velde Hans
You get your text from the textarea and you do this:

Dynamically attach a movieclip from the library with a preformatted
textfield that exactly fits an A4 page (set movieclip to _visible = false to
do it invisibly)
and fill the textfield up with the text from your textarea until the
textfield is full.

Then you add to movieclip to the printjob and push the reference to the
movieclip to an array. 

Cut the remaining text and fill up the next one...
Create a loop of this to write out all your text.

After all text is written out, you execute the printjob and remove all 
the movieclips with removeMovieClip by looping the array of movieclips.

NOTE : this is easier than it seems.


Been there, done that,

Regards,

Hans.




-Original Message-
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] On Behalf Of julian
atienza
Sent: maandag 24 april 2006 17:26
To: flashcoders@chattyfig.figleaf.com
Subject: [Flashcoders] PRINTJOB HELL, PRINTJOB NIGHTMARE with several PAGES

Hi.
I wanted to Print contents of a long Scrollable textArea  with Flash, but
it's a kind of nightmare.

I tried to made a class to manage Printing (with a PrintJob object inside) ,
and one empty swf that Creates Dynamically the TextArea and the Class to
ManagePrinting, who feeds textArea with contents and scroll TextArea adding
page by page contents.

Problems:

- The Scrolled area in Screen doesn't appeared to be the same than the
printable area (each Page, i see repeated contents... why? i just don't know
. IT's like the scroll doesn't scroll propertly).

- Of course, sometimes, appeared incomplete text (with a cut at the middle)
because i don't know any mechanism to avoid it at the moment.


Somebody have any idea - the contents to print will be sometimes of 5 or 6
pages DIN A-4

thanks in advance
___
Flashcoders@chattyfig.figleaf.com
To change your subscription options or search the archive:
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders

Brought to you by Fig Leaf Software
Premier Authorized Adobe Consulting and Training
http://www.figleaf.com
http://training.figleaf.com

___
Flashcoders@chattyfig.figleaf.com
To change your subscription options or search the archive:
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders

Brought to you by Fig Leaf Software
Premier Authorized Adobe Consulting and Training
http://www.figleaf.com
http://training.figleaf.com