loadMovieNum and cache
- Started
- Last post
- 18 Responses
- mr_flaco
So I add '?random=' to the end of strings all the time, as well as when I embed to prevent caching. Will this work with loadMovieNum? Does anyone have a technique for no caching from swf to swf?
- mr_flaco0
Ive been testing it btw, but dont have access to my webserver right now, so it treats it literally, i.e., wont disregard the ?vars...
- weldedturkey0
here's what i use to prevent caching, used in the _root movie.
{_root.daRandom();
daFile = "yourmoviethatyouwanttoload?" + _root.daRandomNumber;
loadMovie(daFile, "yourmoviestargetdestination");
}function daRandom() {
_root.daRandomNumber = Math.random()
}
- mr_flaco0
so it does work from swf to swf, and not just for loading data files?
- SmilingBuddh0
The random number trick will work for loadMovieNum just fine. I usually just use getTimer to give me a 'random' number:
loadMovie(filename + "?r=" + getTimer());
same as:
loadMovie(filename + "?r=" + Math.random());
That should take care of the problem, but as you've noticed, it doesn't work when you're testing it locally.
If you're doing a lot of testing and it's a pain in the ass, you can do something like this:
MovieClip.prototype.loadMovieNum... = function(url,level) {
var append = (_url = "http://www.mysite.com/myswf.swf... ? ("?r=" + getTimer()):("");
loadMovieNum(url + append, level);
}This will only append the random bit if the file is on your server; you can use it just like loadMovie:
mymc.loadMovieNum2("myswf", 50);
- weldedturkey0
i have it on my root movie, which all other movies are loaded into. all movies that load into the same specified target will not cache.
if you would like i can email you sample swfs from my website which uses this code (http://justin.zahndmiller.com)
- weldedturkey0
do either of you know anything about expressions in After Effects?
i'm hurting for a random expression for opacity.
- mr_flaco0
thanks guys. I just needed to know it works with loadMovieNum and on a server, as Im only testing local right now. Now I can press on.
Cheers.
- mr_flaco0
its java script for AE, sorry, dont have one handy. try using the wiggler...wait, which version of AE do you have?
- weldedturkey0
5.5
all i want to do is have a composition start at random points on the timeline.
any suggestions?
- mr_flaco0
I have done it, but wont be back to that machine/file until tomorrow or Monday. I used the wiggler, setting the perams from 0% to your high value...
- weldedturkey0
if you find yourself with access to the script tommorrow, and feel like emailing me, that would rock the house down.
- SmilingBuddh0
Just because I'm a dork, I thought of a better way to do this whole thing:
var mcp = MovieClip.prototype
mcp.oldLMN = mcp.loadMovieNummcp.loadMovieNum = function(url,level) {
var app = (_url.charAt(1) == "h") ? ("?r=" + getTimer()):("");
this.oldLMN(url + app, level);
}This replaces the old LMN function with a new one that automatically appends the random number when it's on the server, but not when it's running local.
Overkill, maybe, but it saves having to type the random shit every time. Might be useful where you're loading a lot of .swfs
- weldedturkey0
damn, you don't fuck around.
any thoughts about my After Effects expression question?
- SmilingBuddh0
Unfortunately, I don't know AE expressions from a hole in the ground.
- mr_flaco0
Nice Buddh.
The AE thing is totally doable with random(100) for the opacity, wiggler for the keyframes.
- weldedturkey0
the most important thing i want to do is have the playhead start at random spots in the timeline.
similar to this (from flash)
therandom=math.random();
therandom=therandom*700;
therandom=math.round(therandom);
if (therandom<2) therandom=2;
gotoAndPlay(therandom);
- mr_flaco0
I dont know about that, but you can have keyframes placed randomly.
- mr_flaco0
using the wiggler