A Flash Developer Resource Site

Results 1 to 9 of 9

Thread: Passing Movie Clip to New Movie Clip via Function

  1. #1
    Member
    Join Date
    Mar 2006
    Posts
    43

    Passing Movie Clip to New Movie Clip via Function

    Ok here is the situation, I have my main scene and inside the scene I have a movie clip called "display_area". I already have a movie clip loaded into my main scene named "test".

    The display_area clip has a function exactly like the one below:
    this.LoadClipForDisplay= function(nClip:MovieClip):Void
    {
    // NEED HELP HERE
    };

    I am calling this function like this:
    display_area.LoadClipForDisplay(test);

    Now I can access everything I need to know via the nClip variable (such as size, position, etc...) but what I need to do is in this function is add the movieclip that is being passed in nClip into this "display_area" movieclip. So basically when I call display_area.LoadClipForDisplay(test); I will end up with the test movieclip being displayed at 1,1 of the display_area clip.

  2. #2
    Member
    Join Date
    Mar 2006
    Posts
    43
    Also, a work around method could work... still the ideal solution would be exactly as described above.

  3. #3
    Registered User nunomira's Avatar
    Join Date
    May 2002
    Location
    portugal
    Posts
    7,003
    Hi,

    Do you want to attach the movie clip "test" inside "display_area" and place it at (x, y)=(1, 1)?

    You need to export the movie clip for ActionScript, with an identifier, e.g. test_mc and use code like this:
    code:

    this.attachMovie("test_mc", "new_mc", 1, {_x:1, _y:1});


  4. #4
    Member
    Join Date
    Mar 2006
    Posts
    43
    yes that is very simular to what I need to do... except I need to do that using the nClip variable being passed into the function, since this is a movie clip I am dynamically loading into the movie I do not have it registered in my library to be used with action script. So what I am doing is loading it, passing it to the other clips LoadClipForDisplay and from that clip using the nClip to attach that movie clip

  5. #5
    Registered User nunomira's Avatar
    Join Date
    May 2002
    Location
    portugal
    Posts
    7,003
    So, the external movie has already been loaded... Inside a movie clip test? And you just want to move it?
    code:

    this.LoadClipForDisplay= function(nClip:MovieClip):Void
    {
    nClip._x = 1;
    nClip._y = 1;
    };
    display_area.LoadClipForDisplay(test);


    I find it very confusing... Can you explain again what you want?

  6. #6
    Member
    Join Date
    Mar 2006
    Posts
    43
    ok here is basically the situation it will be used in.

    You have a bunch of movie clips loaded into your main scene in a gallery sort of thing. There is another control on your main scene called "display_area", and "display_area" is just a empty white box when you start.

    Now when you click on an image from the gallery it loads that image into "display_area" but it can't replace "display_area" because "display_area" has special controls and buttons for modifying the image you load into it.

  7. #7
    Registered User nunomira's Avatar
    Join Date
    May 2002
    Location
    portugal
    Posts
    7,003
    So, if you want to load a movie inside a Movie Clip, but don't want it to disappear, you'll have to load it inside empty Movie Clip.

    For example, in order to load external.swf inside my_mc:
    code:

    my_mc.createEmptyMovieClip("e_mc", 1);
    my_mc.e_mc.loadMovie("external.swf");


  8. #8
    Member
    Join Date
    Mar 2006
    Posts
    43
    yes that is basically what I want to do the problem is I already have the image loaded and don't want to reload it. Most people would say the Flash Cache would make this not be an issue but the original images are being served up by an ASP.NET application, which means flash will not cache the image thus I cannot re-open the image from the link or I will be faced with re-loading the image

  9. #9
    Registered User nunomira's Avatar
    Join Date
    May 2002
    Location
    portugal
    Posts
    7,003
    If you have an image or a movie which you can duplicate it (visually only) using the BitmapData Class. Apart from this, if you don't want to load the external file again, I'd say it's not possible.

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