Skip to main content
Michael Lunsford
Inspiring
September 10, 2008
Answered

dynamic image load with MovieClipLoader

  • September 10, 2008
  • 14 replies
  • 1119 views
I'm trying to load five images from five URLs. If I use the documentation exactly as is, it works fine. Problem is, I don't want to createEmptyMovieClip, I want to use an existing one that's tucked inside a movie instance. Also, the images coming in are of unknown size, but have a standard 4:3 size ratio. I'd also like to scale them down to 180x120 after they arrive. Any help would be greatly appreciated.

The code below only loads one image (which isn't working). I will eventually need it to load five different images.

This topic has been closed for replies.
Correct answer Rothrock
Hey we've all been there with messing up the names of variables and stuff and such. So hopefully you are learning how to use the traces in specific spots to find the names of things.

What that is telling you is that at the time that code executes there isn't a movieclip with that name. I downloaded your fla and sure enough the code is on Frame 1, but the clip doesn't exist until Frame 2. You need to move the stage placed clips to frame 1. And it should work.

14 replies

Michael Lunsford
Inspiring
September 16, 2008
Wow, well, I got really lucky and the ad serving software can remotely deliver the ad, so I put it on the same "remote" server that the database script resides. Presto, problem one is gone.

An added benefit to having it actually online and working is the browser is caching the images, so it only flickers on the loading page before continuing.

Looping because I built the ad using techniques from flash 5 or so where the entire movie is on the main timeline. I need to take a flash class, or get a book on best practices because I really don't get how to do it any other way.

Anyway, Thanks Rothrock, you saved me big time on this one. That neglected name on the middle container movie was the big thing that held me up. The rest of this stuff was just hacking until I got it figured out.

Thanks!
Inspiring
September 16, 2008
Not sure on the first one. I haven't done cross domain scripting. Are you seeing this problem in the test publish environment or have you actually put it on your server to test it? I think that might fix it. Otherwise you'll need to look into cross domain. I think that the server needs an xml file at the root that allows your domain to access it. I'm sure that can be worked out.

As for the next I'm not really sure. but you could put some kind of conditional that checks if they have already been loaded and if so don't load them again. It is strange that it takes so long to reload them. Generally they sould be in the browser cache and reloading should be almost instantaneous.

Why are you looping at all? Are you doing depth swapping?
Michael Lunsford
Inspiring
September 16, 2008
Well, I have it almost ready to go. It's mostly a crazy hack, but it works in test mode.

Two problems, one major, one not so major:

1. "Flash player has stopped a potentially unsafe operation." The LoadVars is calling an external URL. There's nothing I can do to localize the URL, as this flash file is running on an ad server that I don't have access to. This is preventing the variables from loading, and breaking the whole file. Any hacks to get around this wonderful "feature"?

2. The issue previously mentioned about only the last loaded image remaining after the movie loops. Basically, the movie holds on frame 2 until until all five images load. It scrolls through the five images. at the end, it reaches a gotoAndPlay(3) that loops back to frame 3. The first four images are missing, but the last one is in place. I've "fixed" this issue by going back to frame 2, which reloads all five images. The big part of this problem is it can take 15 to 30 seconds to reload the images.

the latest revision is here:
http://www.uncommonname.com/vidframeTDA8b.fla
Inspiring
September 11, 2008
While you are at it, you might want to have only one of these pre-made templates and set it to export for actionscript. Then you can use attachMovie to attach as many of them as you need after the variables load. That way you might have 5 some day, but some other day you might have 8 or 3 or whatever. Just a thought.

It is hard to give advice on exactly how to do these things because everybody's requirments are different and everybody's thought process is different. You are making progress and there wasn't anything deeply flawed with your original idea. Just a few little areas where it can be worked this way or that way a bit easier.
Michael Lunsford
Inspiring
September 11, 2008
It's apparently the best practices stuff that's coming around to bite me. I'll rework it today and let you know how it goes.
Inspiring
September 11, 2008
Are you doing any depth swapping? That is what it sounds like. Other than that I wouldn't know.

I would probably design this whole thing very differently from what I briefly saw in you FLA. So it is hard to know what to suggest at this point. For example I almost never have the main timeline loop. My main timelines are either one frame with some code or maybe 20 or 30 frames with keyframes and labels at 1 and 10. The labels would be something like "init" and "content". The init label would have some code to load some variables and assets and then it would gotoAndStop("content");
Inspiring
September 11, 2008
Dynamic text that doesn't have embedded fonts won't respond to tweening, alpha, etc. So you need to embed the font(s). There are a couple of ways to do this depending upon what you are doing. But most likely you can just select the text field and click the font button on the properties panel and select embed. Also I would recommend that you use _visible=false instead of alpha for this effect.

I'm not sure what the second go-round is. Can you explain that a bit better? You should be able to use the same loader, so I'm not quite sure what is going on. Again, look for some helpful places to put some traces and see if you can figure out what is going on. Remember that generally Flash does what we tell it, not what we want! So if you can find the places where you are telling it to do things you can figure out what is happening.

Also I'm not clear on what is going on with the variables and text. Generally I would recommend against using the variable property of text fields. That is a leftover from the Flash 5 days when you couldn't work directly with dynamic text fields. Instead give the fields instance names and then assign the text with the text property.

myTextField.text="some value in here";
myTextField2.text=someStringVariable;




Michael Lunsford
Inspiring
September 11, 2008
Oh, sorry. By "the second go around" I mean the whole thing loops. At the end of the movie I have a script that says gotoAndPlay(2) that brings you back to the first frame that doesn't load anything. If I do this, it will have only the last image loaded.

Also, I've managed to hack a fix by moving the image loads to frame 2. But this just reloads the images again (and adds a slight pause to the movie).
Michael Lunsford
Inspiring
September 11, 2008
Okay, a few more challenges: The images all load, but the second go-round all but the last image loaded disappear. Do I need to build a separate loader for each image?

Also, since all the movie instances are in the first frame before the text variables load, the text is empty. Once the movie makes a complete loop, the text appears.
Michael Lunsford
Inspiring
September 11, 2008
Okay, I did what you said -- moved all the movie containers to the first frame. The AS works great now.

New problem. Now I have five movie containers with text and images all on the first frame. My static text and images respond to making the container movie 0% alpha, but the dynamic text doesn't listen. Now what?
RothrockCorrect answer
Inspiring
September 10, 2008
Hey we've all been there with messing up the names of variables and stuff and such. So hopefully you are learning how to use the traces in specific spots to find the names of things.

What that is telling you is that at the time that code executes there isn't a movieclip with that name. I downloaded your fla and sure enough the code is on Frame 1, but the clip doesn't exist until Frame 2. You need to move the stage placed clips to frame 1. And it should work.