.onLoadComplete No Can Do?
I working on some dynamic loading and I want execute a function after the image is loaded.... myMc.loadMovie("pageimage.jpg");myMc.onLoadComplete = function() { trace("run this");};The onload complete will not work in such an instance. I know i could just do a (if getbytestotal = bytesloaded...) but im trying to learn a little here Am i correct in assuming that i would have to add a listener to make this work?any ideas?
KirupaForum > Flash > ActionScript 1.0/2.0
Posted on: 04-27-2004, 04:22 PM
View Complete Forum Thread with Replies
See Related Forum Messages: Follow the Links Below to View Complete Thread
OnLoadComplete() Help
can someone take a look at this post in the Flash MX section?
http://www.flashkit.com/board/showth...hreadid=507220
not getting any response other than my own...
thanks,
-myk
Mcl OnLoadComplete
hi, can you please help?
i'm building a movie that will take file names from an XML doc ("source.xml")
and loads them into movieclips on stage (its jpgs).
now the problem is with the alignment. i wrote code to align those new movieclips on the stage but it seems like it firsts loads the jpg, and then it doesnt align at all.
here is the relevant code:
Code:
var mclJPG:MovieClipLoader = new MovieClipLoader();
var oJPGListener:Object = new Object();
var xmlData:XML = new XML();
xmlData.ignoreWhite = true;
xmlData.load("source.xml");
xmlData.onLoad = function(bVerify:Boolean){
if(bVerify){
var xnRoot:XMLNode = xmlData.firstChild;
var xnCellular:XMLNode = xnRoot.firstChild; /* xnCellular takes a node in which
jpg names sit in childnodes*/
var aCellular:Array = xnCellular.childNodes;
for(var i:Number = 1; i < (nNumofPics+1); i++){
var sJPGName:String = String(aCellular[i-1].firstChild);
_root.createEmptyMovieClip("mcCellPic" + i, this.getNextHighestDepth());
oJPGListener.onLoadComplete = function(mcCellPic1:MovieClip){
_root["mcCellPic" + i]._x = (Stage.width/10) + (i-1)*((Stage.width - Stage.width/5)/(nNumofCellPics-1));
}
mclJPG.addListener(oJPGListener);
mclJPG.loadClip(sJPGName, _root["mcCellPic" + i]);
}
}
}
the names of the jpg are in the same folder as the movie is.
examples are: nokia.jpg, motorola.jpg, samsung.jpg ect...
does anybody know what seems to be they problem?
.onLoadComplete No Can Do?
I working on some dynamic loading and I want execute a function after the image is loaded....
myMc.loadMovie("pageimage.jpg");
myMc.onLoadComplete = function() {
trace("run this");
};
The onload complete will not work in such an instance. I know i could just do a (if getbytestotal = bytesloaded...) but im trying to learn a little here
Am i correct in assuming that i would have to add a listener to make this work?
any ideas?
OnLoadComplete Problem
I have a file master.swf which loads two files into it - a preloader and the main movie. I am loading the preloader into level 4 and the main movie into level 5.
myMCL.loadClip("flash/main.swf", 5);
myMCL.loadClip("flash/preloader.swf", 4);
There is a stop on frame one of the main movie, so it won't start until the preloader has finished:
myListener.onLoadComplete = function(target_mc) {
_level4._visible = false;
_level5._visible = true;
_level5.play(2);
}
In Internet Explorer, after the movie has loaded into the cache and you refresh the screen, it will sit there on the STOP frame of the main movie, not advancing to frame 2. In other words, it's ignoring _level5.play(2);
Firefox, however, renders this just fine. What's going on?!?!?
If I move this preloader into Scene 1 of the main movie, how do I set the target?
Master.fla is attached.
Thanks!
Positioning A Mc With OnLoadComplete
Hi,
I'm loading a swf into an mc on the stage. After it's loaded I want to center it on stage. I'm doing something like this:
Code:
maintimeline = this;
mainMC.onResize = function() {
this._x = (Stage.width+this._width)/4;
this._y = (Stage.height+this._height)/4;
};
Stage.addListener(mainMC);
maintimeline.mainMC.onResize();
//
var mainMCloader = new MovieClipLoader();
mainMClistener = new Object();
mainMClistener.onLoadComplete = function() {
updateAfterEvent;
maintimeline.mainMC.onResize();
};
mainMCloader.addListener(mainMClistener);
mainMCloader.loadClip("main.swf", maintimeline.mainMC);
The problem is that, even while I'm using onLoadComplete, Flash thinks that the mainMC._width = 0. It is only, when I make the timeline play a couple of frames that mainMC._width finally results in the real size (the one of the loaded swf).
What I'm I doing wrong???
Cheers
OnLoadComplete Example In Actionscript 1.0
There's a help topic in Flash 8 HELP about onLoadComplete function. The problem is that it's for actionscript 2.0 and I just can't get it to work on actionscript 1.0. can anyone help me rewriting it? I need the whole example to work on actionscript 1.0. :
Code:
var loadListener:Object = new Object();
loadListener.onLoadComplete = function(target_mc:MovieClip, httpStatus:Number):Void {
trace(">> loadListener.onLoadComplete()");
trace(">> =============================");
trace(">> target_mc._width: " + target_mc._width); // 0
trace(">> httpStatus: " + httpStatus);
}
loadListener.onLoadInit = function(target_mc:MovieClip):Void {
trace(">> loadListener.onLoadInit()");
trace(">> =============================");
trace(">> target_mc._width: " + target_mc._width); // 315
}
var mcLoader:MovieClipLoader = new MovieClipLoader();
mcLoader.addListener(loadListener);
var mc:MovieClip = this.createEmptyMovieClip("mc", this.getNextHighestDepth());
mcLoader.loadClip("http://www.w3.org/Icons/w3c_main.png", mc);
Problem With OnLoadComplete
Hi
really banging my head against the wall
im trying to retrieve the width and height of a loaded jpeg from xml.
it loads the pictures fine into a dynamically created MC
then i try to retrieve the dimensions after much searching i have added a on load complete listener but when i try and trace the widths and heights i still get 0....
e.g. my trace output is
_level0.Holder.container0
images/p.jpg width = 0
images/p.jpg height = 0
_level0.Holder.container1
images/p1.jpg width = 0
images/p1.jpg height = 0
_level0.Holder.container2
images/p2.jpg width = 0
images/p2.jpg height = 0
_level0.Holder.container3
images/p3.jpg width = 0
images/p3.jpg height = 0
_level0.Holder.container4
images/p4.jpg width = 0
images/p4.jpg height = 0
any help wood be so great
thanks
Charlie
Code:
function firstImage() {
photo_mc.loadPhoto(image[0]);
content.text = description[0];
for (i=0; i<total; i++) {
_root.Holder.createEmptyMovieClip("container"+i, i);
containerHolder = "_root.Holder.container"+i;
eval(containerHolder).LoadThumbs(thumb[i], eval(containerHolder));
}
}
MovieClip.prototype.LoadThumbs = function(thumbPhoto, containerHolder) {
var listener:Object = new Object();
var mcl:MovieClipLoader = new MovieClipLoader();
mcl.addListener(listener);
listener.onLoadComplete = function() {
trace(containerHolder);
var w = containerHolder._width;
trace(thumbPhoto+" width = "+w);
var h = containerHolder._height;
trace(thumbPhoto+" height = "+h);
};
mcl.loadClip(thumbPhoto, containerHolder);
};
[F8] AS OnLoadComplete Or OnLoadInit
Hi. I have a movie clip that works as a container for jpegs. The actions I am giving is this:
container_mc.loadMovie("image1.jpg")
I want another movie to play at the moment when the loading of the image is completed. I have tried a lot of things but none of them work. Some help please? Thanks you
OnLoadComplete Not Firing...
Hi:
I´m trying to build a photo slide that "auto-advances" using an interval. So when I call the interval to show the next pic, I check if the next one is loaded.
When testing it locally, the onComplete (also tried onInit) work fine, but when testing on the server, the onLoadComplete doesn´t fire. I know the pic is loaded (I use web speed simulator and can see that the jpg is loaded), but the event doesn´t fire.
Any help would be greatly appreciated, I´m stuck.
Here´s part of the code.
Code:
var imgLoader = new MovieClipLoader();
var imgNum = 0;
// la defino ahora, porque al añadirle clips y fotos se jode el alto y no se centran
var master_alto=this._height
function loadImg(){
imgNum = my_secc.numfotos;
//trace(imgNum);
//Create the instance name for the movieclip to hold the image
imgMcName = "img" + imgCurLoad + "_mc";
if(imgCurLoad <= imgNum){
this.createEmptyMovieClip(imgMcName, this.getNextHighestDepth());
eval(imgMcName)._alpha =0;
imgLoader.loadClip(folder+"/" + imgCurLoad + ".jpg",imgMcName);
}
}
imgLoader.onLoadComplete = function(target_mc:MovieClip){
traceAlert("target_mc "+target_mc)
traceAlert("photo number loaded "+imgMcName.substr(3,1));
if(imgCurLoad == 1){
eval(imgMcName)._alpha = 100;
imgSelected = imgCurLoad;
//this is the interval that shows the next pic. It hides the previous and fades in the next one
auto_foto=setInterval(pict_av,Number((fotodelay+fade_largo)*1000))
}
//Incriment imgCur for the next load, and start the process again
imgCurLoad++;
loadImg();
}
Why OnLoadComplete Is Not Called
hi,
the event onLoadComplete is not triggered.. why ??
If I move
ActionScript Code:
this.addChild(image);
outside the method, it is working instead...
ActionScript Code:
var image:Loader = new Loader();
image.addEventListener(Event.COMPLETE, onLoadComplete);
var url:URLRequest=new URLRequest("images/DSCF2375.jpg");
image.load(url);
trace(image.x);
function onLoadComplete(e:Event):void {
this.addChild(image);
trace(image.height);
}
thanks
Get Width Of Mc OnLoadComplete ?
Hi there
I'm just re-writing some of my AS1 code to utilise some of the benefits of AS2, and I've hit a wall with the movieClipLoader object. All I'm trying to do is get the width of a loaded jpeg onLoadComplete, but I keep getting a value of 0. If I assign an onPress listener with the same code in it, when I click the jpeg, it returns the correct value, which suggests to me that my onLoadComplete is not actually complete...
here is the code:
ActionScript Code:
tMCL = new MovieClipLoader(); //loader for thumbs
iMCL = new MovieClipLoader(); //loader for main images
tListener = new Object(); //listener for laod error in thumbnail
iListener = new Object(); //listener for load error in main image
tMCL.addListener(tListener); //assign listener to thumb loader
iMCL.addListener(iListener); //assign listener to main loader
//**************** Main Functions *************************************************
tListener.onLoadComplete = function(targetThumb){ //listener event for each thumbnail
trace( "LOADING OF " + targetThumb + " COMPLETE")
trace(targetThumb._width);
targetThumb.onPress = function() {
trace("targetThumb = " + targetThumb.imageNum); // sets up onPress event for enlargement of main images
trace(targetThumb._width);
} //end onpress
} //end function
function loadImages(artist, book, final) {
for (j=1; j<=final; j++){
thumbStrip.thumbNail.duplicateMovieClip("thumbNail_"+j, j); //duplicate clip
thumbStrip["thumbNail_"+j].imageNum = j; //assign identifier
thumbStrip["thumbNail_"+j]._x = j*60; //position 110 apart
thumbStrip["thumbNail_"+j]._y = -104; //position 110 apart
tMCL.loadClip("../images/"+artist+"/thumbs/"+artist+"_"+book+"_"+j+".jpg", thumbStrip["thumbNail_"+j].thumbHolder); //loads jpeg into movie clip
placeHolder.duplicateMovieClip("placeHolder_"+j, j); //load large image into holder
iMCL.loadClip("../images/"+artist+"/"+artist+"_"+book+"_"+j+".jpg", _root["placeHolder_"+j].imageHolder); //loads jpeg into movie clip
_root["placeHolder_"+j]._visible = false; //sets large image invisible
_root["placeHolder_"+j].ID = j;
if (j>=final) {
_root.finalImage = final-1; //sets final image for later reference
} // end if
} // end for
} //end function
loadImages('wd', 'beau', 28); //initiate loading of thumbs - William Davies, beauty, last image is #28
Any help would be much appreciated!
OnLoadComplete Problem
I've been smashing my head against the keyboard for the last 2 days on how to make this work...
Please help!
I'm loading a text dynamic in to a movieClip with the Load Variable class.
My problem is that i can not tell when the text is loaded.. to add my animation only then.
this is the code i use (partial):
lv.load("lorem.txt");
lv.onLoad = function() {
my_txt.text = this.txtField;
my_txt.setTextFormat(my_fmt);
}
lv.onLoadComplete = function () {
trace("loading_done"); //// this doesn't seem to work!
}
OnLoadComplete Issue
I'm loading an MC and then attempting to activate a function onLoadComplete in order to hide the MC. The function is actually reused several times through out the "app" I'm building. I know the onLoadComplete works because I tested it, but the function isn't being activated
ActionScript Code:
var msgMC:MovieClipLoader = new MovieClipLoader();var msgMCL:Object = new Object();msgMC.loadClip("message.swf"+"?uniqueID="+getTimer(), msg);msgMC.addListener(msgMCL);var root:MovieClip = this;msgMCL.onLoadComplete = function() { msg.messageBox._x = Stage.width/2; msg.messageBox._y = Stage.height/2; root.msgHide();};function msgReveal(msgString:String, btn1B:Boolean, btn2B:Boolean, btn3B:Boolean, command1:String, command2:String, command3:String) { msg.messageBox._visible = true; msg.messageBox.textF.htmlText = msgString; msg.messageBox.btn1._visible = false; msg.messageBox.btn2._visible = false; msg.messageBox.btn3._visible = false; if (btn1B) { msg.messageBox.btn1._visible = true; } if (btn2B) { msg.messageBox.btn2._visible = true; } if (btn3B) { msg.messageBox.btn3._visible = true; } msg.messageBox.btn1.onRelease = function() { this._parent._parent._parent.msg.messageBox.textF.text = command1; this._parent._parent._parent.callFunction(command1); //root[command1](); }; msg.messageBox.btn2.onRelease = function() { this._parent._parent._parent.msg.messageBox.textF.text = command2; this._parent._parent._parent.callFunction(command2); //root[command2](); }; msg.messageBox.btn3.onRelease = function() { this._parent._parent._parent.msg.messageBox.textF.text = command3; this._parent._parent._parent.callFunction(command3); //root[command3](); };}function callFunction(callUpon:String):Void { //root[callUpon](); eval(callUpon)(); msg.messageBox.textF.text = callUpon;}function msgHide() { msg.messageBox._visible = false; msg.messageBox.textF.htmlText = ""; msg.messageBox.btn1._visible = false; msg.messageBox.btn2._visible = false; msg.messageBox.btn3._visible = false;}
OnLoadComplete Tween
Hey everyone. Has anyone run into this problem before? I can't seem to figure out why the below code won't tween. There's obviously more code, but this should be the problem. Anyone have any ideas?
Code:
....
listener.onLoadComplete = function(mc:MovieClip):Void {
var tw:Tween = new Tween(mc, "_x", Strong.easeOut, mc._x, 210, 1, true);
}
...
OnLoadComplete Issue
Wassup guys, so I did the tutorial for the external swf preloaders and it seems to work fine. I wanted to take it a step further however and add a little masking effect to transition smoother than just making the preloader invisible by changing the ._visible to false. So I made a little mask animation instead.
This is what I have:
mclL.onLoadComplete = function() {
loader.gotoAndPlay("reveal");
//loader._visible = false
loader.percent.text = "";
}
so now what should happen is after it loads it goes to and plays the "reveal" keyframe which is where the masking animation starts. However, the problem that is occuring is that the animation is starting a bit too early. So now I can't see the preloader because the masking animation is happening in the spot where I would usually see the percentage number increasing. Does anybody know why this is happening. In the tutorial he had onLoadInit but that didn't work either I thought that changing it to complete would make a difference. I also have stops located in the appropriate places so it isn't playing on it's own either. Something is telling it to gotoAndPlay("reveal") earlier than I want it to.
Any suggestions?? thanks :)
Trying To Understand 'MovieClipLoader.onLoadComplete()' - Please Help
Hi All!
I am trying to get an mp3 to start streaming after a jpg has finished dynamically loading. I know the best way to do this is to use MovieClipLoader.onLoadComplete(), however I'm having a few implementation problems as you can see below. Any help would be really appreciated.
Code:
function nextImage() {
if (p<(total-1)) {
p++;
if (loaded == filesize) {
empty_mc._alpha = 0;
mclListener.onLoadStart = function(empty_mc) {
empty_mc.loadMovie(image[p], 1);
};
mclListener.onLoadComplete = function(empty_mc) {
audio_mc.loadSound(audio[p], 1);
};
}
}
}
Thank you.
OnLoadComplete GotoAndPlay Issue...
Hello...
I am trying to use MovieClipLoader with a preloader and it works fine if I am just loading the movieclip into a empty movieclip when the preloader reaches 100%. But instead of loading the movieclip I wanted to go to a specific frame with in the preloader to show another motion tween then I will load the movieclip and continue on. Not sure how to go about this. I tried onLoadComplete but that did not work. Here is my code so far with it loading into the empty movie clip.
loader_mc.bar_mc._xscale = 0;
var myLoader_mcl:MovieClipLoader = new MovieClipLoader();
var mclListener:Object = new Object();
mclListener.onLoadProgress = function(target_mc:MovieClip) {
trace(getTimer());
var prog:Object = myLoader_mcl.getProgress(target_mc);
var pctLoaded:Number = Math.round((prog.bytesLoaded/prog.bytesTotal)*100);
loader_mc.bar_mc._xscale = pctLoaded;
loader_mc.pctLoaded_txt.text = pctLoaded+"% loaded";
};
myLoader_mcl.addListener(mclListener);
myLoader_mcl.loadClip("bigfile.jpg", this.createEmptyMovieClip("holder", 2));
MovieClipLoader OnLoadComplete Problem
i am dynamically creating a 2 movie clips in a class. in one movie clip i am loading the image using MovieClipLoader. everything is working fine. but the onLoadComplete method is not working properly.
i am using onLoadComplete method to find the width of the image but in onLoadComplete event the exact width is not calculating
code is here
__imageClip = createEmptyMovieClip("MyImage", this.getNextHighestDepth());
__canvasClip = createEmptyMovieClip("MyCanvas", this.getNextHighestDepth());
imageLoader = new MovieClipLoader();
imageLoader.addListener(mclListner);
mclListner.onLoadComplete = function():Void {
__fileWidth = _root.myLoader.__imageClip._width;
__fileHeight = _root.myLoader.__imageClip._height;
trace(__fileWidth);
};
imageLoader.loadClip(__fileName, this.__imageClip);
Faraz
MovieClipLoader Never Makes It To OnLoadComplete?
I'm hoping someone with more experience with the moviecliploader class can help me. I'm trying to load two images into two instances of a child movie (mcDog and mcCat). I'm trying to load these two images and when they're loaded move on to the next frame (named start). When I press Ctrl-Enter to test the movie, everything works fine. However when I simulate download, it never makes it into the onloadcomplete function at all, so it never advances to the next frame. I've attached the code. Anyone have any ideas? Thanks!
Attach Code
stop();
mcDog._visible = false;
mcCat._visible = false;
var mcLoader:MovieClipLoader = new MovieClipLoader();
var mcListener:Object = new Object();
var picsLoaded:Number = 0;
mcLoader.addListener(mcListener);
mcDog.createEmptyMovieClip("imgContainer", this.getNextHighestDepth());
mcLoader.loadClip("pets/" + dog.id + ".jpg", "mcDog.imgContainer");
mcDog.imgContainer._x = 10;
mcDog.imgContainer._y = 10;
mcCat.createEmptyMovieClip("imgContainer", this.getNextHighestDepth());
mcLoader.loadClip("pets/" + cat.id + ".jpg", "mcCat.imgContainer");
mcCat.imgContainer._x = 10;
mcCat.imgContainer._y = 10;
mcListener.onLoadComplete = function(mcTarget)
{
// It never makes it inside this function when I simulate download
picsLoaded++;
if (picsLoaded == 2)
{
gotoAndStop("start");
}
}
OnLoadComplete Problem In Preloader
I'm trying to display a swf file, but only after it's 100% loaded. Even though the code below seems to request that the swf doesn't show until the load is "complete", when I publish the file and use the "simulate download" function, it displays the swf after only 72% has been loaded. The file size is about 1400KB, and it seems to display after about 1100KB are loaded. Any suggestions?
on (release) {
this._visible = false;
_level0._visible = true;
//_level0.main_menu._visible = false;
var myMCL:MovieClipLoader = new MovieClipLoader();
var myListener:Object = new Object();
myMCL.addListener(myListener);
myListener.onLoadProgress = function(target_mc:MovieClip, bytesLoaded:Number, bytesTotal:Number) {
var preloadPercent:Number = Math.round((bytesLoaded/bytesTotal) * 100);
_level5.progressBar.gotoAndStop(preloadPercent);
}
myListener.onLoadInit = function (target_mc:MovieClip) {
_level5.progressBar._visible = true;
}
myListener.onLoadStart = function (target_mc:MovieClip) {
_level5.progressBar._visible = true;
}
myListener.onLoadComplete = function(target_mc:MovieClip) {
_level5.progressBar._visible = false;
}
_level0.myMCL.loadClip("bobsRoom.swf", 10);
}
Issue With OnLoadInit And OnLoadComplete?
Hello Everyone,
I am going crazy with simple functionality, I would highly appreciate your help. I load a movie called "menus" on stage, it is a simple slide-Out slide-In menu. Within this menu I have four movie clips.
link1
link2
link3
link4
I load "menus" with MovieClipLoader, an OnLoadInit, I read in all the movie via for In loop and when this menu is loaded, I am able to click on the links, and the do fire away. But if I put a slideOut and slideIn function within onLoadComplete, SlideOut, and SlideIn will work but I am not longer able to click the links.
I would highly appreciate it if someone can point out what am I doing wrong.
Attach Code
// MY CODE
=======================================================
// ROOT GLOBAL VARIABLE
_global.gRoot = this;
// TOGGLE SWITCH VARIABLE ISENABLED FOR CONTENT MENU TO POP UP AND BACT TO ITS LOCATION
_global.isEnabled = null;
// CONTENT MENU PATH ON ROOT
var menuPath = gRoot.cmenu.menuLoader;
// CM STANDS FOR CONTENT MENU
var cmLoader:MovieClipLoader = new MovieClipLoader();
// OBJECT IS BEING INITIALIZED TO ATTACH TO CONTENT MENU LOADER
var myObj:Object = new Object();
myObj.onLoadInit = function(mc:MovieClip)
{
for(var a in mc)
{
for(var b in mc[a])
{
mc[a][b].onPress = function()
{
if(mc[a][b])
{
//trace(this);
switch(this)
{
case menuPath.spotlightMenu.link1:
trace("HOME");
//oader.loadClip("movies/home.swf", cont);
break;
case menuPath.spotlightMenu.link2:
trace("WORK");
//loader.loadClip("movies/work.swf", cont);
break;
case menuPath.spotlightMenu.link3:
trace("PORTFOLIO");
//loader.loadClip("movies/portfolio.swf", cont);
break;
case menuPath.spotlightMenu.link4:
trace("CONTACT");
//loader.loadClip("movies/contact.swf", cont);
break;
}
}
}
}
}
}
myObj.onLoadComplete = function(target:MovieClip)
{
//target.onRollOver = slideOut;
}
// CMLOADER IS LOADING THE MENU MOVIE HERE
cmLoader.loadClip("myMenus.swf", menuPath);
// OBJECTLISTENER IS BEING INITIALIZED HERE
cmLoader.addListener(myObj);
// TWEEN CONTENT MENU
function initMenu(target:MovieClip)
{
target.slideTo(0, -248, 2);
}
// FUNCTION CLOSE MENU
function placeMenu(target:MovieClip)
{
target.slideTo(0, -89, 2);
}
setTimeout(initMenu, 50, menuPath);
setTimeout(placeMenu, 3000, menuPath);
// TOGGLE EVENT FUNCTIONS (SLIDE-OUT ON ROLLOVER) AND (SLIDE-BACK IN ON ROLLOUT)
// SLIDE OUT
function slideOut()
{
if(isEnabled == null)
{
this.slideTo(0, -248, 3);
isEnabled = true;
//updateAfterEvent();
}
}
// SLIDE BACK IN
function slideIn()
{
if(isEnabled == true)
{
this.slideTo(0, -89, 2);
isEnabled = null;
//updateAfterEvent();
}
}
Trying To Understand 'MovieClipLoader.onLoadComplete()' - Please Help
Hi All!
I am trying to get an mp3 to start streaming after a jpg has finished dynamically loading. I know the best way to do this is to use MovieClipLoader.onLoadComplete(), however I'm having a few implementation problems as you can see below. Any help would be really appreciated.
Code:
function nextImage() {
if (p< (total-1)) {
p++;
if (loaded == filesize) {
empty_mc._alpha = 0;
mclListener.onLoadStart =function(empty_mc) {
empty_mc.loadMovie(image[p], 1);
};
mclListener.onLoadComplete =function(empty_mc) {
audio_mc.loadSound(audio[p], 1);
};
}
}
}
Thank you.
MovieClipLoader OnLoadComplete Problem
am dynamically creating a 2 movie clips in a class. in one movie clip i am loading the image using MovieClipLoader. everything is working fine. but the onLoadComplete method is not working properly.
i am using onLoadComplete method to find the width of the image but in onLoadComplete event the exact width is not calculating
code is here
__imageClip = createEmptyMovieClip("MyImage", this.getNextHighestDepth());
__canvasClip = createEmptyMovieClip("MyCanvas", this.getNextHighestDepth());
imageLoader = new MovieClipLoader();
imageLoader.addListener(mclListner);
mclListner.onLoadComplete = function():Void {
__fileWidth = _root.myLoader.__imageClip._width;
__fileHeight = _root.myLoader.__imageClip._height;
trace(__fileWidth);
};
imageLoader.loadClip(__fileName, this.__imageClip);
Faraz
OnLoadComplete Being Triggered Too Early
Hello, all...
I figure I'm doing something wrong here because the onLoadComplete trigger is being activated too early... and by too early I mean there's no delay at all... as soon as the frame plays it's being triggered instantly...
Code:
onLoadComplete("MainMovie")
{
gotoAndStop("Preloader",2);
}
I'm trying to make a preloading screen... I have a scene called "MainMovie" and one called "Preloader". I think the names are self-explanitory.
Any help would be greatly appreciated!!
[F8] _width Property And OnLoadComplete Problems
I'm trying to load an external jpeg. The order I want things to happen is this:
- Existing image fades out. If image doesn't exist, create a holder MC.
- Load jpeg in the transparent container MC.
- Once jpeg is loaded, resize background MC to create an 8 pixel border.
- Fade loaded jpeg in.
Everything works fine except that after onLoadComplete is called, the _width and _height properties of my loaded jpeg are 0. Thus the background is resized to 16x16, and not the size of the jpeg plus 16x16.
This is the first time I've used the MovieClipLoader class, so I may be way off on something. Any help and / or constructive criticism would be greatly appreciated.
PHP Code:
function introduceImage(img_loc) {
if (_root.main_site.content_module.image_mc.image == undefined) {
_root.main_site.content_module.image_mc.createEmptyMovieClip('image', 5);
_root.main_site.content_module.image_mc.image._x = 8;
_root.main_site.content_module.image_mc.image._y = 8;
_root.main_site.content_module.image_mc.image._alpha = 100;
trace('Image holder not present; create it');
}
var imgFadeOut:Tween = new Tween(_root.main_site.content_module.image_mc.image, "_alpha", Regular.easeOut, _root.main_site.content_module.image_mc.bg._alpha, 0, 0.2, true);
imgFadeOut.onMotionFinished = function() {
trace('* Old image faded out');
var mcLoader = new MovieClipLoader();
mcListener = new Object();
mcListener.onLoadComplete = function(target_mc) {
trace('* New image loaded');
bg_width = (_root.main_site.content_module.image_mc.image._width+16);
bg_height = (_root.main_site.content_module.image_mc.image._height+16);
var xResize:Tween = new Tween(_root.main_site.content_module.image_mc.bg, "_width", Regular.easeOut, _root.main_site.content_module.image_mc.bg._width, bg_width, 0.2, true);
var yResize:Tween = new Tween(_root.main_site.content_module.image_mc.bg, "_height", Regular.easeOut, _root.main_site.content_module.image_mc.bg._height, bg_height, 0.2, true);
yResize.onMotionFinished = function() {
var imgFadeIn:Tween = new Tween(_root.main_site.content_module.image_mc.image, "_alpha", Regular.easeOut, _root.main_site.content_module.image_mc.image._alpha, 100, 0.2, true);
};
};
mcListener.onLoadError = function(target_mc, errorCode) {
trace("ERROR CODE = "+errorCode);
};
mcLoader.addListener(mcListener);
mcLoader.loadClip(img_loc, _root.main_site.content_module.image_mc.image);
};
}
Tween Not Working In An .onLoadComplete Function?
Hello all - been a while since I've treaded these waters (like the new facelift, btw ). But now I've got something that's completely stumping me and I'm hoping one of you fine people can help me out.
I'm building a dynamic image gallery - got that part working. I read the contents of the database through php, push that data into flash with a LoadVars object, and then use the resultant data to pull the image off the server. I'm loading the images using a MovieClipLoader so I can have a preloader and - I was hoping - slightly more control. Here's the issue that I've come across -
This is code that loads the actual images -
ActionScript Code:
portImgsCat.onLoad = function():Void{
var j:Number = 0;
var k:Number = 1;
var thumbWide:Number = 130;
var thumbHigh:Number = 130;
var crY:Number = 0;
var crX:Number = 0;
for(i=0; i<portImgsCat.totRows; i++){
var crThumb:String = "thumb"+i;
var crLoc:String = "loc"+i;
var crID:String = "id"+i;
//create the scroller base for the portfolio thumbnails, if necessary...
rPane.createEmptyMovieClip("scroller", rPane.getNextHighestDepth());
//attach the thumbnails and set the id variable for each
rPane.scroller.attachMovie("thumbnail", [crThumb], rPane.getNextHighestDepth());
rPane.scroller[crThumb].imgID = portImgsCat[crID];
//take care of the onClick event for each thumbnail...
rPane.scroller[crThumb].onRelease = function():Void{
getImage(this.imgID);
}
tImg.addListener(thumbListener);
//load the thumbnail images...
tImg.loadClip("makeImage.php?img="+portImgsCat[crLoc], rPane.scroller[crThumb].imgHolder);
tImg.loadClip("makeImage.php?img="+portImgsCat[crLoc], rPane.scroller[crThumb].imgRef);
//position the thumbnails...
rPane.scroller[crThumb]._y = crY;
rPane.scroller[crThumb]._x = thumbWide * j;
// rPane.scroller[crThumb]._x = 675;
if(j < 4){
j++;
}else{
//reset positioning info on the next line down...
j = 0;
crY = (thumbHigh * k);
k++;
}
crX = thumbWide*j;
//duplicate the images for the "reflection"...
rPane.scroller[crThumb].imgRef._rotation = 180;
rPane.scroller[crThumb].imgRef._xscale = -100;
rPane.scroller[crThumb].imgRef._alpha = 40;
}
//create the masking for the scroller movie clip...
rPane.createEmptyMovieClip("masking", rPane.getNextHighestDepth());
rPane.masking.beginFill(0x000000, 0);
rPane.masking.lineTo(640, 0);
rPane.masking.lineTo(640, 640);
rPane.masking.lineTo(0, 640);
rPane.masking.lineTo(0, 0);
rPane.masking.endFill();
//set the scroller mask...
rPane.scroller.setMask(rPane.masking);
//add the scrollbars if the scroller movieclip is taller than the masking..
if(rPane.scroller._height >= 640){
rPane.attachMovie("scrollBar", "scrollBar", rPane.getNextHighestDepth());
rPane.scrollBar._x = 640;
rPane.scrollBar._y = 50;
//handle the click events for the scrollbar...
//up ->
rPane.scrollBar.dn.onPress = function():Void{
sclIt = setInterval(scrollDn, 10);
}
rPane.scrollBar.dn.onRelease = function():Void{
clearInterval(sclIt);
}
//down ->
rPane.scrollBar.up.onPress = function():Void{
sclIt = setInterval(scrollUp, 10);
}
rPane.scrollBar.up.onRelease = function():Void{
clearInterval(sclIt);
}
}
var portImgsCat:LoadVars = new LoadVars();
}
This is loading in all my images in perfect rows with the proper spacing between and the proper amount of images across. Yay. However, what I'd like to have is for the images (once they're done loading) slide in using a tween from the right of the screen. So, to test, I uncomment the line "rPane.scroller[crThumb]._x = 675;" and comment out the line "rPane.scroller[crThumb]._x = thumbWide * j;". So, now I've got all my thumbnails overlapping nicely off the edge of my stage.
Now the rest of the code -
ActionScript Code:
thumbListener.onLoadComplete = function(tgt:MovieClip){
eval(tgt)._parent.preloader.removeMovieClip();
new Tween([eval(tgt)._parent], "_x", mx.transitions.easing.Strong.easeOut, eval(tgt)._parent.x, 10, 2, true);
}
This does nothing. At all. The tween should work, right? Or has my cold finally eaten the last of my brain? I'm still on Flash MX Professional 2004, btw.
OnLoadComplete Events In AS2 Do Not Fire When Loaded Into AS3 ... ?
I am trying to load as AS2 swf (source unavailable) into an AS3 movie. Easy enough, but then I want to be able to invoke functions on the loaded AS2 swf, which is not easy becuase the AS3 and AS2 reside in different VMs as I understand it.
What I thought I would do is create a "wrapper" AS2 swf. The AS3 would load the wrapper and communicate with it via SWFBridge or similar. The wrapper AS2 would load the real AS2 swf, and simply pass any function calls received over the SWFBridge to it.
The first bit, loading the AS2 swf indirectly via a wrapper AS2 works, but I have run into a problem. I cannot set up the AS2 side of the SWFBridge, because the onLoadComplete event (for loading the target AS2 within the wrapper AS2) only fires when the wrapper is run in its own right. When the wrapper is run by loading it into the AS3, the event never fires (even though the external AS2 swf does load), so the bridge does not get set up, so the function calls cannot be made.
Somebody must have encountered this before so I ask, whats the solution or workaround, or is there a better way to do what Im trying to do?
Thanks for reading!
LoadClip>onLoadComplete>Tween Problem
Hey Guys and Gals-
I have a strange problem that has been bugging me and can figure it out.
Here is a sample of the code:
Quote:
import mx.transitions.Tween;
import mx.transitions.easing.*;
var loadListener:Object = new Object();
loadListener.onLoadComplete = function(target_mc:MovieClip, httpStatus:Number):Void {
trace(">> loadListener.onLoadComplete()");
trace(">> =============================");
trace(">> target_mc._width: "+target_mc._width);
trace(">> httpStatus: "+httpStatus);
trace("LOCATION: "+target_mc);
};
loadListener.onLoadInit = function(target_mc:MovieClip):Void {
trace(">> loadListener.onLoadInit()");
trace(">> =============================");
trace(">> target_mc._width: "+target_mc._width);
};
var logoLoader:MovieClipLoader = new MovieClipLoader();
logoLoader.addListener(loadListener);
//
var aItemName:Array = ["What", "When", "Where"];
var mcVideo:MovieClip;
var nDepth:Number;
//
for (var i:Number = 0; i<aItemName.length; i++) {
var speedObj = 1;
nDepth = 10+i;
mcVideo = this.attachMovie("sample_mc", "mcVideo"+i, nDepth);
var swfLoad:MovieClipLoader = new MovieClipLoader();
swfLoad.loadClip("../samples/"+aItemName[i]+".swf", mcVideo.swf_mc);
swfLoad.addListener(loadListener);
//
mcVideo._xscale = 10;
mcVideo._yscale = 10;
//
var mcVideoX:Tween = new Tween(mcVideo, "_x", Regular.easeInOut, -500, (i*70)+50, speedObj, true);
var mcVideoY:Tween = new Tween(mcVideo, "_y", Regular.easeInOut, -500, 370, speedObj, true);
var mcVideoA:Tween = new Tween(mcVideo, "_alpha", Regular.easeInOut, 50, 100, speedObj, true);
}
The problem is that I want to load all the images/swf before the Tween happens. So far I haven't figured out a way to make it Tween after loading. And yes I did try to put the Tween in the onLoadComplete function. It runs into a problem from the for loop. It wouldn't be a problem but, with it their is.
Maybe someone can think of a fix
To many days and lack of sleep I can't think of any right now.
Thx
Listener.onLoadComplete Wont Trigger GotoAndStop?
Hi
got the following code for a grid of thumbnails, everything seems to work fine but I want to tell a mc called grid_details_mc to display the items details as eack one loads then tell the grid_details_mc to gotoAndStop("off") when load is complete.
It is being 'turned on' by the mclListener.onLoadInit but wont turn off with the mclListener.onLoadComplete.
Can anyone tell me why not
Many thanks in advance
Code:
var itemSiteID:Number;
var itemGridID:Number = Number(this._name.slice(12, 14));
var gridItemImageURL:String = _parent.itemImageURL[itemGridID];
var itemName:String = _parent.itemNameArray[itemGridID];
var itemClient:String = _parent.itemClientArray[itemGridID];
var itemType:String = _parent.itemTypeArray[itemGridID];
var grid_item_holder:MovieClip;
//
var mclListener:Object = new Object();
mclListener.onLoadInit = function(grid_item_holder) {
_parent.grid_details_mc.gotoAndStop("on");
var mclProgress:Object = mcl.getProgress(grid_item_holder);
_parent.grid_details_mc.itemName.text = itemName;
_parent.grid_details_mc.itemClient.text = itemClient;
_parent.grid_details_mc.itemType.text = itemType;
};
//
mclListener.onLoadComplete = function(grid_item_holder) {
//THIS LINE IS NOT WORKING
_parent.grid_details_mc.gotoAndStop("off");
if (itemGridID<_root.grid.noOfItems) {
//THIS LINE IS NOT WORKING ALSO
_parent.grid_details_mc.gotoAndStop(1);
_root.grid.attachMovie("grid_item_mc", "grid_item_mc"+(itemGridID+1), (itemGridID+50));
}
grid_item_holder.onRollOver = function() {
//do stuff
};
mcl.removeListener(mclListener);
};
var mcl:MovieClipLoader = new MovieClipLoader();
mcl.addListener(mclListener);
mcl.loadClip(gridItemImageURL, grid_item_holder);
//
Newbie Loader Question...onloadComplete/Init?
I am making a simple image rotator but some images are taller than others. Depending on their height some show up at the top, while others show up half way down, so i need to set the loader's content to the top. I pretty sure i've figured this much out, except I know that I cannot access this until the image is loaded and here is where I run into my problem.
How do i know when the image has been loaded?
*topImage is the loader component in my movie*
I've tried:
Code:
var imageListener:Object = new Object();
topImage.addListener(imagewListener);
imageListener.onLoadComplete = function()
{
topImage.content._y = 0;
}
and also:
Code:
topImage.onLoadComplete = function()
{
topImage.content._y = 0;
}
I also tried both of those with onLoadInit and still didn't work. Please help, I need to find a solution asap.
MovieClipLoader OnLoadComplete For Multiple Loaded Images
I have made an mc containing a frame, a container and a small loading animation. And I have an array with urls to images, which will later be filled through xml. Each image needs to be loaded in a mc so they all have their own frame and preloader animation.
After an image is loaded the preloader must fade out and the image fade in. That's the part I can't get to work properly. With the code I have right now the tween only works for the last loaded image.
Code:
var aScreenshots:Array = new Array("projectimages/km_main.jpg", "projectimages/ipod_main.jpg", "projectimages/bdp_main.jpg");
for (var i:Number = 0; i < aScreenshots.length; i++) {
var mcProject:MovieClip = this.attachMovie("project", "project" + i, this.getNextHighestDepth(), {_x:Stage.width / 2, _y:i * 190});
var mclProjectLoader:MovieClipLoader = new MovieClipLoader();
var oProjectListener:Object = new Object();
mclProjectLoader.addListener(oProjectListener);
oProjectListener.onLoadStart = function(mcTarget:MovieClip) {
mcProject.mcLoadingAni._alpha = 100;
mcProject.mcContentContainer._alpha = 0;
}
oProjectListener.onLoadProgress = function(mcTarget:MovieClip, nLoaded:Number, nTotal:Number) {
// Eventueel loading bar
// trace(nLoaded + " van " + nTotal + " geladen");
}
oProjectListener.onLoadComplete = function(mcTarget:MovieClip) {
ZigoEngine.doTween(mcProject.mcLoadingAni, "_alpha", 0, 0.5, "easeOutExpo");
ZigoEngine.doTween(mcProject.mcContentContainer, "_alpha", 100, 0.8, "easeOutExpo", 0.5);
trace(mcTarget + " geladen");
}
mclProjectLoader.loadClip(aScreenshots[i], mcProject.mcContentContainer);
}
I hope you guys know what I mean . Any help appreciated.
Initiate Events With OnLoadComplete . Preload Images Sequently
Hi there,
I´m facing the end of my knowledge:
I got a Flash movie in which I need to load six images one after the other to make my preloader work because each picture should be indicated by a small square - blue if not yet loaded, yellow if loaded. It should like the static version that can be seen on www.aw-architektur.de .
In the first keyframe all the squares are blue and the first image is loaded. When done the movie should move on to frame number 6. I worked out the following script to initiate this event/action:
var mcl1:MovieClipLoader=new MovieClipLoader;
var listener1:Object=new Object();
listener1.onLoadComplete=function(target:MovieClip ) {
target._visible=false;
gotoAndPlay(6);
}
mcl1.addListener(listener1);
mcl1.loadClip("aktuell_1_1.jpg","bild1");
As you might have already guessed: It does not work. If I export the file the movie kind of randomly loads sometimes only one sometimes all the pictures, but always a) at once and b) without stopping in the preloader part.
So please you Flash-gurus out there, tell me what I´m doing wrong.
I attached the file as well. Don´t be irritated by the "5 frame" steps of the preloader part of the movie. Its just because I adapted a static version of the file to this dynamic one. And "bild" is just the german word for image. The empty movieclips "bild1, bild2, etc." are on layers Bild1 to Bild6.
Thanks for your answers in advance!
Martin
p.s.
because of the size limit of 300KB i had to compress first with rar and then with zip, sorry for this...
"onLoadComplete, Play" Plays Prematurely
I have a frame with a stop action up at the top. In the same frame, I have a JPEG dynamically load in. I want the movie to stop playing (except for a preloader animation) until the JPEG has completely downloaded, and then resume. I have the following code:
Code:
myListener.onLoadComplete = function (target_mc) {
play();
}
...but the movie executes the play command before the JPEG is done downloading. Why?
|