Filling content in dynamic MCs


Here is attahcing my FLA file. I want to print multiple records which are stored in an Array Object. In the attahced sample file:

  • I have a MC where i am creating 2 dynamic textfields at run time.
  • On the stage I have function duplicatePages() which actually creates 2 (MC) pages with diff records and supposed to print the same. But i am getting 2 blank pages printed.

But stange thing is when Instead of creating 2 dynamic textFields inside MC, if i keep directly in it then my print works fine. But thats not my solution. Because I do not the no. of TextField I need to have initially. Its just for simplicty, I am executing this way.

Can anyone help me!!!


I noticed several things that were causing the printing problem.

  1. You are exporting to Flash Player 6. You cannot use a Flash Player 7 feature if you export to an older version, even if the content is playing in the newer player. I changed it to export to flash player 7 AS1.
  2. Now the reason why you are not able to print, lies in one of flash’s many quirks. A movieclip once attached does not initialize right away, it required atleast one frame to do so. Which is why the initObject is provided. However in your case you have code inside the “com” movieclip symbol that creates the dynamic textfields. This code will execute after the movieclip has initialized. Now coupled with the fact that the PrintJob class is synchronous, this code will only execute After the Print dialog has been closed. So essentially the PrintJob is printing an empty page because at the time
    that you add the page to the print spool, the page movieclip is empty since it hasn’t initialized yet.
  3. One solution to get around this is to wait one frame to let the pages initialize, and then print them. Replace the code on layer 5 with the one below.

list = [
	["Ashish", "1"], 
	["Mahesh", "2"], 
	["Ganesh", "3"], 
	["Manish", "4"], 
	["Vishal", "5"], 
	["Pankaj", "6"]

var iPages = list.length; // assuming you really want more than 2 pages.

function duplicatePages() {
	for (i=0; i<iPages; i++) {
		main.attachMovie("com", "prints"+i, i);

	invalidate ("populatePages");

// simple form of calling a function a frame later.
function invalidate (sFunc) {
	this.onEnterFrame = function () {
		this [sFunc] ();
		delete this.onEnterFrame;

function populatePages () {
	var k, myPage;
	for (var i = 0; i < iPages; ++i) {
		myPage = main ["prints"+i];

		k = 1;
		while (k<3) {
			myPage["myText"+k].htmlText = list*[k-1];

	printPages ();

function printPages () {
	var my_pj = new PrintJob ();
	if (my_pj.start ()) {
		for (var i = 0; i < iPages; ++i) {
			my_pj.addPage (main ["prints" + i]);

		my_pj.send ();
		delete my_pj;

Hey arcaRox,

Thanks alot, thats just worked perfectly the way i wanted. Its being last 2 months I was putting the similar kind of problem in all forums but couldnt get the solution. Actually I need some more help from you or any suggession.
Here is attaching the .fla file (MX 2004) for ur reference with XML File.

Here i am getting data from an XML File. I am loading my XML file inside the MC in Library and creating dynaimc textFIeld to display. On stage i am attaching this MC, the way i did in that sample File. But I dont what to in this case to get my all records printed page by page.

Please if this is done…then there is nothing like it…Pls help

Thanx and Regards
Ashish :slight_smile:

Any Expert Please !!! :frowning:

Sorry for the late reply. I have been really swamped by work for the last few days. I will post a solution in a day or so…