Announcement

Collapse
No announcement yet.

initializing widgets

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    #16
    yes thats it i remember now the tabs example is in the menu example knew i saw it somewhere.

    Comment


      #17
      That works great Matt, but the one issue that continually plagues us is the use of the "tab" design. Given the fact the screens that are loaded into the button bar viewstack are symbols, they just don't want to share data with the main movie. Setting up the options object, as instructed above, works great as long as you stay within the viewstack. So widgets retain their value when hopping between tab views, but if I navigate away from the screen with the viewstack on it and come back, those values are not retained.

      This particular UI is one Fla using gotoandplay on the timeline to navigate between screens. So everything is self contained.

      Comment


        #18
        I'll need to know more specifics on your setup to be able to assist you any further. How you have everything setup, what components you are using from CLIK, etc. When you say 'symbol' I assume you are referring to a movie clip that contains all the components?

        Try this quick tutorial:
        • Using the TabNavigatorDemo file, create a new view (MyView) by duplicating one of the other views in the library (Say SquareView), with export for actionscript (the linkage ID) set to 'MyView'.
        • In this view, add a toggle button with the instance name of 'myToggleButton'.
        • Also add the following code on the timeline of this view:


        ActionScript 2.0 Code

        Code:
        myToggleButton.selected = _root.options.myToggleButton;
        myToggleButton.addEventListener("select", this, "onSelect");
        
        function onSelect() 
        {
            _root.options.myToggleButton = myToggleButton.selected;
        }
        • Back to the main (_root) timeline, add a regular button to the stage on the 'demoPanel' layer with the instance name of 'myButton' on the first keyframe.
        • Add this code on the first keyframe as well:


        Code:
        myButton.addEventListener("press", this, "onPress");
        
        function onPress() 
        {
            gotoAndStop(2);
        }
        stop();
        • Create a new layer called 'vars', with a single keyframe that spans the entire _root timeline. This keyframe/layer will store your global variables which can be accessed from anywhere.
        • On this keyframe, add the code:


        Code:
        if (!options) 
        {
            var options:Object = {};
        }
        • Create a second keyframe on the 'demoPanel', 'demoComponents', and 'background' layers (but not the vars layer). And on this keyframe, on the 'demoPanel' layer, add another button with the instance name 'myButton'.
        • Also add this code to the 'demoPanel' layer on keyframe 2:


        Code:
        myButton.addEventListener("press", this, "onPress");
        
        function onPress() 
        {
            gotoAndStop(1);
        }
        stop();
        • Delete the tab view movie clip ('demoComponents') on this frame (frame 2), so that only the button exists on frame 2.
        • Ensure this code is inside the 'demoComponents' movieclip (on frame 1):


        Code:
        bb.dataProvider = [
            {label:"Polygon", data:"PolygonView"},
            {label:"Circle", data: "CircleView"},
            {label:"Square", data:"SquareView"},
            {label:"MyView", data:"MyView"}
        ];
        
        Selection.setFocus(bb);
        
        stop();
        • Publish/Test. Everything should work as expected.
        • Go to the MyView view using the button bar.
        • Then click on the toggle button to set its toggled state to true.
        • Then select another view.
        • Then reselect MyView, and the toggle button is still selected.
        • If you press the button to go to frame 2, where there is no tab view movie clip, then return to frame 1 with the button on that frame, and then select MyView, the toggle button should have remembered its last state.


        All thanks to the options object on the vars layer.

        Also - bear in mind, that most (if not all) of this code can be done in UnrealScript as well.

        Comment

        Working...
        X