A Flash Developer Resource Site

Results 1 to 9 of 9

Thread: [RESOLVED] Problem retrieving height of MC inside an MC

  1. #1
    Member
    Join Date
    Nov 2005
    Posts
    68

    [RESOLVED] Problem retrieving height of MC inside an MC

    Hi,

    in FlashMX 2004 i'm trying to make a scrollbar for a couple of thumbnail images. More images can be added later, so i wanted to make it so that the scrollbar is always right.
    I made a MC "window" and inside an masked MC "content".
    If the user scrolls down, the content mc scrolls up. This should be by the same amount as is scrolled down multiplied by the proportion between the scrollbar and the content MC.
    This works fine if i put the height of the content MC in the AS code, but if i try to call the heigth with :

    this._parent.window.content._height

    i get 0 as result.
    I tried to call the heigth of the window MC, and this works.

    Anyone an idea ?

    thx,

    B
    Last edited by banshee007; 08-07-2008 at 09:55 AM.

  2. #2
    Getting There! bitsk308's Avatar
    Join Date
    Jul 2000
    Location
    Phoenix, AZ
    Posts
    427
    Hello Banshee

    I've just finished figuring this out for myself, I made some edits to your .fla, figured that'd be easier than explaining everything. I made a couple mods to be aware of. I moved the registration points to center and to for the scroller and the balk mcs, makes the math easier to look at. also i made the scroller resize to take up an appropriate percentage of the balk, to match the percentage of the inhoud visible at any given time in the venster. Let me know if you have any questions.

    _b
    Last edited by bitsk308; 01-10-2008 at 01:32 PM.

  3. #3
    Member
    Join Date
    Nov 2005
    Posts
    68
    Hi _b,

    thx man, great solution !

    But i wonder what was wrong with my code ?
    I replaced ur "_root.venster.inhoud._height"
    with "this._parent.venster.inhoud._height"
    and it worked.
    But i my original movie it seems i cannot get the _height.
    A bug ?

    again, thx,

    B

  4. #4
    Getting There! bitsk308's Avatar
    Join Date
    Jul 2000
    Location
    Phoenix, AZ
    Posts
    427
    Banshee, your code may actually work, I honestly didn't try to rework yours. Like I said I just stuffed my solution in there instead, but upon looking at your again, this line of code:

    this._parent.venster.inhoud._height

    is nowhere in you function, not even in the commented out line. Obviously you can't achieve the desired effect without this info. I have a feeling you put a _y in there instead of _height. Double check your code and see if you can't work it out, it's more fun when you can make your own method work. Anyhow, let me know how it goes.

    _b

  5. #5
    Member
    Join Date
    Nov 2005
    Posts
    68
    oops, sorryn posted the wrong fla

    in the original version there was a code :

    trace("inhoud-height : "+ this._parent.venster.inhoud._height);

    which always returned : 0

    But now i think i found were the problem is :

    if the photos are already inside the "inhoud" mc the _height can be called upon. But in my original movie i load the photos :

    loadMovie("000-small.jpg","foto1");

    this happens in the timeline of the "inhoud" mc.

    So at the time that the _height is requested, there isn't anything inside yet , so the heigth is : 0

    I'll have to find another way...

    thx for the help !

    tchau,

    B
    Last edited by banshee007; 08-07-2008 at 09:55 AM.

  6. #6
    Getting There! bitsk308's Avatar
    Join Date
    Jul 2000
    Location
    Phoenix, AZ
    Posts
    427
    Alright, this isn't the most pretty, but it works.

    The cleaner version would be to load your clips with the .MovieClipLoader class, so you could actually initiate commands when the image is done loading. As it is these images are small enough to load very quickly, so it's not a huge deal. The onClipEvent(data) on each target mc pushes an array on the root bigger by one, so that when each clip has started to load, the array is the length of as many clips as you have, in this case 10. An onEnterFrame loop is waiting for that array to be full size, and when it is, THEN the script runs to determine the scrolling attributes based of the size of the inhoud. Hope this is clear, the .fla is reworked again and commented.


    _b
    Last edited by bitsk308; 01-10-2008 at 01:32 PM.

  7. #7
    Member
    Join Date
    Nov 2005
    Posts
    68
    Thx again man, this is better than i ever imagined!
    If u are interested, i'll send an url when the site is finished.
    tchau,

    B

  8. #8
    Getting There! bitsk308's Avatar
    Join Date
    Jul 2000
    Location
    Phoenix, AZ
    Posts
    427
    Please do, I'd love to see how it turns out.
    Take Care

    _b

  9. #9
    Member
    Join Date
    Nov 2005
    Posts
    68

    site ready !

    Hey man,

    the site is finished !

    take a look at :

    http://www.line-grypdonck.be

    Thx for the help !

    tchau

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