PDA

View Full Version : Add Files to Library Programatically?


maguidhir
03-08-2006, 04:18 PM
Is there a way to add external files to the library programatically in actionscript?

Xeef
03-08-2006, 04:27 PM
hi and welcome to As.Org


NO :(


search for "runtime sharing" may eventualy help

maguidhir
03-08-2006, 04:33 PM
hi and welcome to As.Org

NO :(

search for "runtime sharing" may eventualy help

Thanks for the welcome :)

Ok, how about instead of programatically importing to the library, would there be a way to programatically bring in several swf files to the stage and place them at particular coordinates? I'm very very new to this, so excuse me if the questions seem elementary. Though, i suppose...this is the newbie forum. Thanks for the help.

Xeef
03-08-2006, 04:42 PM
Lookup

"MovieClipLoader"

"MovieClip.loadMovie"

in the help

the first one is a bit more complicated but woud sugest to learn to use it !
because you get status callbacks

eg .
clip is loaded
there was an error
...
..
.

maguidhir
03-08-2006, 07:42 PM
Thanks, I got the Load movie to work...but I have another issue. I'm trying to load multiple swf's to the stage, but I can't get them to all appear at the same time. They appear one after the other at runtime. I did a little research and then tried using createEmptyMovieClip for each swf that I want to add, and then loading the swfs to separate movieclips. This did not work, they still appear one after the other. What am I doing wrong? Also, does anyone know of a good tutorial site that could help me get through the basics? Thanks

Xeef
03-08-2006, 08:49 PM
as fare a movie is loaded it will apear

they never will down load at the same time ;)

solution is to make the movie invisible and visible as fare all has loaded
(but me personaly woud like to see they apearing one after each so i have some filing what's going on)
Mc._visible=false make it invisible Mc._visible=true visible


Hmmm not sure that this isn't to much for now ;)


var mclListener:Object = new Object();
mclListener.onLoadInit = function(target_mc:MovieClip) {
target_mc._visible = false;
this.Loaded++;
_root.LoadedImage.push(target_mc);
if (this.Loaded == _root.ToLoad.length) {
for (a=0; a<_root.LoadedImage.length; a++) {
_root.LoadedImage[a]._visible = true;
}
}
};
mclListener.Loaded = 0;
var image_mcl:MovieClipLoader = new MovieClipLoader();
image_mcl.addListener(mclListener);
ToLoad = ["http://www.helpexamples.com/flash/images/image1.jpg", "http://www.w3.org/Icons/w3c_main.png"];
LoadedImage = [];
for (a=0; a<ToLoad.length; a++) {
_mc = this.createEmptyMovieClip("_mc"+a, this.getNextHighestDepth());
image_mcl.loadClip(ToLoad[a], _mc);
}



Also, does anyone know of a good tutorial site that could help me get through the basics?

http://www.actionscript.org/tutorials.shtml

maguidhir
03-09-2006, 03:59 PM
Sorry, I guess I didn't mean to say that I wanted the movie clips to appear at exactly the same time. What was happening was this: they were appearing one after the other, but each one would disappear before the next would show, so at the end of the movie, only 1 would be present on the screen. I wanted them all to show up in the end. I figured out what had to be done, and have posted the code below. For each clip that i wanted to load, I needed to use createEmptyMovieClip() and use loadMovie to load each movie into a different empty movie clip. To insure that they all show on the screen in the end, the empty movie clips had to have different names and be at different depths.


for (var i:Number=1; i<=5; i++) {
// get the depth and file location from root variables
var depth = eval("_root.thing" + i).charAt(0);
var swfLocation = eval("_root.thing" + i).substring(2, (eval(thing+i)).length);

// load the movie in empty movie clip
createEmptyMovieClip("container" + i, depth);
loadMovie(swfLocation, "container" + i);
}


Thanks for all the help! Sorry that I wasn't very clear about what I needed.