A Flash Developer Resource Site

Results 1 to 10 of 10

Thread: [MX Pro] Hide all screens?

  1. #1
    Junior Member
    Join Date
    Jun 2007
    Posts
    17

    [MX Pro] Hide all screens?

    Hi all,

    I have a flash form application file developed in Flash MX Pro 2004 that has over 200 static screens and I see no end in sight of its continued expansion.

    I need a way to simplify my screen navigation scripts if I'm going to continue with this tool.

    What I have are literally dozens upon dozens of nested screens that I'm trying to hide with snipets that look like thus:

    Code:
    on(load)
    {
      // button to navigate back to application root
      btn_app.onRelease=function():Void
      {
        var x:String="navigate: App Root";
        trace(x);
    
    _root.ATHENA.WebRoot.WebFunc.WebType.visible=false;
    _root.ATHENA.WebRoot.WebFunc.WebInvRoot.visible=false;
    _root.ATHENA.WebRoot.WebFunc.WebInvRoot.WebInvMenu.visible=false;
    _root.ATHENA.WebRoot.WebFunc.WebInvRoot.WebInvHome.visible=false;
    _root.ATHENA.WebRoot.WebFunc.WebInvRoot.WebInvMice.visible=false;
    _root.ATHENA.WebRoot.WebFunc.WebInvRoot.WebInvProjects.visible=false;
    _root.ATHENA.WebRoot.WebFunc.WebInvRoot.WebInvGenetics.visible=false;
    _root.ATHENA.WebRoot.WebFunc.WebInvRoot.WebInvReqRoot.visible=false;
    _root.ATHENA.WebRoot.WebFunc.WebInvRoot.WebInvReqRoot.WebInvReqMenu.visible=false;
    _root.ATHENA.WebRoot.WebFunc.WebInvRoot.WebInvReqRoot.WebInvReqSum.visible=false;
    _root.ATHENA.WebRoot.WebFunc.WebInvRoot.WebInvReqRoot.WebInvReqMoveRoot.visible=false;
    
        //etc etc etc
    
        _root.ATHENA.Home.visible=true;
        _root.ATHENA.RootMenu.visible=true;
        }
    }
    As you can see, I'm trying to create a button that sits on a root screen for a given section that will take the user back to the application's _root

    What I want:

    Code:
    on(load)
    {
      // button to navigate back to application root
      btn_app.onRelease=function():Void
      {
        var x:String="navigate: App Root";
        trace(x);
    
        _global.visible=false;
    
        _root.ATHENA.Home.visible=true;
        _root.ATHENA.RootMenu.visible=true;
      }
    }
    Essentially what I'm asking for is a code snipet that will make all screens in the clip invisible without having to discretely reference them, then rebuild the visible screen path.

    Any help would be greatly appriciated. Thanks in advance!

    --Oukachiru

  2. #2
    :
    Join Date
    Dec 2002
    Posts
    3,518

    Maybe try something like this...

    Not sure exactly what you are looking for, but you can use a recursive function to hide all nested movie clips...
    Code:
    on (load) {
    	function hideAllMovies(instance) {
    		instance._visible = false;
    		for (var n in instance) {
    			if (typeof (instance[n]) == "movieclip") {
    				arguments.callee(instance[n]);
    			}
    		}
    	}
    	// button to navigate back to application root
    	btn_app.onRelease = function() {
    		var x:String = "navigate: App Root";
    		trace(x);
    		hideAllMovies(_root.ATHENA);
    		_root.ATHENA._visible = true;
    		_root.ATHENA.Home._visible = true;
    		_root.ATHENA.RootMenu._visible = true;
    	};
    }

  3. #3
    Junior Member
    Join Date
    Jun 2007
    Posts
    17
    Hi dawsonk, thank you very much for replying.

    When I executed your snipet, I got the following error message:

    "256 levels of recursion were exceeded in one action list.
    This is probably an infinite loop.
    Further execution of actions has been disabled in this movie."

    When executed the code did hide all screens. But it errored out before it could begin to rebuild the visible path. I think it was looping "n" without an endpoint? I'm pretty new to actionscript so I'm not positive what is going on in this snipet. Does it make a difference that I'm not using a standard movie clip, but rather a flash form application?

  4. #4
    Junior Member
    Join Date
    Jun 2007
    Posts
    17
    I tried explaining my problem a little better in the swf file here:

    http://www.transcendents.net/Work/explaination.swf

  5. #5
    :
    Join Date
    Dec 2002
    Posts
    3,518
    Yep, sorry I missed the part about forms.

    In the base -ATHENA-, initialize a new global array and a global hideAll function
    Code:
    on (load) {
    	_global.myHold = new Array();
    	_global.hideAll = function() {
    		while (myHold.length > 0) {
    			var tmp = myHold.pop();
    			tmp.visible = false;
    		}
    	};
    }
    Then whenever something becomes visible, that later you'll want to make invisible, push it into the array.

    In an on(reveal) event, it would be
    Code:
    myHold.push(this)
    or elsewhere just push the path
    Code:
    _root.ATHENA.WebRoot.WebFunc.WebType.visible = true;
    myHold.push(_root.ATHENA.WebRoot.WebFunc.WebType)
    Then when you want to hide them, just call the function.
    Code:
    hideAll()

  6. #6
    Junior Member
    Join Date
    Jun 2007
    Posts
    17
    Hi dawsonk, thank you very much for replying again! This is helping a lot!

    I'm not sure if the method you laid out will work within my screen architecture? Unless I’m not understanding the method it seems to require for the application to keep track of the myHold array value on the screen where the code is called, but the problem (I think?) is that this value is not updated when there are layers of screens open on top of the screen where the value is being held?

    But I’m not sure?

    Can you take a look at the attached file. This was a concept of the app, very very basic compared to where I am right now so it should make sense more or less immediately.

    I put the global functions on:

    _root.ATHENA

    Set the myHold array value I tried to test on:

    _root.ATHENA.Home.RootMenu

    And tried to execute the hideAll function on

    ATHENA.WebRoot

    You can see where I tried to use your code but I can’t seem to get it to work. I commented it out and re-enabled my original code that I’m trying to remove.

    Again, thank you VERY much for helping me out. You’ve been most kind!!

    http://transcendents.net/Work/example.fla

    --Ouka

  7. #7
    Junior Member
    Join Date
    Jun 2007
    Posts
    17
    well, i guess if no one else has any ideas, I'm stuck doing this the hard way. I find it hard to fathom that a tool designed to create application interfaces doesn't have an easy way to do what I'm asking...

  8. #8
    :
    Join Date
    Dec 2002
    Posts
    3,518
    I'm not sure why you are using forms vs slides. But if using slides is an option, it does all the hiding and showing for you based on the nesting. See attached file...
    Last edited by dawsonk; 08-22-2007 at 10:50 AM.

  9. #9
    Junior Member
    Join Date
    Jun 2007
    Posts
    17
    ! omg, that's so much easier! Thank you soo much.

    Neither of the two books I've read on flash application development:

    Macromedisa FLASH MX Professional 2004 application development (Stallons)

    Foundation Flash MX Applications (Mebberson)

    explain slides. Stallon's has 2 pages out of a 650 page book that mention slides and made them sound like a MS PowerPoint tool. Mebberson doesn't even mention them.

    Do you know of a good resource for learning more about slides vs screens? I'm left wondering what the functional difference is and when it would be a good time to use one vs the other in my applications.

    Thank you again, you just saved my a couple weeks of work!

  10. #10
    :
    Join Date
    Dec 2002
    Posts
    3,518
    Sorry, I've got no clue.

    I've only worked with slides once before and that was trying to help somebody here on flashkit. And with forms, this is the first I've seen them.

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