A Flash Developer Resource Site

Page 1 of 3 123 LastLast
Results 1 to 20 of 57

Thread: loadmovie checking ...

  1. #1
    Member
    Join Date
    Jul 2003
    Location
    Brampton, ONT
    Posts
    50

    loadmovie checking ...

    Hi, I just wanted to know if theres a way to have a script check if my emptyMc contains a movieMc and if so, unload it ..


    >>Heres the Scenario:...

    I currently have a mainMc calling a menuMc which in turn calls in other sectionMc(s), now, when I just put this script on my frame

    _root.sectionMc.unloadMovie();

    I get an error saying can't locate file, which is understandable because the file (swf) isn't loaded on the sectionMc unless I ..


    on (release) {
    gotoAndPlay("section");
    }
    on (release) {
    _root.sectionMc.loadMovie("section.swf");
    }


    Keeping in mind that I have multiple sectionMc(s) [with specificMc names] that my menuMc is calling into which are located in my mainMc, can I have the code do a check and see if the sectionMc(s) are empty or not? and if they are loaded to unload them?

    on that note: is it advisable to have the sectionMc(s) loading on one emptyMc or specificMc(s) like I have?

  2. #2
    Banned by DP
    Join Date
    Jul 2003
    Location
    Love Valley, NC
    Posts
    18
    Why do you need to check if it exists?

    Can't you just unload it and do a try/catch to make sure it doesn't throw an error? (does AS have try and catch?)

  3. #3
    Member
    Join Date
    Jul 2003
    Location
    Brampton, ONT
    Posts
    50

    what I need to check is ...

    Because once the user clicks on the menuMc, I want the MS to check if the sectionMc that the user is requesting is loaded or not .. if loaded, unload whats not needed.

    I have tried to have the other sectionMc(s) unload regardless,

    _root.sectionMc1.unloadMovie();
    _root.sectionMc2.unloadMovie();
    _root.sectionMc4.unloadMovie();
    stop();

    and in the code I remove the line which unloads the movie I'm loading .. in this example ...

    _root.sectionMc3.unloadMovie();

    but which like I explained, shows the error: because the other sectionMc(s) don't exist, hence the error and the concern


    hope this makes sense ..

  4. #4
    Banned by DP
    Join Date
    Jul 2003
    Location
    Love Valley, NC
    Posts
    18
    Oh..ic

    Hmm..well I don't know too much Action Script/Flash M

    Maybe someone else will know.

  5. #5
    Junior Member
    Join Date
    Jul 2003
    Location
    Los Angeles
    Posts
    24
    Hey Jesseyn,

    This should help you out a bit:

    checkForSectionMc = function(){
    if (_root.sectionMc) {
    trace("_root.sectionMc exists");
    _root.sectionMc.unloadMovie();
    }
    }

    yourButton.onRelease = function(){
    checkForSectionMc();
    _root.sectionMc.loadMovie("section.swf");
    this.gotoAndPlay("section");
    }

    Donnie
    pixelrot.com

  6. #6
    Member
    Join Date
    Jul 2003
    Location
    Brampton, ONT
    Posts
    50

    thanks Donnie

    awesome site by the way .. nice design ..

    back to biz .. >>

    I understand your code .. neat idea .. I'm adding it right now to my site ...

    I'll post my results

  7. #7
    Junior Member
    Join Date
    Jul 2003
    Location
    Los Angeles
    Posts
    24

    Thank you...

    Hey thanks,
    The site sure helped me out when I was looking for work. Took awhile, and still not done.
    Definitely let me know if the code works, if it doesn't I'll try to figure it out again.

    Donnie
    Pixelrot.com

  8. #8
    Member
    Join Date
    Jul 2003
    Location
    Brampton, ONT
    Posts
    50

    guess what!?

    I used the code you gave me in an if statement .. and it works great!! .. believe me I had my doubts .. heres what I did ..

    put this:
    checkForSectionMc = function(){
    if (_root.sectionMc) {
    trace("_root.sectionMc exists");
    _root.sectionMc.unloadMovie();
    }

    as an else if code to add ALL the other sections

    and I added this on the buttons:

    yourButton.onRelease = function(){
    checkForSectionMc();
    _root.sectionMc.loadMovie("section.swf");
    this.gotoAndPlay("section");
    }

    Just like you said .. wow .. blew me away ... a little debuggin here and there .. but it looks great ..

    THANKS MAN!!!

    hey give me your contacts .. I'll send you my complete work when I'm done ..

  9. #9
    Junior Member
    Join Date
    Jul 2003
    Location
    Los Angeles
    Posts
    24

    doubt eh?

    not a prob, I'm glad that it worked for you, once I started to code like that everything became a whole lot easier. doubtin me eh? haha, I can see I guess... complete stranger givin ya code.

    You know that you can block all your code into the first frame of the Movie and the button function will work there too, you don't have to put the function in the button actions panel anymore.

    It's a nice new feature, able to have all your code in one place.

    You can contact me directly from my site, and I think that all the rest of my stuff is in my profile on this forum. I'd love to see some more of your stuff, lemme know if I can help in anyway...

    Donnie
    pixelrot.com

  10. #10
    Member
    Join Date
    Jul 2003
    Location
    Brampton, ONT
    Posts
    50

    one quick question...

    is there a way I could 'stall' the loadingMc until the other remaininMc is being unloaded?

    kinda like a waituntil() scenario ..

    It all seems to load and unload toooo fast .. need to slow things down alittle ..

    thanks

  11. #11
    Junior Member
    Join Date
    Jul 2003
    Location
    Los Angeles
    Posts
    24
    I think this is what you mean:

    waitUntil = function(){
    _root.sectionMc.unloadMovie();
    this.onEnterFrame = function(){
    _root.sectionMc.onUnload = function(){
    delete this.onEnterFrame;
    trace("your movie has been unloaded");
    _root.sectionMc.loadMovie("section.swf");
    };
    };
    }

    kinda weird but I hope it helps...

    Donnie
    pixelrot.com

  12. #12
    Member
    Join Date
    Jul 2003
    Location
    Brampton, ONT
    Posts
    50

    quick Q

    Hey Donnie

    I notice you frequently use the trace() function ... what exactly does it do?

  13. #13
    Junior Member
    Join Date
    Jul 2003
    Location
    Los Angeles
    Posts
    24
    Jesseyn

    Oh, lol... It will actually display the results in your "output" screen. Once your code works I usualy take it out of the code. Just there for commenting and making sure you get what you desire out of the program.

    Donnie

  14. #14
    Member
    Join Date
    Jul 2003
    Location
    Brampton, ONT
    Posts
    50

    hahah .. brain fart

    Hey Donnie

    .. thanks for bearing with me ..

    I'm in the process of adding this script to an if statement .. .. I'll let you know how it goes ..

  15. #15
    Member
    Join Date
    Jul 2003
    Location
    Brampton, ONT
    Posts
    50

    a little help Donnie

    Originally posted by pixelrot
    I think this is what you mean:

    waitUntil = function(){
    _root.sectionMc.unloadMovie();
    this.onEnterFrame = function(){
    _root.sectionMc.onUnload = function(){
    delete this.onEnterFrame;
    trace("your movie has been unloaded");
    _root.sectionMc.loadMovie("section.swf");
    };
    };
    }

    >>I'm using an if statement to load and unload the movies .. how can I use the above in an if statement?

    if (_root.events) {
    trace("_root.events");
    _root.sections.unloadMovie();
    } else {
    if (_root.career) {
    trace("_root.career");
    _root.sections.unloadMovie();
    }..and so on and so on ..

    Whatchu think I should do?

    kinda weird but I hope it helps...

    Donnie
    pixelrot.com

  16. #16
    Junior Member
    Join Date
    Jul 2003
    Location
    Los Angeles
    Posts
    24
    Jesseyn,

    ...no prob, I hope that everything works well for you. I remember when I first started to code heavily with actionscript. It get a lot easier

    Donnie

  17. #17
    Junior Member
    Join Date
    Jul 2003
    Location
    Los Angeles
    Posts
    24
    waitUntil = function(arg){
    _root[arg].unloadMovie();
    this.onEnterFrame = function(){
    _root[arg].onUnload = function(){
    delete this.onEnterFrame;
    trace("your movie has been unloaded");
    _root[arg].loadMovie("section.swf");
    };
    };
    }
    if (_root.events) {
    trace("_root.events");
    waitUntil("sections");
    } else {
    if (_root.career) {
    trace("_root.career");
    waitUntil("sections");
    }


    I think that should do it... use the function to unload your movies... the _root[arg].loadMovie("section.swf") can be deleted or replaced

  18. #18
    Member
    Join Date
    Jul 2003
    Location
    Brampton, ONT
    Posts
    50

    wow! ..

    I'll give it a whirl and let you know how it goes .. I got a headache last week from all the coding and debugging! .. lol ..

    Donnie, can't thank you enough!!


    here goes .....

  19. #19
    Junior Member
    Join Date
    Jul 2003
    Location
    Los Angeles
    Posts
    24

    no thanks necessary

    Jesseyn,

    Yea, definitely let me know if it works, also if you have any errors feel free to e-mail me about it. I wrote the code real fast and I didn't write it in the actions panel, so it could have a bug that I over looked... if not then, great!

    No need to thank me, I'm just tryin to help out a little. I know how it feels to be lost as hell in a program with little or no help.

    Donnie

  20. #20
    Member
    Join Date
    Jul 2003
    Location
    Brampton, ONT
    Posts
    50

    hey donnie

    tis been a while since my last post .. I completely moved my code around and it all works perfect ..

    Remember how I had my if statement on my frames? I moved them to my buttons, and it working great.

    Now, if you can break this down for me ..

    waitUntil = function(arg){
    _root[arg].unloadMovie();
    this.onEnterFrame = function(){
    _root[arg].onUnload = function(){
    delete this.onEnterFrame;
    trace("your movie has been unloaded");
    _root[arg].loadMovie("section.swf");
    };
    };

    What exactly is happening here?

    my if statements are checking the loadedMc and the IF Statement checks it and unloads it ..this we have solved ..

    now, how do I add your waitUntil into my if statement?

    checkForSectionMc = function () {
    if (_root.home) {
    trace("_root.home");
    _root.home.unloadMovie();
    } else {
    if (_root.mbaevents) {
    trace("_root.mbaevents");
    _root.mbaevents.unloadMovie();
    } else {
    ....this goes on until it lists all my sectionMcs

    Hope I made sense, its a jungle out here!

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