A Flash Developer Resource Site

Results 1 to 13 of 13

Thread: MX2004Pro - Y position dependant on objects height

  1. #1
    Senior Member
    Join Date
    Feb 2004
    Location
    British Columbia, Canada
    Posts
    119

    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

  2. #2
    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;
    stuff and other stuff

  3. #3
    Senior Member
    Join Date
    Feb 2004
    Location
    British Columbia, Canada
    Posts
    119
    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

  4. #4
    code:

    onEnterFrame = function(){
    B._x = A._x + A._width;
    }

    stuff and other stuff

  5. #5
    Senior Member
    Join Date
    Feb 2004
    Location
    British Columbia, Canada
    Posts
    119
    lol...you seriously rock!

  6. #6
    Senior Member
    Join Date
    Feb 2004
    Location
    British Columbia, Canada
    Posts
    119
    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...

  7. #7
    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]);
    }
    }

    stuff and other stuff

  8. #8
    Senior Member
    Join Date
    Feb 2004
    Location
    British Columbia, Canada
    Posts
    119
    now instead an array of .swf to load... Can you make an array of functions to perform?

  9. #9
    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]();


    stuff and other stuff

  10. #10
    Senior Member
    Join Date
    Feb 2004
    Location
    British Columbia, Canada
    Posts
    119
    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"

  11. #11
    Senior Member
    Join Date
    Feb 2004
    Location
    British Columbia, Canada
    Posts
    119
    Hope that makes sense?!

  12. #12
    Senior Member
    Join Date
    Feb 2004
    Location
    British Columbia, Canada
    Posts
    119
    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...

  13. #13
    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]);
    }
    }

    stuff and other stuff

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  




Click Here to Expand Forum to Full Width

HTML5 Development Center