-
MX2004Pro - Y position dependant on objects height
Hi there...
This should be easy but I'm having difficultly figuring it out:
I have two MC's OjbectA & OjbectB,
OjbectA (a box) shifts in height.
I want ObjectB's Y position to stay centered on the halfway point of OjbectA no matter what size it shifts to.
This code below is wrong but I should be close shouldn't I?
OjbectB._y = OjbectA.height/2;
Thanks
-
I think you want "OjbectA._height" instead of "OjbectA.height".
B's y at A's center would be:
B._y = (A._height/2) + A._y;
If you want B to be centered on A it would be:
B._y = (A._height/2) - (B._height/2) + A._y;
-
Awesome.. that works... Here's the tricky part.
Remember ObjectA is a box...
We got the vertical axis down, now I'm trying to get objectB to sit on the right handside ( i.e. ---------[] ) no matter what size this box shifts to.
Any ideas?
-B
-
code:
onEnterFrame = function(){
B._x = A._x + A._width;
}
-
lol...you seriously rock!
-
Thanks so much that's Awesome... That was for next and back buttons that sit on each side of a box that shifts around and loads different swf's into it.
This may be getting more complicate but what is a good why of saying:
(This would be for a next button)
on (release){
if themoviethatsloadedinto"container" = "picture1.swf"
load "picture2.swf"
if it's "picture2.swf"
load "picture3.swf"
if it's "picture3.swf"
load "picture4.swf"
etc, etc, etc...
-
I'd use an array to store all the mc names and a variable to store the current index.
so:
code:
var pics = new Array("pic1.swf", "pic2.swf", ....);
var currPic = 0;
container.loadMovie(pics[0]);
button.onRelease = function(){
if(currPic + 1 < pics.length){
container.loadMovie(pics[++currPic]);
}
}
-
now instead an array of .swf to load... Can you make an array of functions to perform?
-
sure:
code:
function foo1(){}
function foo2(){}
function foo3(){}
var foos = new Array(foo1, foo2, foo3);
//call foo1
foos[0]();
//call foo2
foos[1]();
//call foo3
foos[2]();
-
There are 20 images in this gallery and the viewer can jump in and view the gallery (thus the array) at any point, so I think I still need to be able to retrieve the name of the loaded .swf out of "container" then perform a funtion depending on the result.
The function "picture2()" adjusts the background box to a different size and loads in the new swf.
For example:
on(release){
var currPic = _root.container.MovieClip = "";
next.onRelease = function(){
if(currPic = "picture1.swf"){
_root.picture2();
}
}
}
I'm not sure how to write the "var currPic"
-
-
The array of funtions would work if you could retrieve the current movie loaded "picture15.swf" then go back, or to the next image from there...
-
you could use two arrays, one for functions and one for names.
so:
code:
var pics = new Array("pic1.swf", "pic2.swf", ....);
var funcs = new Array("foo1", "foo2", ....);
var currPic = 0;
container.loadMovie(pics[0]);
buttonNext.onRelease = function(){
if(currPic + 1 < pics.length){
++currPic;
funcs[currPic]();
container.loadMovie(pics[currPic]);
}
}
buttonPrev.onRelease = function(){
if(currPic - 1 > pics.length){
--currPic;
funcs[currPic]();
container.loadMovie(pics[currPic]);
}
}
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
|