A Flash Developer Resource Site

Results 1 to 7 of 7

Thread: How is this functionality implemented!

  1. #1
    Senior Member vinayak.kadam's Avatar
    Join Date
    Oct 2006
    Location
    gotoAndPlay("Pune");
    Posts
    831

    How is this functionality implemented!

    Hey all,

    Can somebody please tell me how is this implemented:

    - When a button is rolled over I display a movieclip
    - When I rollout of button this movieclip stays on the screen
    - When I click anywhere on the screen this movieclip then goes off

    I have this sample ready, but no source. Can somebody please explain me the basics to implement such kind of functionality.
    Attached Files Attached Files
    As ever,
    Vinayak Kadam

  2. #2
    Senior Member
    Join Date
    Jan 2011
    Posts
    171
    What you want is not clear to me. Are you want the code of how this is happen? or you just want to know in which situation this functionality should implement.


    arkitx

  3. #3
    Prid - Outing Nig 13's Avatar
    Join Date
    Jul 2006
    Location
    Norway
    Posts
    1,864
    I kinda decompiled the .SWF file, and yeah ... he/she who made it, really used a simple solution -.-*

    - Make a Movieclip, which will be visible/invisible when clicked on the button
    - Give that Movieclip an instance name of, e.g.: my_mc
    - Make a button, and give it an instance name of e.g.: my_btn
    - Make a new layer, and drag it BELOW the layer with all of our content (the movieclip and the button)
    - In that layer, create a LARGE button, covering the whole screen. Give it an instance name of: block_btn
    - Now, on any Frame, put this code:

    Actionscript Code:
    my_mc._visible = false;
    block_btn._alpha = 0;
    block_btn.useHandCursor = false;

    my_btn.onRollOver = function(){
        my_mc._visible = true;
    }

    block_btn.onPress = function(){
        my_mc._visible = false;
    }

    Explanation:

    Actionscript Code:
    my_mc._visible = false;
    // make my_mc invisble at the start of movie

    block_btn._alpha = 0;
    // make block_btn invisble, but still functional
    // in other words, change its alpha to 0

    block_btn.useHandCursor = false;
    // prevent the Cursor/Mouse from changing
    //  to Hand Cursor when you are on this button

    my_btn.onRollOver = function(){
        // on my_btn rollOver
        my_mc._visible = true;
        // make my_mc visible
    }

    block_btn.onPress = function(){
        // on block_btn clicked
        my_mc._visible = false;
        // make my_mc invisible
    }

    In other words, they simply hid a Button beneath the Movieclip and Button, and prevented the Cursor from changing into a hand when on that button, and simply added some codes to it. However, I've simplified things by writing the whole code on a single Frame

    Hope this Helps ya =)
    I am back, guys ... and finally 18 :P

    BRING BACK THE OLD DESIGN!! OR AT LEAST FIX THE AS TAGS

  4. #4
    Senior Member
    Join Date
    Aug 2006
    Posts
    322

    AS2 Code

    ActionScript Code:
    var bool = false;
    var tTips;
    var button = _root.attachMovie("btn", "btn", _root.getNextHighestDepth());
    button._x = Stage.width/2-button._width/2;
    button._y = Stage.height/2-button._height/2;

    button.onRollOver = showTips;
    button.onRollOut = mouseOUT;

    function showTips() {
        tTips = _root.attachMovie("toolTips", "toolTips", _root.getNextHighestDepth());
        tTips._x = button._x/2+button._width/2;
        tTips._y = button._y-(tTips._height);
    }
    function mouseOUT() {
        if (_root.bool == false) {
            var mouse:Object = new Object();
            mouse.onMouseDown = function(evt:Object) {
                var hit:Boolean = button.hitTest(_root._xmouse, _root._ymouse, true);
                if (!hit && _root.bool == true) {
                    removeTips();
                    _root.bool = false;
                }
            };
            Mouse.addListener(mouse);
            _root.bool = true;
        }
    }
    function removeTips() {
        removeMovieClip(tTips);
    }



    marlopax
    Last edited by marlopax; 06-20-2011 at 12:34 PM.

  5. #5
    Senior Member vinayak.kadam's Avatar
    Join Date
    Oct 2006
    Location
    gotoAndPlay("Pune");
    Posts
    831
    Both the solutions of Marlopax and Nig_13 really helped. Thanks guys....wonderful job by you both....Nig_13, I also decompiled the SWF and found it to be implemented in the simplest way. Whereas, what Marlopax explained was the perfect technical way.

    Thanks once again guys....and thanx to Arkitx for taking me into consideration!
    As ever,
    Vinayak Kadam

  6. #6
    Senior Member
    Join Date
    Aug 2006
    Posts
    322
    One thing I must say that decompiling swf and expecting for right code and right structure is just not a right way to learn or grab someones skill.

    Combinations of right code structure will always work. So a developer should focus on mechanism, which is his own creative process to make unique Application.

    @ vinayak, I agree with arkitx, as your thread is posted on General Section, nobody guess in which version of AS code you are looking for. You also asking about implementation with a swf file which throws a sense that you are asking how to use this swf to your own projects with its own functionality and also implement your trigger action with it.

    BTW: This is more easy in AS3.



    marlopax

  7. #7
    Senior Member vinayak.kadam's Avatar
    Join Date
    Oct 2006
    Location
    gotoAndPlay("Pune");
    Posts
    831
    Oh yes! I forgot to mention the AS version. I was just curious to know how this functionality is implemented. I never wanted to extent or reuse it. I just wanted to know how wud you detect that mouse key is pressed somewhere out of the box.

    @Marlopax suggestion was excellent though
    As ever,
    Vinayak Kadam

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