loading files via XML

Publishing Flash documents by embedding them in Flash movies
Post Reply
calbertazzi
Posts: 6
Joined: Wed Oct 06, 2010 3:03 am

loading files via XML

Post by calbertazzi » Wed Oct 06, 2010 3:12 am

Sorry, I'm really poor in AS3 programming. I need to load different P2F documents through a menu driven by an external XML document.
If I well understood from another post, I have to use this AS3 class found in SDK:

Code: Select all

import Print2Flash.*;

var P2FDoc            : Print2FlashDoc;
   P2FDoc            = new Print2FlashDoc( "sample.swf", 0, 0, 1180, 850, this);
How can I change "sample swf" with the various documents driven by XML? Thanks.

calbertazzi
Posts: 6
Joined: Wed Oct 06, 2010 3:03 am

Re: loading files via XML

Post by calbertazzi » Wed Oct 06, 2010 12:22 pm

I'm here again.
Looking to other posts, I found the AS2 example "loader.zip" where two swf files are loaded inside a master swf pressing two buttons.
This is the code in frame 1:

Code: Select all

var doc="swf1.swf"

function LoadPrint2FlashDoc(
    url, // Path of Print2Flash document to load
    x, // x coordinate of the Print2Flash document movie
    y, // y coordinate of the Print2Flash document movie
    width, // Width of Print2Flash document movie
    height, // Height of Print2Flash document movie
    name, // Instance name to assign the Print2Flash document movie
    parent, // Optional: parent object of Print2Flash document movie (default is _root)
    eventSink) // Optional: event handler object
{
    var intervalID = 0;
    if (!parent) parent=_root
    var container:MovieClip = parent.createEmptyMovieClip(name, 10);
    container._x=x;container._y=y

    var loadFunc = function()
    {
       if (!container.setSize) return;
       container.init(width, height);
       clearInterval(intervalID);
       eventSink.onLoaded(container);
       container.addListener(eventSink);
    }
   
    intervalID = setInterval(loadFunc, 100);
    var mcLoader:MovieClipLoader = new MovieClipLoader();
    mcLoader.addListener(this)
    mcLoader.loadClip(url, container);
    return container;
}
And this is the code for the button action:

Code: Select all

on (release) {
    _level0.LoadPrint2FlashDoc(_root.doc,20,20,800,800, "MyDoc",_root);
}
If I change the swf name to be opened in frame 1 code with one of mine it works perfectly and I easily customize the size and the position of teh loaded swf. It is perfect for my intended use. What I need now is understanding how can I load files with this method using an external XML instead than with the buttons. Any help?

Post Reply