-
...dishing dimes on an .fla!
as2 movie height
Hi...
I'm building a vertical portfolio viewer which uses the below code to create my gallery. I'm loading the data externally via xml (which loads fine, so no problems there). The data which loads is a set of separate .swf files all of different sizes in height. The only thing I can't do is position the newly created .swf file right underneath the last one in the array, based on the height of said last .swf file.
The only way I can do it at the moment is per below, which duplicates my project clip (the clip which the .swf's load into) and places the next one right underneath the height of the actual project clip, not the height of the .swf being loaded into it.
Does anyone know how I can target the height of the external .swfs, and position the next one in the array right underneath the last one, based on the height of that last .swf, (so if at anypoint in the future the height changed, it would psition itself correctly).
code: // set up gallery...
setGallery = function () {
// Builds gallery projects menu based on XML Data...
for (i=0; i<total; ++i) {
// Build arrays...
image[i] = xmlNode.childNodes[i].attributes.Image;
// Build menu...
scroller.projectMC.project.duplicateMovieClip("pro ject"+i,i);
scroller.projectMC["project"+i].ID = i;
var listener:Object = new Object();
scroller.projectMC["project"+i]._y = (scroller.projectMC["project"+i]._height)*i;
// Load .swf's for each section...
loadMovie(image[i], scroller.projectMC["project"+i].holderMC.holder);
scroller.projectMC["project"+i].holder._alpha = 0;
}
Thanks in advance
Jeff
-
If you used the MovieClipLoader Class instead of loadMovie, your life would be easier.
You can get the height of the loaded swf in the onLoadInit handler. More info here.
gparis
-
...dishing dimes on an .fla!
Hi, thanks...
This is what I've got now for the above code, but all the .swf's load on top of each other at 0,0...
code: // set up gallery...
setGallery = function () {
// Builds gallery projects menu based on XML Data...
for (i=0; i<total; ++i) {
// Build arrays...
image[i] = xmlNode.childNodes[i].attributes.Image;
// Build menu...
scroller.projectMC.project.duplicateMovieClip("pro ject"+i,i);
scroller.projectMC["project"+i].ID = i;
///////////scroller.projectMC["project"+i]._y = (scroller.projectMC["project"+i]._height)*i;
// Load .swf's for each section...
/////////loadMovie(image[i], scroller.projectMC["project"+i].holderMC.holder);
scroller.projectMC["project"+i].holder._alpha = 0;
//set up MCL...
var mclListener:Object = new Object();
mclListener.onLoadInit = function(target_mc:MovieClip) {
scroller.projectMC["project"+i]._y = (scroller.projectMC["project"+(i-1)]._y)+(scroller.projectMC["project"+(i-1)]._height);
}
var loaderSwf:MovieClipLoader = new MovieClipLoader();
loaderSwf.addListener(mclListener);
loaderSwf.loadClip(image[i], scroller.projectMC["project"+i].holderMC.holder);
}
};
-
Did you debug your file? For instance, in the onLoadInit set a var for the images height and trace it.
You could also post a sample so others can try and debug it for you.
gparis
-
...dishing dimes on an .fla!
Hi...
I decided to revisit this problem, and I have this code now
code:
// set up gallery...
setGallery = function () {
// Builds gallery projects menu based on XML Data...
for (i=0; i<total; ++i) {
// Build arrays...
image[i] = xmlNode.childNodes[i].attributes.Image;
// Build menu...
var mclListener:Object = new Object();
var loaderSwf:MovieClipLoader = new MovieClipLoader();
mclListener.onLoadInit = function() {
var Y:Number = scroller.projectMC["project"+(i-1)]._y;
var H:Number = scroller.projectMC["project"+(i-1)]._height;
trace(Y+" "+H);
};
scroller.projectMC.project.duplicateMovieClip("pro ject"+i,i);
scroller.projectMC["project"+i].ID = i;
scroller.projectMC["project"+i].holder._alpha = 0;
loaderSwf.addListener(mclListener);
loaderSwf.loadClip(image[i], scroller.projectMC["project"+i].holderMC.holder);
}
};
Still get the same thing with the external .swf's loading ontop of each other but I get a trace result of 0 350 (y position and height, tracing out 6 times as I have 6 external swfs loading). However, each of those swf's has a different height, so they shuldn't all be 350...
This is driving me nutso here...can anyone shed any light / help please?
Thanks
Jeff
-
...dishing dimes on an .fla!
* bump
-
...dishing dimes on an .fla!
Hi...
I'm still struggling with this, and I know it should be able to be done, but I really can't figure it out...
After researching a little more, i've changed my code to this but it still doesn't do anything different, I just get all the externbal .swf's loading ontop of each other...
Any help is really appreciated. thanks in advance...
Jeff
code:
// set up gallery...
setGallery = function () {
// Builds gallery projects menu based on XML Data...
for (i=0; i<total; ++i) {
// Build arrays...
image[i] = xmlNode.childNodes[i].attributes.Image;
// Build menu...
scroller.projectMC.project.duplicateMovieClip("pro ject"+i,i);
scroller.projectMC["project"+i].ID = i;
scroller.projectMC["project"+i].holder._alpha = 0;
//set up MCL...
////MCL.unloadClip(contentMC);
lis.onLoadInit = function() {
scroller.projectMC["project"+i]._y = (scroller.projectMC["project"+(i-1)]._y)+(scroller.projectMC["project"+(i-1)]._height);
trace(scroller.projectMC["project"+(i-1)].holderMC.holder._height)
};
MCL.loadClip(image[i], scroller.projectMC["project"+i].holderMC.holder);
//scroller.projectMC["project"+i]._y = (scroller.projectMC["project"+(i-1)]._y)+(scroller.projectMC["project"+(i-1)]._height);
}
};
//new movieclip loader...
var MCL:MovieClipLoader = new MovieClipLoader();
var lis:Object = new Object();
MCL.addListener(lis);
-
Either post a sample fla (with just that code) & the xml in case there's one and/or post your trace results. It would be important to know what returns undefined.
gparis
-
...dishing dimes on an .fla!
-
...dishing dimes on an .fla!
Hi gparis...
I wondered if you'd had time to take a look at my file yet?
thanks for any help/ time you can offer
Jeff
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|