A Flash Developer Resource Site

Results 1 to 7 of 7

Thread: Loading .external .swf files proficiently-Is there a different way?

  1. #1
    Master Of The Universe EvilKnevil's Avatar
    Join Date
    Jul 2001
    Location
    Ontario, Canada.
    Posts
    254

    Thumbs up Loading .external .swf files proficiently-Is there a different way?

    Ok...

    I have a main.swf - In it are approximately 6 buttons. This main.swf file is like a main menu.

    Each button clip has actions similar to this:


    on (rollOver) {loadMovie('somethingtext.swf','holder');
    }

    on (release) {nextScene();

    }

    on (release) {loadMovie('somethingmain.swf' ,'holder_contents');
    }



    *So when you rollover a button it shows an .swf telling what the 'somethingmain.swf' is about.

    If it is clicked and released it loads 'somethingmain.swf' in the nextscene in its target area.

    **That all works fine to this point.

    Is this proficient way to write this code though?? Is there a better way??



    MY PROBLEM ***

    I now have come to a point where I have loaded a .swf into a scene----BUT--- This .swf file has buttons.

    I need these buttons to allow me to Load a new .swf file when clicked.
    I also need a 'button' that will take me back to the menu when clicked and clear the current .swf.



    **I apologise if this is difficult to understand. I am just thinking there must be a proficient way to write this code and keep things organised well?

    I hope someone can give me some ideas...I am getting a bit confused with trying to organize this properly.


    Thanks so much...
    "Ride It Like Ya Stole It!'

    Preschool Learning Activities

    Flash Cartoons

  2. #2
    Senior Member whispers's Avatar
    Join Date
    Mar 2001
    Location
    CFA2h (respect the HEX)
    Posts
    12,756
    1.) I would not use loadMovie(), but instead use a movieClipLoader() instance instead.. it gives you much more control over the loading process

    2.) I would NOT load a .swf just for some text.. but instead just use a dynamic textField and change the text in it.. no loading onRollover()..


    your buttons inside the loaded .swf should still function properly.. you just have to remember that once you have loaded a .swf into another (main) .swf the loaded .swf's timeline becomes part of the MAIN.swf (make sense?)

    example:

    loaded1.swf:

    you have a button that whan clicked moves the playhead to the next frame

    the button has code of:

    PHP Code:
    button1.onPress = function(){
        
    _root.gotoAndPlay(2);

    you understand this, so far...correct? that button (when clicked) will move to frame 2 of the main timeline...

    however.. when this loaded1.swf is actually loaded into another (main) .swf

    all reference to _root in loaded1.swf do NOT means the main timeline in loaded1.swf... any use of _root means the MAIN timelineof the MAIN.swf that just loaded the external.swf


    so you need to remember that when you are coding anything in the external.swf that you want to affect the main.swf

  3. #3
    Master Of The Universe EvilKnevil's Avatar
    Join Date
    Jul 2001
    Location
    Ontario, Canada.
    Posts
    254
    Ok whispers,

    What do you mean by a movieclipLoader () instance? I think I know...but I may be thinking differently.

    None of the .swf files I am loading are only for text.
    It really is a way for me to break up the menu into different categories with some images and buttons.


    For instance, this is the code on one of my buttons in my 'main.swf'


    on (rollOver) {loadMovie('count-match.swf','holder');

    }

    on (release){

    _root.loadMovie('counting-match.swf','match_holder');


    }




    ** I recently added the '_root' before the 'loadMovie' --doing that for some reason allowed the 'counting-match.swf' movie to operate correctly. Meaning that now, when it loads, the sounds work and the 'drag and drop' targets work.

    Before I had that it would load, but NO SOUNDS or NONE OF THE DRAG N' DROP TARGETS were working??

    Now it seems that they are working.

    So you think that there is anything wrong with this code then?

    I guess I need to create a button in my loaded.swf to allow people to get back to or 'load' the main.swf'

    ** i was trying to load a different 'swf file' into a 'main.swf' using a 'holder.mc' as a target to load the .swf file.


    Problem was none of the sounds were working in the newly 'loaded.swf'

    **I apologise, but I am trying to explain it best I can.
    Right now, the button seems to be working fine since adding the '_root'


    *Again, maybe you can recommend a better way?
    "Ride It Like Ya Stole It!'

    Preschool Learning Activities

    Flash Cartoons

  4. #4
    Master Of The Universe EvilKnevil's Avatar
    Join Date
    Jul 2001
    Location
    Ontario, Canada.
    Posts
    254
    I was getting confused doing some research on FK and on the web . It was mentioning the 'loaded.swf' points to the loader.swf or main.swf files timeline.

    It was mentioning:

    _lockroot=true;

    and a few code variations. Problems was I didn't understand where it was suppose to go or if it was even what I needed?


    *GRrrr...* LOL
    "Ride It Like Ya Stole It!'

    Preschool Learning Activities

    Flash Cartoons

  5. #5
    Senior Member whispers's Avatar
    Join Date
    Mar 2001
    Location
    CFA2h (respect the HEX)
    Posts
    12,756
    _lockroot goes with my explanation above...

    if you used _root in your external.swf's.. then putting _lockroot = true; would keep the _root timelines separate (once loaded into another .swf)

    I do however suggest that you do NOT place code directly on an object (button or movieClip..etc) and start putting all your code in the timeline (frame)

    instead of putting

    PHP Code:
    on (rollOver){
        
    loadMovie('count-match.swf','holder');

    "ON" a button...

    you should give that button an instance name

    (for example button1)

    then in the timeline (frame this buttons exists in)

    do something like:

    PHP Code:
    button1.onPress = function(){
        
    _root.holder.loadMovie('counting-match.swf);

    by keeping with this practice you keep all code centralized and organized in one spot. (easier to edit if all the code is one place..and its a recommended way of doing things)

    also in my footer are a bunch of links that might be of help to you, but also a link called clipLoader.. that explains how to use a movieClipLoader() instance to load your content..

  6. #6
    Master Of The Universe EvilKnevil's Avatar
    Join Date
    Jul 2001
    Location
    Ontario, Canada.
    Posts
    254
    Ok...I am going to try that...I'll get back to you on that!

    I don't quite understand what you mean about:

    if I used _root in my external .swf then I would use _lockroot=true;


    Where would it go? Some of my code in my external has _root in it

    Is that what you are referring to?

    I just need to know where that _lockroot=true;

    would go?

    **Iwill try your method of code for the buttons
    "Ride It Like Ya Stole It!'

    Preschool Learning Activities

    Flash Cartoons

  7. #7
    Senior Member whispers's Avatar
    Join Date
    Mar 2001
    Location
    CFA2h (respect the HEX)
    Posts
    12,756
    _lockroot = true would go in the first frame..

    I tried to explain why you would use it..

    in any .swf file.. _root means the MAIN time line.....

    but if you use _root in an .swf that you load into another .swf the use of _root in the external.swf (once loaded into another .swf) no longer means the MAIN time line of that .swf... _root means the MAIN time line of the MAIN .swf now...

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