A Flash Developer Resource Site

Results 1 to 11 of 11

Thread: loading swfs to different levels

  1. #1
    Junior Member
    Join Date
    May 2004
    Location
    Philadelphia, PA
    Posts
    24

    loading swfs to different levels

    OK, this one should be pretty simple, but I'm having a heck of a time making it work. I am trying to load a movie(.swf) inside of another movie. I'm running MX2004 if that helps.

    The "main" movie is to act as a container for the other. No matter what I do , I can't seem to load the other swf into the container. Instead it loads it on top of the other movie (at 0,0), and when stepping through the code they both show up on _level0.

    I've never done this before, and I've tried everything.

    Here's the code on the first frame of the container the "main":

    this.createEmptyMovieClip("mcView",this.getNextHig hestDepth());
    mcView.loadMovie("SSPortalView.swf");
    mcView.onLoadComplete = function(){
    setPosition();
    }

    setPosition() is a function that just sets the _x, and _y for the mcView clip.

    Thanks in advance for any input, it is appreciated.

  2. #2
    Senior Mender trionik's Avatar
    Join Date
    Nov 2000
    Location
    Montréal,Canada
    Posts
    1,077
    var myLoader = new MovieClipLoader ();
    myLoader.__main = this;
    myLoader.onLoadComplete = function ()
    {
    this.__main.setPosition();

    };
    myLoader.onLoadError = function (object, error)
    {

    };
    this.createEmptyMovieClip("mcView",this.getNextHig hestDepth());
    myLoader.loadClip (_global.main.myUrl, this.mcView);

  3. #3
    Senior Mender trionik's Avatar
    Join Date
    Nov 2000
    Location
    Montréal,Canada
    Posts
    1,077
    oups \

    var myLoader = new MovieClipLoader ();
    myLoader.__main = this;
    myLoader.onLoadComplete = function ()
    {
    this.__main.setPosition();

    };
    myLoader.onLoadError = function (object, error)
    {

    };
    this.createEmptyMovieClip("mcView",this.getNextHig hestDepth());
    myLoader.loadClip ("SSPortalView.swf", this.mcView);

  4. #4
    Junior Member
    Join Date
    May 2004
    Location
    Philadelphia, PA
    Posts
    24

    quick question about the use of __main

    Thanks for the help, but still no luck with it.

    The debugger still shows the mcView as being on _level0, and the movie is still being loaded in place of the container.

    The container clip is the _root itself, so it has no instance name assigned to it. I'm just not familiar with the use of the (__main) in your code, so I'm probably just missing something. I've tried to look it up, but I can't find anything on it anywhere as related to the movieClipLoader class.


    The setPosition() function is on the _root of the container (actually it's an external .as file).

    I appreciate you taking the time. Any help is appreciated

  5. #5
    Senior Mender trionik's Avatar
    Join Date
    Nov 2000
    Location
    Montréal,Canada
    Posts
    1,077
    var myLoader = new MovieClipLoader ();
    myLoader.__main = this;
    myLoader.onLoadComplete = function ()
    {
    this.__main.setPosition();

    };
    myLoader.onLoadError = function (object, error)
    {

    };
    this.createEmptyMovieClip("mcView",2);
    myLoader.loadClip ("SSPortalView.swf", this.mcView);

    //
    Now mcView should be on level 2 i dont see any reason why it should not work maybe you should send me your file..

    The __main is just a referer to my main movie i always declare a __main in object or movieClip so that i have a direct link to my main movie and dont have to use _parent or _parent._parent etc to acces it.

  6. #6
    Junior Member
    Join Date
    May 2004
    Location
    Philadelphia, PA
    Posts
    24
    Hey, trionik,

    I'll send you both files the .fla for the container, and also the .swf for the "mcView" load.

    Nothing is really functional, but the login button on the swf (no data for the combo box yet). You'll see I also commented out a bunch of code that you needn't be bothered with (it's just populating

    I'm more of a designer than a coder, and I really hate to keep bugging you. But I do appreciate it . The zip file contains the both files.

    Thanks again for all your help, I do appreciate it. Here it is
    Attached Files Attached Files

  7. #7
    Senior Mender trionik's Avatar
    Join Date
    Nov 2000
    Location
    Montréal,Canada
    Posts
    1,077
    its working great here... I dont understand what else than loading your swf you want .. but i took your file hit ctrl-enter and it work.

  8. #8
    Junior Member
    Join Date
    May 2004
    Location
    Philadelphia, PA
    Posts
    24

    maybe I didn't explain it quite right

    Sorry, maybe I just didn't explain what it is that I want to happen. I want the swf file i sent to be loaded on to level 1 of the .fla file (which is to be the _root or the container).

    when the swf loads I want the _y to be offset by 35 pixels, which is the height of the (only symbol) in the .fla file.

    The .fla and the .swf are not the same. I was trying to load the .swf I sent IN to the .fla.

    Sorry about the confusion. When I run it here, the swf replaces the _root, rather than sitting on top of it 35 pixels down from (0,0).

    It just loads it on top of the other. The Login should screen should have a "customerName" and "Site Description" header on it (which is actually sitting on the _root timeline, under the login screen.

    Sorry (again-thanks for your patience).

  9. #9
    Senior Mender trionik's Avatar
    Join Date
    Nov 2000
    Location
    Montréal,Canada
    Posts
    1,077
    i think that it load in the mcView its just that you called setPosition instead of setViewPosition.

    Anyway here is your file

  10. #10
    Junior Member
    Join Date
    May 2004
    Location
    Philadelphia, PA
    Posts
    24

    I'm an idiot

    Thanks so much for your help,

    I can't believe I did that. Anyway, I do appreciate your help. It works exactly like it should, I was just wasn't calling the right function.

    But while I sit here feeling like an idiot, I figured I'd ask you one more question, though I'll try not to be so stupid this time. If I'm debugging, should I expect to see _level1 anywhere in the debug window if I list the variables?

    The movie is loading exactly the way I want it to, but if I want to reference variables in the 'container' from inside the loaded swf (mcView), do I now have to use _parent, __main or _level0?

    If I'm becoming an annoyance, just reply "Yes you are an idiot."

    I'd like to return the favor, so if you need any design work done, let me know. Thanks again, you've been a HUGE help.

  11. #11
    Senior Mender trionik's Avatar
    Join Date
    Nov 2000
    Location
    Montréal,Canada
    Posts
    1,077
    you can use _parent if you want. But you can also set a __main referer wich i always do.

    like

    this.mcView.__main = this;

    There for this.__main in mcView will refer to is parent.

    If you dont understand just use this._parent

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