Create MovieClip and Linkage in Script

Posted on 2005-04-12
Last Modified: 2012-05-05
I need to load pictures from the local folder into movie clips at the beginning of the project and then attach the movie clips to place holders at various places.

This is simple to do if the images are already embedded into the SWF file during design time, since I can assign a linkage name and then simply use attachMovie to 'load' them into a placeholder.

How can I do this dynamically during run-time. The issue here is that I can't allow the loading of the image to take place prior to just displaying them. The load process needs to take place right at the beginning.

Thanks for any code suggestions!

Question by:jsound
    LVL 18

    Expert Comment

    so load them and then set the visible quality of the container clip to false at the start of the movie.
    Just make them visible when you want them.

    LVL 18

    Expert Comment

    and when it has loaded:



    Author Comment

    I appreciate the suggestion. Thought about that one too. However, the problem is that it's the same container that I need to be swapping the movie clips in. In other words, each image must be contained in a separate movie clip that is dynamically created. Those movie clips are then attached to the said container clip.

    Hope this makes sense...

    LVL 9

    Accepted Solution

    Hi JB,

    Perhaps this will work for you:

    // Create an array holding the images you want to load
    var arrImages = new Array()
    arrImages[0] = ""
    arrImages[1] = ""

    // Create a container clip to hold the loaded images
    container = createEmptyMovieClip("container",0)

    // Run thru the images in your array
    for (var i = 0; i<arrImages.length; i++){
      // For each image create a new empty movieclip
      this = container.createEmptyMovieClip("image"+i,i)
      // Load the image into the newly created clip
      // Assign the newly created clip to your image array (replacing the path)
      arrImages[i] = this
      // Set alpha = 0
      arrImages[i]._alpha = 0

    // Now when you want to display an image in your conatiner
    // simply refer to the arrImages[x] raising alpha to 100 like:

    arrImages[0]._alpha = 100

    Best, Jakob E


    Author Comment

    Thanks, Jakob. This will be a good workaround. I would have preferred a solution that allowed me to create a movie clip AND specify a linkage name for the clip. However, it seems that Flash Actionscript doesn't have support for that. I may be wrong, but I haven't seen anything, thus the question.



    Featured Post

    Do You Know the 4 Main Threat Actor Types?

    Do you know the main threat actor types? Most attackers fall into one of four categories, each with their own favored tactics, techniques, and procedures.

    Join & Write a Comment

    Recently, I was asked to recommend a tracking system to be implemented on a clients website. As the entire site was built on flash, my first thought was to suggest custom built tracking system. However, our company at that point of time didn't h…
    In my long career of working as an actionscript developer, I had spent sleepless night often working hard to solve some small problems which actually took a lot of my development time; later found out the solutions to be a line or two. Here are s…
    In this tutorial viewers will learn how to create a basic motion tween animation in Flash Open a new document in Flash: Draw/import an image: Press CTRL + F8 to convert it into a graphic symbol: Select a frame (how long you want the tween to last): …
    The goal of the tutorial is to teach the user how to select which audio input to use. Once you have an audio input plugged into the laptop or computer, you will go into the audio input settings and choose which audio input you want to use.

    754 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    21 Experts available now in Live!

    Get 1:1 Help Now