dcsimg
A Flash Developer Resource Site

Results 1 to 1 of 1

Thread: [F8] passing variables to dynamicly loaded swf.(urgent)

Threaded View

  1. #1
    Junior Member
    Join Date
    Oct 2006
    Posts
    19

    [F8] passing variables to dynamicly loaded swf.(urgent)

    Hi,

    have a problem passing variables (from text file) to a dynamicly loaded swf.

    what i do is.

    preload the swf. using adListener (works) on "loadInit" (as flash help says) i invoke a text preloader (works also) ... but; however the textpreloader says that the text is loaded .. no text is shown in the textfield from the loaded swf.


    Code:
    this.m_menu_array[i].onRelease = function() {
    var _myLV:LoadVars = new LoadVars();
    var mclListener:Object = new Object();
    
    _root.createEmptyMovieClip("progressBar_mc", _root.getNextHighestDepth);
    _root.progressBar_mc.createEmptyMovieClip("bar_mc", _root.progressBar_mc.getNextHighestDepth);
    _root.progressBar_mc.createEmptyMovieClip("stroke_mc", _root.Bar_mc.getNextHighestDepth);
    //use drawing methods to create a progress bar
    with (_root.progressBar_mc.stroke_mc) {
    lineStyle(0, 0x000000);
    moveTo(0, 0);
    lineTo(100, 0);
    lineTo(100, 10);
    lineTo(0, 10);
    lineTo(0, 0);
    }
    with (_root.progressBar_mc.bar_mc) {
    beginFill(0xFF0000, 100);
    moveTo(0, 0);
    lineTo(100, 0);
    lineTo(100, 10);
    lineTo(0, 10);
    lineTo(0, 0);
    endFill();
    _xscale = 0;
    }
    _root.progressBar_mc._x = 45;
    _root.progressBar_mc._y = 435;
    
    // load progress
    mclListener.onLoadStart = function(SwfLoader_CLP:MovieClip) {
    _root.progressBar_mc.bar_mc._xscale = 0;
    };
    mclListener.onLoadProgress = function(SwfLoader_CLP:MovieClip, bytesLoaded:Number, bytesTotal:Number) {
    _root.progressBar_mc.bar_mc._xscale = Math.round(bytesLoaded/bytesTotal*100);
    };
    mclListener.onLoadComplete = function(SwfLoader_CLP:MovieClip) {
    _root.progressBar_mc.removeMovieClip();
    };
    mclListener.onLoadInit = function(SwfLoader_CLP:MovieClip):Void  {
    // creating text preloader
    var barWidth:Number = 75;
    var barHeight:Number = 6;
    
    _root.createEmptyMovieClip("pBar_mc", 9999);
    var bar:MovieClip = _root.pBar_mc.createEmptyMovieClip("bar_mc", 10);
    _root.bar.beginFill(0xFF0000, 100);
    _root.bar.moveTo(0, 0);
    _root.bar.lineTo(barWidth, 0);
    _root.bar.lineTo(barWidth, barHeight);
    _root.bar.lineTo(0, barHeight);
    _root.bar.lineTo(0, 0);
    _root.bar.endFill();
    _root.bar._xscale = 0;
    
    var stroke:MovieClip = _root.pBar_mc.createEmptyMovieClip("stroke_mc", 20);
    _root.stroke.lineStyle(0, 0x000000);
    _root.stroke.moveTo(0, 0);
    _root.stroke.lineTo(barWidth, 0);
    _root.stroke.lineTo(barWidth, barHeight);
    _root.stroke.lineTo(0, barHeight);
    _root.stroke.lineTo(0, 0);
    
    _root.pBar_mc.createTextField("label_txt", 30, 0, barHeight, 100, 21);
    _root.pBar_mc.label_txt.autoSize = "left";
    _root.pBar_mc.label_txt.selectable = false;
    
    _root.pBar_mc._x = 45;
    _root.pBar_mc._y = 435;
    					
    _myLV.onData = onText;
    function onText(src:String):Void {
    if (src != undefined) {
    _root.SwfLoader_CLP.Content_txt.htmlText = src;
    } else {
    _root.SwfLoader_CLP.Content_txt.htmlText = "No data loaded!";
    }
    };
    _root.pBar_mc.onEnterFrame = function() {
    var pctLoaded:Number = Math.floor(_myLV.getBytesLoaded() / _myLV.getBytesTotal() * 100);
    if (!isNaN(pctLoaded)) {
    _root.pBar_mc.bar_mc._xscale = pctLoaded;
    _root.pBar_mc.label_txt.text = pctLoaded + "% loaded";
    if (pctLoaded >= 100) {
    _root.pBar_mc.onEnterFrame = undefined;
    }
    }
    };
    };
    _myLV.load(this.data.Ctext);
    var mcLoader:MovieClipLoader = new MovieClipLoader();
    mcLoader.addListener(mclListener);
    mcLoader.loadClip(this.data.Clink, _root.SwfLoader_CLP);
    };


    please anyone ... im stuck on this issue for 2 weeks now and my deadline starts bugging me!!!!
    Last edited by 476producties; 11-21-2006 at 07:10 AM.

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