A Flash Developer Resource Site

+ Reply to Thread
Results 1 to 14 of 14
  1. #1
    Senior Member
    Join Date
    Mar 2000
    Posts
    457

    Smile

    Hi guys

    I found another gap in my knowledge
    here's the deal:

    very short:
    ---------------------------------------------
    Is there a way to check which background.swf is
    loaded from whithin the controls.swf and then
    jumps to the appropriate keyframe that tells
    you which background is displayed???????
    ---------------------------------------------

    more detailed:
    ---------------------------------------------
    before i explain here's the site it's about:
    http://people.a2000.nl/mstaal

    i use an empty loader.swf to load the stuff into levels.

    there are 2 levels
    1 containing the background (level 1)
    and
    1 containing the controls (level 2)
    There are actually more but it's only confusing when i write them all down

    now when using the displaycontrol you can switch backgrounds
    and the selected backgroundicon in the displaymenu will have
    a text effect telling you it is selected
    (for this example select background 2 or 3).

    Once you have moved your mousepointer away from that control the menu closes again.

    Now this is what's wrong:
    open the displaymenu again and you will see that the wrong
    keyframe is displayed telling you that background 1 is
    loaded

    Is there a way to check which background.swf is loaded from
    whithin the controls.swf and then jumps to the appropriate
    keyframe that tells you which background is displayed???????

    Hope you guys understand what i mean because it's a bit hard to explain

    resume:
    3 backgrounds named:
    backgrnd1.swf (this one is loaded into level 1 by an empty loader.swf that loads everything into place)

    backgrnd2.swf (replacing the one in level 1)
    backgrnd3.swf (replacong the one in level 1)

    controls.swf (loaded into level 2)
    ---------------------------------------------


    [Edited by Michel on 04-21-2001 at 08:14 PM]

  2. #2
    Senior Member
    Join Date
    Aug 2000
    Posts
    2,235
    Get level1 to set a variable on level0 when if is loaded;

    _level0.whichBkd=bkd_a;

    and use an if statement to check which background is active.

    ~mgb

  3. #3
    Senior Member
    Join Date
    Mar 2000
    Posts
    457

    This probably sound dumb

    But could you please help me with a more detailed example of the script because i never used the IF statement

    I do understand the principle you explained so further i would be able to implement it in the site
    but i need some exaple of the actual code

    Thanks in advance

  4. #4
    Senior Member
    Join Date
    Mar 2000
    Posts
    457

    i tried this with no luck :o(

    ON THE LOADED BACKGROUND:
    -----------------------------
    _level0.whichBkd = backgrnd2;
    stop ();
    -----------------------------

    AND ON THE CONTROLS:
    -------------------------------
    tellTarget ("_level0") {
    if (whichBkd = backgrnd2) {
    gotoAndStop (2);
    }
    }
    -------------------------------

    this is probably not the way so please give me some info on this MGB

  5. #5
    Senior Member
    Join Date
    Aug 2000
    Posts
    2,235

    Re: i tried this with no luck :o(

    Originally posted by Michel

    this is probably not the way so please give me some info on this MGB
    Your idea is basically what I'm on about. On the button or frame event put;

    if(_level0.whichBkd == bkgrnd2){
    // do some stuff;
    } else if (_level0.whichBkd==bkgrnd3){
    // do other stuff;
    }

    On the preloaders of the levels for the background put;
    if(_framesloaded==_totalframes){
    _level0.whichBkd=bkgrnd2;
    }

    tell target is deprecated so it's best to use the dot notation.
    [Edited by mgb on 04-22-2001 at 10:14 AM]

  6. #6
    Senior Member
    Join Date
    Mar 2000
    Posts
    457

    I've done exactly whatyou told me to but
    Somehow i am missing something because i can't get it to work
    even though i understand the scripting bit

    Is it possible that i send you the fla's by email?
    so you could have a closer look at it.
    (Total of all the fla files is 611kb)

    Hope to hear soon from you
    and if you want to receive the fla's send me an empty e-mail to: m.staal@chello.nl

    I'll reply that one with the files

    Thanks in advance

    P.s. don't think i am not trying because i also tried this:

    in the preloader of the background:
    if (_framesloaded == _totalframes) {
    var whichBkd = bkgrnd3;
    }


    in the first keyframe of the controls:
    if (_level1.whichBkd == bkgrnd1) {
    gotoAndStop (2);
    } else if (_level1.whichBkd == bkgrnd2) {
    gotoAndStop (3);
    } else if (_level1.whichBkd == bkgrnd3) {
    gotoAndStop (4);
    }

    But that didn't do the trick either

    [Edited by Michel on 04-22-2001 at 01:57 PM]

  7. #7
    Senior Member
    Join Date
    Aug 2000
    Posts
    2,235

    Re:

    You need to set the variable on level0

    in the preloader of the background:
    if (_framesloaded == _totalframes) {
    _level0.whichBkd = bkgrnd3;
    }


    do a trace on the variable to see if it's being set...


    ~mgb

  8. #8
    Senior Member
    Join Date
    Mar 2000
    Posts
    457

    YES YES YES YES !!!!!!!!!!!!!!!!

    It works
    THANKS MAN !!!!!!!!!!!!

    here's why it didn't work the first attempt:

    to set the var i had to change it
    var whichBkd = bkgrnd3;
    into
    _level0.whichBkd = "3";

    because somehow the var statement only worked when i used a single number instead of the full bkgrnd3
    the var did get set but the controls didn't read it

    Or it might be because i was overlooking something.


    Nevertheless (if that's good english )
    YOUR THE MAN !!!!!!!!
    IT IS WORKING NOW

    to see that you really helped check:
    http://people.a2000.nl/mstaal

  9. #9
    Senior Member
    Join Date
    Aug 2000
    Posts
    2,235

    Re: YES YES YES YES !!!!!!!!!!!!!!!!

    Ok, well done!

    ~mgb

  10. #10
    Senior Member
    Join Date
    Mar 2000
    Posts
    457

    last question

    Locally it works just fine

    but when i look at the version i uploaded to my isp
    it is working after several switches back and forward

    And there is a tick in the animation the second the background icons fall into place (that isn't when tested locally)

    Any suggestions?

  11. #11
    Senior Member
    Join Date
    Aug 2000
    Posts
    2,235

    Re: last question

    This could be a timing problem where the variable is not set for a few seconds even though the swf is cached. You should also set the whichBkd variable to "" with;

    if (_level0.whichBkd=="2"){

    // do something;

    _level0.whichBkd="";

    }

    ~mgb

  12. #12
    Senior Member
    Join Date
    Mar 2000
    Posts
    457

    Smile Looked at it more closely

    I've tried what you told me but that didn't solve it.

    So i looked at it more closely
    And the reason why it only working locally is because
    there are all 3 of the backgrounds.

    Once you've selected all the of the background in the online version it is working.

    So for some reason all 3 of the background.swf's must be in the cache

    Any suggestions?

    BTW
    I realy appreciate your help and the quick replies

  13. #13
    Senior Member
    Join Date
    Aug 2000
    Posts
    2,235

    Re: Looked at it more closely

    Perhaps it is not necessary to use levels. You could use a movie clip for all your backgrounds an use frames in the clip to set the variable. You could also have the nav mc on the root.

    You also might try to figure a way to make the variable reset if the swf is reloaded after it is cached so the ifFrameIsLoaded sets the variable and it is also set if it is reloaded.

    ~mgb

  14. #14
    Senior Member
    Join Date
    Mar 2000
    Posts
    457

    It's working :o)))))))))))))))))))))

    I tried and tried and tried and tried )

    Finally it is working now
    You where right about the timing thing AGAIN !!!

    I changed the point of the variable being written from keyframe 1 of the preloader to the last keyframe of the beckground animation (the one containing the stop action)

    And now it is working

    Thanks for ALL the support and i hope to be of some help in the future
    (although i don't think that will happen ))

    Once again
    Thanks man

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