A Flash Developer Resource Site

Results 1 to 13 of 13

Thread: [F8] AttachMovie question for dragging windows

  1. #1
    Senior Member
    Join Date
    May 2004
    Posts
    322

    [F8] AttachMovie question for dragging windows

    Ok, I have a question rather than a problem here - what I want to do is create a draggable pop-up window showing information such as a graph or diagrams.

    What I have done is make the draggable window by creating a MC called 'dialogbox' and inside that there is a 'windowbar' MC (which has the dragging code on it) and another MC called 'content' (which is where the content will load.

    Now this all works fine, I can make the dialogbox popup and it is draggable: so that's great!

    What I want to do is to be able to choose what to load in the 'content' MC dynamically. So for instance, if I choose 'print' it will load the 'print' MC where 'content' MC should be. I would then resize the 'windowbar' and 'dialogbox' so everything looks right.

    The thing is I'm not sure how to pass the relevant info to the MC 'dialogbox'. If there were a function I could do something like:

    Code:
    showBox(print, dialogbox, x=300, y=300);
    But I don't know if that's possible or whether a better function already exists? So in other words I just want to load my own 'content' MC into the 'dialogbox' MC dynamically, and resize it to fit correctly.

    Any ideas how to do this???
    Everybody has a story to tell, what's yours? -- http://www.filmfiler.com

  2. #2
    All 1s and 0s dmonkey's Avatar
    Join Date
    Nov 2005
    Location
    Leeds, UK
    Posts
    606
    Hi,

    Load content into your content clip like this:

    code:

    dialogbox.content.attachMovie("print", "print1", 0);



    This will attach a movieclip called 'print' from the library into 'content'. Once you have done that, dialogbox will automatically resize to fit the content inside. The last problem then is to make the windowbar the correct length:

    code:

    dialogbox.windowbar._width = dialogbox.content._width;



    Does that help?
    "If I have seen further, it is by standing on the shoulders of giants." - Sir Isaac Newton

  3. #3
    Senior Member
    Join Date
    May 2004
    Posts
    322
    Thanks for the quick reply -

    Code:
    dialogbox.attachMovie("weeklychart", "weeklychart", this.getNextHighestDepth());
    I did the following and it just attaches a MC called 'weeklychart' to the 'dialogbox' MC.

    However-

    I deleted 'content' from 'dialogbox' because I thought 'weeklychart' could be attached directly to 'dialogbox' instead of into 'content'.

    So in order to resize the 'windowbar' I want it to be same size as 'weeklychart' (or whatever MC I attached).

    So I tried:

    Code:
    dialogbox.dragbar._width = dialogbox._width;
    But it don't work. The correct stuff shows, and it is still draggable, but the windowbar isn't the right size...

    Any ideas how I can reference the MC I have just attached to dialogbox?
    Everybody has a story to tell, what's yours? -- http://www.filmfiler.com

  4. #4
    All 1s and 0s dmonkey's Avatar
    Join Date
    Nov 2005
    Location
    Leeds, UK
    Posts
    606
    Hi,

    You can reference it with the name you gave it when you attached it:

    dialogbox.dragbar._width = dialogbox.weeklychart._width;

    Any good?
    "If I have seen further, it is by standing on the shoulders of giants." - Sir Isaac Newton

  5. #5
    Senior Member
    Join Date
    May 2004
    Posts
    322
    That's not working.. I've checked properties to make sure the linkage thing is on, I'm not too sure what else there could be to change/add??
    Everybody has a story to tell, what's yours? -- http://www.filmfiler.com

  6. #6
    All 1s and 0s dmonkey's Avatar
    Join Date
    Nov 2005
    Location
    Leeds, UK
    Posts
    606
    Could i see the .fla?
    "If I have seen further, it is by standing on the shoulders of giants." - Sir Isaac Newton

  7. #7
    Senior Member
    Join Date
    May 2004
    Posts
    322
    There's a lot of extra code and also xml files and png files so I'd have to zip it all and it's too big to attach here. Thanks for the offer - I really appreciate it as you're helping me in your own time but I'd rather just fix it without showing the file to anyone until its complete.

    Maybe you could do a simple example and I could check to see if I've done the same stuff???
    Everybody has a story to tell, what's yours? -- http://www.filmfiler.com

  8. #8
    Senior Member
    Join Date
    May 2004
    Posts
    322
    Has anyone else got this working?
    Everybody has a story to tell, what's yours? -- http://www.filmfiler.com

  9. #9
    All 1s and 0s dmonkey's Avatar
    Join Date
    Nov 2005
    Location
    Leeds, UK
    Posts
    606
    Hi,

    I did a quick trial and mine works fine. Here's the .fla.
    Attached Files Attached Files
    "If I have seen further, it is by standing on the shoulders of giants." - Sir Isaac Newton

  10. #10
    Senior Member
    Join Date
    May 2004
    Posts
    322
    Here's a copy of what I am doing - not sure why yours works and mine don't. This would be great if you could help figure this out...
    Attached Files Attached Files
    Everybody has a story to tell, what's yours? -- http://www.filmfiler.com

  11. #11
    All 1s and 0s dmonkey's Avatar
    Join Date
    Nov 2005
    Location
    Leeds, UK
    Posts
    606
    Hi,

    You haven't called the movieClip dragbar. You need to edit the movieClip 'window', select the dragbar clip, and give it the instance name 'dragbar'. Giving it a linkage name just means that you can identify it in the library. The linkage name will not allow you to access an instance of the movieClip inside a loaded clip.

    Hope this helps.
    "If I have seen further, it is by standing on the shoulders of giants." - Sir Isaac Newton

  12. #12
    Senior Member
    Join Date
    May 2004
    Posts
    322
    That's great - can't believe I missed that. Oh well

    I have another question related to this, do you know how I can move the 'close' button dynamically so it will be on the right side of the bar.

    I'm using the following code:

    Code:
    ok._x = dragbar.width - 30;
    But if I do the trace function for dragbar.width it says 'undefined'. I tried dialogbox.dragbar.width but that is undefined as well... how should I fix it?
    Everybody has a story to tell, what's yours? -- http://www.filmfiler.com

  13. #13
    All 1s and 0s dmonkey's Avatar
    Join Date
    Nov 2005
    Location
    Leeds, UK
    Posts
    606
    Hi,

    You want _width, not width.
    "If I have seen further, it is by standing on the shoulders of giants." - Sir Isaac Newton

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