[thelist] Flash MX Objects and XML class
Christopher Joseph
christopher at ideadesigners.com
Thu Feb 19 07:41:48 CST 2004
In case anyone was interested the problem was caused because '
this.oXMLDoc.onLoad = this.handleLoad;' results in the 'this' of
handleLoad becoming the oXMLDoc object. If this wasn't inside a class
definition I could have referenced process() via 'this._parent.process;'
through an anonymous function as follows. Beats me how it all works
though...
aquireLoadSequence = function () {
this.oXMLDoc = new XML();
this.oXMLDoc.onLoad = function () { this._parent.process; };
this.oXMLDoc.load(this.sLoadSequence);
};
Christopher Joseph wrote:
> Hi list,
>
> Can anyone see why process() doesn't get called from handleLoad() and
> trace(this.sLoadSequence); in handleLoad() is undefined?
>
> //The complete trace output follows and I can see in debug that the
> function process() is ignored even when the line that calls it is
> processed:
> ---------------------------------
> com.qlod.LoaderClass.as loaded
> com.qlod.LoaderClass: Defining global com object
> com.qlod.LoaderClass: Defining global com.qlod object
> com.ideadesigners.LoadSequence.as loaded
> com.ideadesigners.LoadSequence: Defining global com.ideadesigners object
> com.qlod.LoaderClass: using ASBroadcaster
> xml/sequence.xml
> undefined
> after process.
> ----------------------------------
>
> //My flash movie has this in the first frame:
> -----------------------------------
> stop();
> #include "com.qlod.LoaderClass.as"
> #include "com.ideadesigners.LoadSequence.as"
> var sXMLSequenceFile = "xml/sequence.xml";
> // show 10 mins steps at least
> myLoader = new com.qlod.LoaderClass();
> myLoader.setMinSteps(10);
> mySequencer = new com.ideadesigners.LoadSequence(sXMLSequenceFile,
> MyLoader);
> mySequencer.aquireLoadSequence();
> -----------------------------------
> //My partially coded "com.ideadesigners.LoadSequence.as" is:
> -----------------------------------
> trace("com.ideadesigners.LoadSequence.as loaded");
> /**
> * @class LoadSequence
> *
> * Version 1.0
> * Date 2004/02/18
> * Author Chris Joseph (christopher at ideadesigners.com)
> *
> */
> if( typeof(_global.com) != 'object'){
> trace("com.ideadesigners.LoadSequence: Defining global com object");
> _global.com = new Object();
> }
> if( typeof(com.ideadesigners) != 'object'){
> trace("com.ideadesigners.LoadSequence: Defining global
> com.ideadesigners object");
> com.ideadesigners = new Object();
> }
> o = com.ideadesigners.LoadSequence = function( psXMLSequence, poLoader,
> psAlternateStart ){
> if( arguments[0] == 'NO_INIT') return;
> this.aLoadSequence = [];
> this.sStart = "";
> this.setSequenceSource( psXMLSequence );
> this.setLoaderObject( poLoader );
> this.setStartPoint( psAlternateStart );
> };
> //
> // Statics
> o.DEFAULT_TIMEOUT_MS = 10 * 1000;
> o.DEFAULT_INTERVAL_MS = 100;
> o.DEFAULT_MIN_STEPS = 1;
>
> // Prototypes
> o = o.prototype;
> o.setLoaderObject = function( poLoader ) {
> this.oLoader = poLoader;
> this.oLoader.addListener( this );
> };
> o.setSequenceSource = function ( psXMLSequence ) {
> this.sLoadSequence = psXMLSequence;
> };
> o.setStartPoint= function ( psAlternateStart ) {
> this.sStart = psAlternateStart;
> };
> o.onTimeout = function( poLoader ){
> trace("Timeout-Error: The file " + poLoader.getUrl() + " could not be
> loaded.");
> };
> o.onLoadStart = function( poLoader){
> trace("Loading of " + poLoader.getTarget() + " has started");
> };
> o.onLoadProgress = function( poLoader ){
> trace("Percentage: " + poLoader.getPercent());
> };
> o.onLoadComplete = function( bSuccess, poLoader){
> trace("Loading of " + poLoader.getTarget() + " is completed");
> };
> o.aquireLoadSequence = function () {
> this.oXMLDoc = new XML();
> this.oXMLDoc.onLoad = this.handleLoad;
> trace(this.sLoadSequence);
> this.oXMLDoc.load(this.sLoadSequence);
> };
> o.handleLoad = function (bSuccess){
> if(bSuccess){
> trace(this.sLoadSequence);
> this.process();
> trace(this.sLoadSequence + " after process.");
> } else {
> trace(this.sLoadSequence + " did not load.");
> }
> };
> o.process = function () {
> this.oXMLDoc.ignoreWhite = true;
> trace(this.oXMLDoc.ignoreWhite);
> trace("latest");
> };
>
> delete o;
> -----------------------------------
> thanks.
--
Christopher Joseph
-------------------
[Internet]
http://www.ideadesigners.com [iseries & web technologies]
mailto: christopher at ideadesigners.com
[Telephone]
mobile: +44 7966 003860
Office: +44 1494 731814 ext. 832
Direct: +44 1494 731832
[Instant Message]
ICQ: 78019724
YIM = Josephc_98
MSN = christopher at ideadesigners.com
More information about the thelist
mailing list