A Flash Developer Resource Site

Results 1 to 3 of 3

Thread: Sending vars between swfs - External Interface?

  1. #1
    Senior Member
    Join Date
    Oct 2004
    Location
    London
    Posts
    186

    Sending vars between swfs - External Interface?

    Hi, as always I appreciate suggestions.

    On my html page I have two frames, one for navigation and the other for content. The navigation menu is an swf. Most of the content is html, except for the 'gallery' page.

    The thumbnails for the gallery appear within the navigation. I can get the pictures to load from the thumbnails into the 'content' frame using LoadVars sendAndLoad.

    However, doing this means that the flash gallery refreshes itself each time a thumbnail is clicked (thereby losing the transition effect).

    So, how do I load the images in the other frame without reloading the flash??

    Could I do it using external interface? ...it seems confusing.

  2. #2
    Senior Member
    Join Date
    Aug 2000
    Location
    Montréal
    Posts
    14,141
    No. Use Local Connection.
    external interface is for calling javascript.

    gparis

  3. #3
    Senior Member
    Join Date
    Oct 2004
    Location
    London
    Posts
    186
    That's great! - Exactly what I need!
    ...and I never heard of it before!
    Thank you! ...so simple.

    One thing though, somehow my transition still doesn't happen.

    Here is the code:

    Sending swf:
    Actionscript Code:
    mc.onMouseDown = function() {
       if (this.hitTest(_xmouse,_ymouse,true)) {
        val = this._parent._name.substr(7,2);
        var sending_lc:LocalConnection = new LocalConnection();
        sending_lc.send("lc_vars","getVars",_global.cID,val);
       }
    }

    Receiving swf:
    Actionscript Code:
    var lc_receiver:LocalConnection = new LocalConnection();
    lc_receiver.getVars = function(param1:Number,param2:Number) {
        loc = param1;
        num = param2;
        //_root.querystring.text = "var 1 = "+param1+" and var 2 = "+param2;
        if (num != undefined) {
            tmp1 = loader.createEmptyMovieClip("tmp1",1);
            tmp2 = loader.createEmptyMovieClip("tmp2",2);
            levs = 2;
            imgLoader.loadClip(path+loc+"/"+num+".jpg",_root["loader"]["tmp2"]);
        } else {
            _root.querystring.text = "Error loading file";
        }
    };

    lc_receiver.connect("lc_vars");

    imgLoaderListener.onLoadInit = function(mc:MovieClip) {
        centX = Stage.width/2;
        mc._x = centX - (mc._width/2);
        //mc._x = (diffX - mc._width/2);
        frame = _root.attachMovie("frame","frame",-10,{_x:0,_y:0});
        frame._width = mc._width + 30;
        frame._height = mc._height + 40;
        frame._x = mc._x - 15;
        frame._y = mc._y;
        id2 = _root["loader"].getInstanceAtDepth(levs);
        photo_msk = _root.attachMovie("photo_msk","photo_msk",100);
        photo_msk._width = mc._width;
        photo_msk._height = mc._height;
        photo_msk._x = mc._x;
        photo_msk._y = mc._y;
        _root["loader"].setMask(photo_msk);
        if (id2 != mc) {
            mc._alpha = 0;
            mc.swapDepths(id2);
            id2.swapDepths(levs-1);
            fadeIn(mc);
        }
        img_desc._x = mc._x;
        img_desc._y = mc._y + mc._height;
        desc.load(path+loc+"/descriptions.txt");
    };

    I don't think the onLoadInit function is happening at all? The pictures are loading fine, but no transition.

    (This isn't all the code, just the bits affected. The code and transitions work when the variables are sent via php and flashvars...)

    Any suggestions?

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