?
Solved

Create MovieClip and Linkage in Script

Posted on 2005-04-12
5
Medium Priority
?
796 Views
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!

JB
0
Comment
Question by:jsound
  • 2
  • 2
5 Comments
 
LVL 18

Expert Comment

by:Billystyx
ID: 13767575
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.

Billystyx
0
 
LVL 18

Expert Comment

by:Billystyx
ID: 13767629
container.loadMovie("mypic1.jpg");
and when it has loaded:

container._visible=false;

Billystyx
0
 

Author Comment

by:jsound
ID: 13767685
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...

JB
0
 
LVL 9

Accepted Solution

by:
Jakob_E earned 2000 total points
ID: 13768303
Hi JB,

Perhaps this will work for you:

// Create an array holding the images you want to load
var arrImages = new Array()
arrImages[0] = "http://www.experts-exchange.com/images/woman_orange.jpg"
arrImages[1] = "http://www.experts-exchange.com/images/expertPic.jpg"

// 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
  this.loadMovie(arrImages[i])
  // 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
 

0
 

Author Comment

by:jsound
ID: 13768465
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.

Thanks,

JB
0

Featured Post

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

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…
While working over numerous projects I often had the requirement for doing a screen capture in AS3.0. Unfortunately I found no "ready made" solutions in google search that suited my requirements. But I did come across some great resources which help…
The goal of the tutorial is to teach the user how to how to record live broadcast.
The goal of the tutorial is to teach the user what frame rate is, how to control it and what effect it has on the video.
Suggested Courses

840 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