Google
 
Webnews.only-4-geeks.com
Interesting places
news.only-4-geeks.com Forum Index » Flash - ActionScriptGoto page 1, 2  Next

onLoad??

 
Jump to:  
 
mr.nazarko
PostPosted: Sat Aug 16, 2008 11:21 pm    Post subject: onLoad??
       
hello -

ive managed to create a loop that loads some xml and images,
but im struggling with creating an 'onLoad' type event for this line of code
--- R1item.image_holder.loadMovie(R2photoURL[j]);

so when then the R2photoURL[j] is finally loaded an event will occur.

could someone point me in the right direction
what should i be using?

thanks,
anton.

var butterList:XML = new XML();
butterList.ignoreWhite = true;

var R1photoURL:Array = new Array();
var R1caption1:Array = new Array();
var R1caption2:Array = new Array();

var R2photoURL:Array = new Array();
var R2caption1:Array = new Array();
var R2caption2:Array = new Array();

butterList.onLoad = function(success) {
trace ("it worked!")
_global.R1 = this.firstChild.firstChild.childNodes
for (i=0; i < R1.length; i++) {
R1photoURL.push (R1[i].attributes.URL);
R1caption1.push (R1[i].attributes.caption1);
R1caption2.push (R1[i].attributes.caption2);
}

_global.R2 = this.firstChild.firstChild.nextSibling.childNodes
for (i=0; i < R2.length; i++) {
R2photoURL.push (R2[i].attributes.URL);
R2caption1.push (R2[i].attributes.caption1);
R2caption2.push (R2[i].attributes.caption2);
}
trace (R2.length)

j = 0;
while (j < R2.length)
{
trace (R2caption2[j])
R1item = _root.contentSpace.row1.attachMovie ("row1_holder","row1_holder" +
j, j + 8Cool;
R1item.caption2.text = R2caption2[j];
R1item.image_holder.loadMovie(R2photoURL[j]);
R1item._y = R1item._y + j * 495;
++j;
};

}

butterList.load("http://www.antonnazarko.com/butter/butter.xml");
 

 
kglad
PostPosted: Sun Aug 17, 2008 12:06 am    Post subject: Re: onLoad??
       
the movieclip onLoad() method only executes for movieclips that are in your
library and placed on-stage in the authoring environment.

it does not execute when a file is loaded into a target movieclip.

either use the onLoadInit() method of the moviecliploader class'es listener
object or create a loop and check the getBytesLoaded() and getBytesTotal()
methods of the target movieclip.
 

 
mr.nazarko
PostPosted: Sun Aug 24, 2008 4:33 am    Post subject: Re: onLoad??
       
hello --- thanks!

ive been trying to implement the onLoadInit using the help files -
see attached code:

but im obviusly doing something wrong.
any suggestions?

thank you,
anton.

var butterList:XML = new XML();
butterList.ignoreWhite = true;

var R1photoURL:Array = new Array();
var R1caption1:Array = new Array();
var R1caption2:Array = new Array();

var R2photoURL:Array = new Array();
var R2caption1:Array = new Array();
var R2caption2:Array = new Array();

butterList.onLoad = function(success) {
trace ("it worked!")
_global.R1 = this.firstChild.firstChild.childNodes
for (i=0; i < R1.length; i++) {
R1photoURL.push (R1[i].attributes.URL);
R1caption1.push (R1[i].attributes.caption1);
R1caption2.push (R1[i].attributes.caption2);
}

_global.R2 = this.firstChild.firstChild.nextSibling.childNodes
for (i=0; i < R2.length; i++) {
R2photoURL.push (R2[i].attributes.URL);
R2caption1.push (R2[i].attributes.caption1);
R2caption2.push (R2[i].attributes.caption2);
}
trace (R2.length)

j = 0;
while (j < R2.length)
{
trace (R2caption2[j])
R1item = _root.contentSpace.row1.attachMovie ("row1_holder","row1_holder" +
j, j + 8Cool;
R1item.caption2.text = R2caption2[j];

var mclListener:Object = new Object();
mclListener.onLoadStart = function(target_mc:MovieClip) {
trace ("start");
};

mclListener.onLoadComplete = function(target_mc:MovieClip) {
trace ("complete!!");
};

mclListener.onLoadInit = function(target_mc:MovieClip) {
trace ("loading");
};


R1item.image_holder.addListener(mclListener);
R1item.image_holder.loadMovie(R2photoURL[j]);
R1item._y = R1item._y + j * 750;
++j;
};

}
 

 
kglad
PostPosted: Sun Aug 24, 2008 5:26 am    Post subject: Re: onLoad??
       
you need to use a moviecliploader instance if you want to use methods of its
listener (like onLoadStart, onLoadComplete and onLoadInit).

check the flash help files for how to use the moviecliploader.
 

 
mr.nazarko
PostPosted: Sun Aug 24, 2008 1:56 pm    Post subject: Re: onLoad??
       
thanks!
works perfectly!
 

 
mr.nazarko
PostPosted: Sun Aug 24, 2008 6:54 pm    Post subject: Re: onLoad??
       
hello --
although the onLoadInit is working fine - i have run into another problem.

the mclListener is called during a loop,
by the time all images are loaded the mcLoader and mclListener.onLoadComplete
will only effect the last movie loaded.

im trying to set up a mclListener that will work with every cycle --
var mclListener[j]:Object = new Object();

but it doesnt work.

do you have any advice?
thanks again - i really appreciate the help.











var butterList:XML = new XML();
butterList.ignoreWhite = true;

var R1photoURL:Array = new Array();
var R1caption1:Array = new Array();
var R1caption2:Array = new Array();

var R2photoURL:Array = new Array();
var R2caption1:Array = new Array();
var R2caption2:Array = new Array();

butterList.onLoad = function(success) {
trace ("it worked!")
_global.R1 = this.firstChild.firstChild.childNodes
for (i=0; i < R1.length; i++) {
R1photoURL.push (R1[i].attributes.URL);
R1caption1.push (R1[i].attributes.caption1);
R1caption2.push (R1[i].attributes.caption2);
}

_global.R2 = this.firstChild.firstChild.nextSibling.childNodes
for (i=0; i < R2.length; i++) {
R2photoURL.push (R2[i].attributes.URL);
R2caption1.push (R2[i].attributes.caption1);
R2caption2.push (R2[i].attributes.caption2);
}
trace (R2.length)

j = 0;
while (j < R2.length)
{
trace (R2caption2[j])
R1item = _root.contentSpace.row1.attachMovie ("row1_holder","row1_holder" +
j, j + 8Cool;
R1item.caption2.text = R2caption2[j];

var mclListener:Object = new Object();

mclListener.onLoadStart = function(target_mc:MovieClip) {
trace ("start");
};

mclListener.onLoadComplete = function(target_mc:MovieClip) {
R1item._alpha = 50
trace ("complete");
};

mclListener.onLoadInit = function(target_mc:MovieClip) {

trace ("oninit");
};



var mcLoader:MovieClipLoader = new MovieClipLoader();
mcLoader.addListener(mclListener);
mcLoader.loadClip((R2photoURL[j]),R1item.image_holder);


//R1item.image_holder.loadMovie(R2photoURL[j]);
R1item._y = R1item._y + j * 750;
++j;
};

}

butterList.load("http://www.antonnazarko.com/butter/butter.xml");
 

 
kglad
PostPosted: Sun Aug 24, 2008 10:25 pm    Post subject: Re: onLoad??
       
var mclListener:Object = new Object();

var mcLoader:MovieClipLoader = new MovieClipLoader();
mcLoader.addListener(mclListener);

should be outside your while-loop.
 

 
mr.nazarko
PostPosted: Thu Aug 28, 2008 7:48 pm    Post subject: Re: onLoad??
       
Hello ?
i have tried you suggestions without luck,
the mclListener.onLoadStart, onLoadComplete ect will only affect the last
movie loaded into the movieClipLoader.

I think i have to create a new instance of the movieClipLoader for each pass
in the with loop - but not sure how.

the website can be viewed here
LINK

do you have any more advice?



var butterList:XML = new XML();
butterList.ignoreWhite = true;

var R1photoURL:Array = new Array();
var R1caption1:Array = new Array();
var R1caption2:Array = new Array();

var R2photoURL:Array = new Array();
var R2caption1:Array = new Array();
var R2caption2:Array = new Array();

butterList.onLoad = function(success) {
trace ("it worked!")
_global.R1 = this.firstChild.firstChild.childNodes
for (i=0; i < R1.length; i++) {
R1photoURL.push (R1[i].attributes.URL);
R1caption1.push (R1[i].attributes.caption1);
R1caption2.push (R1[i].attributes.caption2);
}

_global.R2 = this.firstChild.firstChild.nextSibling.childNodes
for (i=0; i < R2.length; i++) {
R2photoURL.push (R2[i].attributes.URL);
R2caption1.push (R2[i].attributes.caption1);
R2caption2.push (R2[i].attributes.caption2);
}
trace (R2.length)

var mclListener:Object = new Object();
var mcLoader:MovieClipLoader = new MovieClipLoader();
mcLoader.addListener(mclListener);

j = 0;
while (j < R2.length)
{
trace (R2caption2[j])
R1item = _root.contentSpace.row1.attachMovie ("row1_holder","row1_holder" +
j, j + 8Cool;
R1item.caption2.text = R2caption2[j];

mclListener.onLoadStart = function(target_mc:MovieClip) {
trace ("start");
};

mclListener.onLoadComplete = function(target_mc:MovieClip) {
R1item._alpha = 50
trace ("complete");
};

mclListener.onLoadInit = function(target_mc:MovieClip) {

trace ("oninit");
};


mcLoader.loadClip((R2photoURL[j]),R1item.image_holder);


//R1item.image_holder.loadMovie(R2photoURL[j]);
R1item._y = R1item._y + j * 750;
++j;

};

}

butterList.load("http://www.antonnazarko.com/butter/butter.xml");
 

 
mr.nazarko
PostPosted: Tue Sep 02, 2008 1:41 am    Post subject: Re: onLoad??
       
Hello -
ive been struggling with this all week trying to find a solution.
i followed your instructions - but unfortunately i the mclListener will only
effect the last mcLoaded loaded.

do you have another suggestion?

thank you,
anton,







var butterList:XML = new XML();
butterList.ignoreWhite = true;

var R1photoURL:Array = new Array();
var R1caption1:Array = new Array();
var R1caption2:Array = new Array();

var R2photoURL:Array = new Array();
var R2caption1:Array = new Array();
var R2caption2:Array = new Array();

butterList.onLoad = function(success) {
trace ("it worked!")
_global.R1 = this.firstChild.firstChild.childNodes
for (i=0; i < R1.length; i++) {
R1photoURL.push (R1[i].attributes.URL);
R1caption1.push (R1[i].attributes.caption1);
R1caption2.push (R1[i].attributes.caption2);
}

_global.R2 = this.firstChild.firstChild.nextSibling.childNodes
for (i=0; i < R2.length; i++) {
R2photoURL.push (R2[i].attributes.URL);
R2caption1.push (R2[i].attributes.caption1);
R2caption2.push (R2[i].attributes.caption2);
}
trace (R2.length)

var mclListener:Object = new Object();
var mcLoader:MovieClipLoader = new MovieClipLoader();
mcLoader.addListener(mclListener);

mclListener.onLoadStart = function(target_mc:MovieClip) {
trace ("start");
};

mclListener.onLoadComplete = function(target_mc:MovieClip) {
R1item._alpha = 50
trace ("complete");
};

mclListener.onLoadInit = function(target_mc:MovieClip) {

trace ("oninit");
};

j = 0;
while (j < R2.length)
{
trace (R2caption2[j])
R1item = _root.contentSpace.row1.attachMovie ("row1_holder","row1_holder" +
j, j + 8Cool;
R1item.caption2.text = R2caption2[j];
mcLoader.loadClip((R2photoURL[j]),R1item.image_holder);
//R1item.image_holder.loadMovie(R2photoURL[j]);
R1item._y = R1item._y + j * 750;
++j;

};

}

butterList.load("http://www.antonnazarko.com/butter/butter.xml");
 

 
kglad
PostPosted: Tue Sep 02, 2008 3:09 am    Post subject: Re: onLoad??
       
well, what is it you expect them to do?

they execute for each item loaded. but when the first onLoadComplete executes
R1item is going to reference

_root.contentSpace.row1["row1_holder","row1_holder" + (R2.length-1)]

because the while loop completes execution before the first load even starts.

to remedy, use a relative path from the target movieclip (R1item.image.holder)
to R1item. ie,

target._parent._parent.
 

Page 1 of 2 .:. Goto page 1, 2  Next

Google
 
Webnews.only-4-geeks.com

Windows Update | C++ | C | PHP | JavaScript | Photoshop | Programming | Windows 2000 | Python | Windows XP | Object | Flash | Flash - ActionScript | Paint Shop Pro | Excel | PowerPoint | Access | Word | Windows 98 | Internet Explorer 6.0 | CorelDraw12 | Java | XML | asm x86 | Linux Mandrake | Linux RedHat | Outlook |  | news from newsgroups |_ | s

Web Templates

Awesome Website Templates ©

pasy ciążowe Kasia Wilk Portal Miasteczko dolnoslaskie konta studenckie Rijana