A Flash Developer Resource Site

Results 1 to 12 of 12

Thread: [RESOLVED] This is the most annoying *** problem ever

  1. #1
    Senior Member
    Join Date
    Sep 2007
    Location
    USA................. Posts: 87,683
    Posts
    337

    resolved [RESOLVED] This is the most annoying *** problem ever

    Hey Everyone,

    So, I've created a basic pop up mc, that is visible when a function is called. And invisble when someone clicks the X button.

    It works completely fine, except one problem. One HUGE problem.

    When the pop up shows up on frame 1, I can easily click the X button. And the pop up goes away.

    However, if I go to frame 2, and go back to frame 1. And the pop up comes again, and I try to X out the pop up. NOTHING HAPPENS.

    This is definitely a problem with swapping depths. Because, there is some error where the exit button can't make the mc's visibility false.

    I've spent COUNTLESS hours on this annoying **** problem. Definitely over 3-4 hrs.

    So I've made the whole pop up feature much more basic and easy to troubleshoot.

    Here's the SWF: http://www.trixmasta.com/test/popup.swf -try it out, it DOESN'T WORK!

    Here's the fla: http://uploading.com/files/cf873ed9/...Bpop%2Bup.fla/

    Please help out! I'm sure if you know depth() well in Flash, you can help me out :/

    Thanks
    ...♠♣♦♥::Trickmaster::♥♦♣♠...
    ╔════════════════════╗
    ║------------------------- ║
    ║-- www.Trixmasta.com--- ║
    ║------------------------- ║
    ╚════════════════════╝

  2. #2
    Junior Member
    Join Date
    Dec 2010
    Posts
    18
    You're probably changing a variable when you click the X and not changing it back when the popup resets.

  3. #3
    Senior Member
    Join Date
    Sep 2007
    Location
    USA................. Posts: 87,683
    Posts
    337
    when X is clicked, I am changing the visibility of the pop up mc.
    like this
    Actionscript Code:
    mc._visible=false

    also when the pop up is called, its depth is also changed so its at the top of all the layers. i change it with
    Actionscript Code:
    mc.swapDepths(mc._parent.getNextHighestDepth())

    Note: What I wrote above isnt exact syntax. My exact syntax and code is in the fla file.
    ...♠♣♦♥::Trickmaster::♥♦♣♠...
    ╔════════════════════╗
    ║------------------------- ║
    ║-- www.Trixmasta.com--- ║
    ║------------------------- ║
    ╚════════════════════╝

  4. #4
    Junior Member
    Join Date
    Dec 2010
    Posts
    18
    I've had strange problems like this happen with Flash before and, unfortunately, they've always ended with an unfinished program. I did notice something that might help you. I moved the popup on the first frame so that it's position was different from the one on the second frame. When I made the popup appear and changed frames, the popup was still in the same position. You aren't seeing the popup on the second frame. Somehow it's still the first one. Perhaps it's related to the negative depth that you're giving it.

    EDIT: I removed the line of code changing the depth of the popup and it works now. If you do the same, your problem should be fixed.
    Last edited by FlyingMonkey456; 01-10-2011 at 08:44 PM.

  5. #5
    Senior Member
    Join Date
    Sep 2007
    Location
    USA................. Posts: 87,683
    Posts
    337
    Well, the problem is that I the pop up shows up once on frame 1, and then if I do other things in the movie like go to frame 2, and then come back to frame 1, the pop up exit button does NOT work.

    But I didnt assign it a negative value. Its just the way it starts
    ...♠♣♦♥::Trickmaster::♥♦♣♠...
    ╔════════════════════╗
    ║------------------------- ║
    ║-- www.Trixmasta.com--- ║
    ║------------------------- ║
    ╚════════════════════╝

  6. #6
    Junior Member
    Join Date
    Dec 2010
    Posts
    18
    After removing that line of code, the popup disappears for me when I go from the second frame back to the first. The problem you were having, I think, is that the MC wasn't actually there. The image of it was just stuck on the stage.

  7. #7
    Senior Member
    Join Date
    Sep 2007
    Location
    USA................. Posts: 87,683
    Posts
    337
    Yeah, I know if I take out the depth code it will work. But that's defeating the purpose of the pop up. My pop up needs to be at level or 3 in the movie, because I am also loading other swfs into level 0 and 1.

    Therefore I need the getNextHighestDepth() code, so the pop up can actually appear.
    ...♠♣♦♥::Trickmaster::♥♦♣♠...
    ╔════════════════════╗
    ║------------------------- ║
    ║-- www.Trixmasta.com--- ║
    ║------------------------- ║
    ╚════════════════════╝

  8. #8
    Junior Member
    Join Date
    Dec 2010
    Posts
    18
    Just put the popup on a higher layer than everything you want it to be above. :P

  9. #9
    Senior Member
    Join Date
    Sep 2007
    Location
    USA................. Posts: 87,683
    Posts
    337
    Noo dude, you didnt hear what I said. I'm loading other MC's while the movie is playing. And they're loaded higher than than the depth of the layers that are present. And I want a pop up that is higher than the stage layers AND the loaded MC's.
    ...♠♣♦♥::Trickmaster::♥♦♣♠...
    ╔════════════════════╗
    ║------------------------- ║
    ║-- www.Trixmasta.com--- ║
    ║------------------------- ║
    ╚════════════════════╝

  10. #10
    [Horse Thief] gotoAndCrash's Avatar
    Join Date
    May 2007
    Location
    NW, USA
    Posts
    576
    I suspect the problem is that when you go to Frame 2 you're not really getting rid of the popup, & when you swap it's depth you're essentially pulling it off the stage & holding it in some kind of limbo. Then when you go back to Frame 1 you end up with 2 popups: the one stuck in limbo, PLUS the one sitting on the stage in Frame 1. Every time you jump from Frame 1 to Frame 2 to Frame 1 you're essentially adding another popup to limbo. You can see this evidenced if you replace the first
    Code:
    _root.popup._visible = false;
    to
    Code:
    popup._alpha = 0;
    & in the pop1 function, change:
    Code:
    _root.popup._visible = true;
    to
    Code:
    popup._alpha = 20;
    & in popup.exit_btn.onRelease, change
    Code:
    _root.popup._visible = 0;
    to
    Code:
    popup._alpha = 0;
    Then publish the SWF & spawn a popup, go to Frame 2, go back to Frame 1, & spawn a popup. If you keep doing this, you will notice that the popups get darker because you're stacking them up. By turning it's _alpha to 0 (or it's visibility to false), you're not doing anything to get it out of the way, you're just turning it invisible, but it's still technically "there". The popups that end up in limbo (as I mentioned before) are kind of dead, but don't go away. Like zombies eating your brain for hours on end while you try to figure this out! :P

    Now, continuing with the changes I made above, just for fun, in the popup.exit_btn.onRelease function, change that
    Code:
    popup._alpha = 0;
    to
    Code:
    popup.removeMovieClip();
    This will cause some other problems (such as the [semi] inability to spawn popups on Frame 2), but if you publish the SWF, & go:
    Test Pop Up, close it, go to Frame 2, go back to Frame 1, Test Pop Up, close it - you'll see that it works. Also, publish the SWF again & go: Test Pop Up, 2nd Frame, 1st Frame, Test Pop Up, 2nd Frame, 1st Frame, Test Pop Up - at this point you'll have 3 popups stacked on top of each other. But because we're now removeMovieClip()-ing them, they go away completely, so you can go close popup, close popup, close popup, & they'll all close!!

    I believe your solution lies in getting this stuff off the stage, maybe getting away from the timeline, & doing all of this stuff dynamically thru code. TimeLine has a way of screwing with functionality that is heavily code-based (which most of it is!). You might want to try spawning the popups dynamically, using a variable name to keep track of them so they can be deleted on a per-popup basis. Between that popup on the timeline, jumping across frames, & swapping depths, you're likely not going to solve this easily or efficiently.

    I think it's also worth touching on the hang-up with Instance Names that is going on here. The popup on the stage has an Instance Name of popup. When it's put in limbo it's name is still popup, but after you go to Frame 2, then back to Frame 1, the popup clip on the stage is named popup, so the popup in limbo no longer holds that name, or at least it won't respond to it. This means that the code that references popup is talking about the one on the stage, not the one in limbo. Basically the one in limbo is out of your control (& in your way) forever.

    Also, on a side note: You don't need to specify _root when you're on the _root. Notice that I didn't say _root.popup._alpha, I just said popup._alpha.


    Happy coding!
    1 Infinite Loop, Cupertino is a portal of Hell.

  11. #11
    Senior Member
    Join Date
    Sep 2007
    Location
    USA................. Posts: 87,683
    Posts
    337
    THANK YOU!
    So much!!!

    That was a beautifully explained and working response! I appreciate that you took time to help me out! I can't believe all I had to do was change the code to "removeMovieClip()". And I spent hours debugging with "_visible"!

    Oh yeah the _root, I still need to perfect my scoping skills with variables.

    And the alpha/visible/limbo explanation makes sense. Haha since when did flash games turn into LOST? (TV show reference joke)

    Thanks again for your help!
    ...♠♣♦♥::Trickmaster::♥♦♣♠...
    ╔════════════════════╗
    ║------------------------- ║
    ║-- www.Trixmasta.com--- ║
    ║------------------------- ║
    ╚════════════════════╝

  12. #12
    Senior Member
    Join Date
    Sep 2007
    Location
    USA................. Posts: 87,683
    Posts
    337
    Oh okay, I just noticed the major problem in that solution, like you mentioned (by I quickly read it).

    I am testing it out now again, and yeah the pop up doesnt appear.

    So I guess I have to create the MC through actionscript.
    ...♠♣♦♥::Trickmaster::♥♦♣♠...
    ╔════════════════════╗
    ║------------------------- ║
    ║-- www.Trixmasta.com--- ║
    ║------------------------- ║
    ╚════════════════════╝

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