15 Replies Latest reply on Oct 6, 2010 12:11 PM by kglad

    How To Move MC To Top?



      On the default page, I have scattered photos. Once "Clothes" is clicked,  it contains a page flip. When the page flip is loaded, I would like for  the scattered photos to hide. If this can't be done, then the page flip  should be on top of the scattered photos. Right now it's not doing  either.


      Any advice appreciated.

        • 1. Re: How To Move MC To Top?
          kglad Adobe Community Professional & MVP

          assign their visible (as3) property to false.

          • 2. Re: How To Move MC To Top?
            Nana00L Level 1



            Thank you for the prompt response. I apologize in advance for my questions that might seem simple.


            The tween of photos is done on the main timeline (default page). On a separate timeline I have the five buttons and loading/unloading of pageflip. I'm not sure how to make the photo tween visible on the default page and call it on another timeline to make it invisible.


            I've tried creating functions and global functions/classes for the tween so I can call it (use it) in another timeline. None worked and it's over my head.


            Not sure if this wil help, code to tween.


            import fl.transitions.Tween;
            import fl.transitions.easing.*;


            var p:Number = 0;
            var scale_factor:Number = 0.4;
            var tween_duration:Number = 0.6;
            var photo_folder:String = "thumbnails/";
            var file_extension:String = ".jpg";
            var photo_array:Array = new Array("flashmo_400x300_01",
            var total_photo:Number = photo_array.length;
            var photo_group:MovieClip = new MovieClip();


            for( p = 0; p < total_photo; p++ )
                var pic_request:URLRequest = new URLRequest(
                                photo_folder + photo_array[p] + file_extension );
                var pic_loader:Loader = new Loader();
                pic_loader.contentLoaderInfo.addEventListener(Event.COMPLETE, on_loaded);


            function on_loaded(e:Event):void
                var flashmo_bm:Bitmap = new Bitmap();
                var flashmo_mc:MovieClip = new MovieClip();
                flashmo_bm = Bitmap(e.target.content);
                flashmo_bm.x = - flashmo_bm.width * 0.5;
                flashmo_bm.y = - flashmo_bm.height * 0.5;
                flashmo_bm.smoothing = true;
                var bg_width = flashmo_bm.width + 16;
                var bg_height = flashmo_bm.height + 16;
                flashmo_mc.scaleX = flashmo_mc.scaleY = scale_factor;
                flashmo_mc.graphics.drawRect( - bg_width * 0.494, - bg_height * 0.494, bg_width, bg_height );
                flashmo_mc.graphics.drawRect( - bg_width * 0.5, - bg_height * 0.5, bg_width, bg_height );
                flashmo_mc.buttonMode = true;
                flashmo_mc.addEventListener( MouseEvent.MOUSE_OVER, bring_it );
                flashmo_mc.addEventListener( MouseEvent.MOUSE_DOWN, drag_it );
                flashmo_mc.addEventListener( MouseEvent.CLICK, drop_it );
                var positionX:Number = 100 + Math.random() * 250;
                var positionY:Number = 600 + Math.random() * 60;
                var rotate:Number = Math.random() * 120 - 60;
                new Tween(flashmo_mc, "x", Strong.easeOut, 100, positionX, 2, true);
                new Tween(flashmo_mc, "y", Strong.easeOut, 800, positionY, 2, true);
                new Tween(flashmo_mc, "rotation", Strong.easeOut, 0, rotate, 2, true);


            function bring_it(e:MouseEvent):void
                var mc:MovieClip = e.target;




            function drag_it(e:MouseEvent):void
                var mc:MovieClip = e.target;
                mc.addEventListener( Event.ENTER_FRAME, moving );


                new Tween(mc, "rotation", Strong.easeOut, mc.rotation, 0, tween_duration, true);
                new Tween(mc, "scaleX", Strong.easeOut, mc.scaleX, 1, tween_duration, true);
                new Tween(mc, "scaleY", Strong.easeOut, mc.scaleY, 1, tween_duration, true);


            function drop_it(e:MouseEvent):void
                var rotate:Number = Math.random() * 120 - 60;
                var mc:MovieClip = e.target;
                mc.removeEventListener( Event.ENTER_FRAME, moving );


                new Tween(mc, "rotation", Strong.easeOut, mc.rotation, rotate, tween_duration, true);
                new Tween(mc, "scaleX", Strong.easeOut, mc.scaleX, scale_factor, tween_duration, true);
                new Tween(mc, "scaleY", Strong.easeOut, mc.scaleY, scale_factor, tween_duration, true);


            function moving(e:Event):void
                var mc:MovieClip = e.target;
                mc.x = mouseX;
                mc.y = mouseY;


            Thank you again for looking into this!

            • 3. Re: How To Move MC To Top?
              kglad Adobe Community Professional & MVP

              if you have timeline tweening, you probably won't have an easy way to assign a visible property using actionscript.


              does your page-turn loader have the same parent as you tweened objects?  if yes, just (re)add you loader to the display list when you want to move it to the top.  if no, your loader has an ancestor (parent, grandparent, etc) that's a sibling of your tweened objects.  move that ancestor above the tweened objects.

              • 4. Re: How To Move MC To Top?
                Nana00L Level 1



                I hope this doesn't sound confusing as I'm confused myself.


                On the main timeline, I have layers "actions", "contents"...so forth. Under the "contents" layer, the first frame contains "contents" (mc) that has 5 layers (all the buttons).


                Tweening is done on the main timeline, the first frame under "actions" layer on the default page so it's loaded when the site opens.


                Page flip is done in "contents" (mc) in one of the 5 layers (each layer correspondes to a button so it's the third layer).


                With this structure, I'd assume the tweening is the parent and page flip is the child(?). Since tweening is called on the main timeline and the page flip is called in a mc that's in one of the layers in the main timeline. But I haven't set anything to be parent or child, I assume it's done automatically based on what is defined/used first?


                In the page flip layer, I can't use/call any variables used in tweening since it's on the main timeline. I think that's my challenge. If I could, I could make tweening invisible like you suggested earlier.


                Thank you again!!!

                • 5. Re: How To Move MC To Top?
                  kglad Adobe Community Professional & MVP

                  how can the buttons be tweened on the main timeline if they're in contents?

                  • 6. Re: How To Move MC To Top?
                    Nana00L Level 1

                    The buttons (menu) is on the main timeline and it's using an array, I suppose to make the menu dynamic (code is at the bottom). The tweening of photos is just below the array that holds these 5 menus. In other words, the code below for menus and tweening (code above) are together on the main timeline under "actions".


                    The "contents" layer in the main timeline holds the "content" mc. The "content" mc has 5 frames, each frame for each menu content. For example in the "content" mc -> layer 1 has f1 (frame1), f2, f3, f4, f5. f1 = Home, f2 = Policy, f3 = Clothes, f4 = How To Buy, f5 = Contact Me. It's in f3 (Clothes) that I have page flip.


                    Code for menu in main timeline under "actions" layer ----->


                    flashmo_button.visible = false;


                    var menu_label:Array = new Array("Home", "Policy",
                                                     "Clothes", "How To Buy", "Contact Me");
                    var total:Number = menu_label.length;
                    var spacing:Number=1;
                    var i:Number = 0;
                    var page:Number;
                    var main_menu:MovieClip = new MovieClip();




                    for( i = 0; i < total; i++ )
                        var btn = new button();
                        btn.name = "btn" + i;
                        btn.x = flashmo_button.x + (flashmo_button.width + spacing) * i;
                        btn.y = flashmo_button.y;
                        btn.item_no = i;
                        btn.addEventListener( Event.ENTER_FRAME, btn_enter );
                        var each_substring:Array = menu_label[i].split("|"); 
                        btn.item_label.fm_label.text = each_substring[0]; 
                        btn.item_url = each_substring[1];


                    function btn_over(e:MouseEvent):void
                        e.target.over = true;


                    function btn_out(e:MouseEvent):void
                        e.target.over = false;


                    function btn_click(e:MouseEvent):void
                        var mc = e.target.parent;
                        if( mc.item_url != undefined ) 
                            navigateToURL( new URLRequest( mc.item_url ), "_parent" );


                    function btn_enter(e:Event):void
                        var mc = e.target;
                        if( mc.over == true )


                    function change_page(no:Number):void
                        for( var i:Number = 0; i < main_menu.numChildren; i++ )
                            var mc = MovieClip( main_menu.getChildAt(i) );
                            mc.over = false;
                            mc.click_area.visible = true;
                            mc.addEventListener( MouseEvent.ROLL_OVER, btn_over );
                            mc.addEventListener( MouseEvent.ROLL_OUT, btn_out );
                            mc.addEventListener( MouseEvent.CLICK, btn_click );
                        var mc_selected = MovieClip( main_menu.getChildAt(no) );
                            mc_selected.over = true;
                            mc_selected.click_area.visible = false;
                            mc_selected.removeEventListener( MouseEvent.ROLL_OVER, btn_over );
                            mc_selected.removeEventListener( MouseEvent.ROLL_OUT, btn_out );
                            mc_selected.removeEventListener( MouseEvent.CLICK, btn_click );
                        fm_content.gotoAndStop(no + 1);



                    below is the code for tweening of photos mentioned in above post.


                    Thank you again!!!!!!

                    • 7. Re: How To Move MC To Top?
                      kglad Adobe Community Professional & MVP

                      so your buttons ARE on the main timeline and they ARE NOT in a movieclip (named content or anything else), correct?


                      and your loader that loads your page turn swf is on what timeline?

                      • 8. Re: How To Move MC To Top?
                        Nana00L Level 1

                        Yes, the identifying and assigning of buttons are on the main timeline, on the first frame of "actions" layer. On the main timeline, there is another layer called "contents", in this layer contains a movieclip called "contents" (same name as the layer name on the main timeline, put in italics to separate from the layer). In the "contents" movieclip, it has "gallery" layer with 5 frames. Each frame correspondes to each content of the 5 menus when it's clicked. The page flip is on this timeline, the "content" movie clip timeline.


                        main timeline


                        "actions" [frame1] <--this frame contains the code for menu array (5 menu buttons) and photo tweening

                        "content" [frame1]




                                       "contents" movieclip time line

                                                       [frame1][frame2][frame3][frame4][frame5] <--each frame holds the content for each menu

                                                       [Menu]  [Policy]  [Clothes][Howtobuy][Contact]

                                       "gallery"    [unload][unload][load swf][unload][unload]




                        Thank you again!!!!!!!

                        • 9. Re: How To Move MC To Top?
                          kglad Adobe Community Professional & MVP

                          you want all frames (except 3) of the contents movieclip to be under your buttons and you want frame 3 of contents to display above your buttons?

                          • 10. Re: How To Move MC To Top?
                            Nana00L Level 1

                            I am failing miserably to explain this. What I want to do is for the page flip to be on top of the photos tweening. Not necessarily on top of the buttons.


                            Photo tweening is done on the main timeline on the default (home) page, but page flip is done on another timeline which I can't call any variables of photo tweening. What I'm hoping to do is from the page flip's timeline, I can call on the main timeline and make the photo tweening invisible. Another option is make the page flip on top of the photo tweening. I'm not quite sure how to do either.


                            I wish I could attach the files to show what I'm talking about.

                            • 11. Re: How To Move MC To Top?
                              kglad Adobe Community Professional & MVP

                              on the timeline that contains your page flip loader try:




                              • 12. Re: How To Move MC To Top?
                                Nana00L Level 1

                                I tried adding what you suggested to the page flip loader (before the loader, after the loader, in another layer but the same timeline). It's still isn't working. The photo tweening is still on top of the page flip, blocking the view.

                                • 13. Re: How To Move MC To Top?
                                  kglad Adobe Community Professional & MVP





                                  // and if that fails try:



                                  • 14. Re: How To Move MC To Top?
                                    Nana00L Level 1

                                    The this.parent.addChild(this) worked!!!!! Thank you! One problem down, one more to go.


                                    Just curious, is it possible to make 2 parents? How does flash know which one should be in front of the other in terms of layout? Could parents of parents be made? Hmmm...sounds like I'm talking about people.

                                    • 15. Re: How To Move MC To Top?
                                      kglad Adobe Community Professional & MVP

                                      you're welcome.


                                      you can reference the parent.parent.parent.etc until you reach the stage.  the parent of the stage is null.  and if you try and reference the parent (or anything else) of a null object you'll get a flash error #1009  - the most frequently encountered error as far as i can tell.