Home Tutorials Forums Articles Blogs Movies Library Employment Press
Home » Actionscripts library »  Selection Object

Next 5

ClickManager

/**
* @author: Eric Feminella
* @url: http://www.ericfeminella.com
* @copyright: (c)2004 - 2006 code.ericfeminella.com
*/

import com.dataProviders.IntervalMethodCall;




class com.dataProviders.ClickManager
{
        
        private var global_mouseTimer:Number = 0;
        private var doubleClickTime:Number = 300;
        public var singleClick:Boolean = false;
        public var initInterval:Boolean = false;
        public var intervalMethodCall:IntervalMethodCall;
        
        
        public function ClickManager()
        {
                this.intervalMethodCall = new IntervalMethodCall(this, "validateSingleClick", null, 1, 1)
        }
        
        
        public function detectDoubleClick():Boolean
        {
                var time:Date = new Date();
                var now:Number = time.getTime();
                
                if (now - this.global_mouseTimer < this.doubleClickTime)
                {
                        return true;
                }
                else
                {
                        this.global_mouseTimer = now;
                        return false;
                }
        }
        
        
        public function detectSingleClick():Boolean
        {
                this.checkIntervalCall();
                
                if (this.singleClick)
                {
                        this.singleClick = false;
                        return true;
                }
                else
                {
                        return false;
                }
        }
        
        
        public function checkIntervalCall():Void
        {
                if (!this.initInterval)
                {
                        this.intervalMethodCall.beginInterval();
                        this.initInterval = true;
                }
        }
        
        
        public function validateSingleClick():Void
        {
                this.initInterval = false;
                this.singleClick = true;
        }
}

Posted by: Eric Feminella | website http://www.ericfeminella.com
Copy And Paste Shortcut keys
/*OK so everyone's been going on about how to use the standard Windows copy
and paste keys within Flash. Well here's my solution.*/

// Win. Copy and Paste Functionality, V1
// Jesse Stratford, www.actionscript.org
onClipEvent (enterFrame) {
        if (Key.isDown(Key.CONTROL) and Key.isDown(67)) {
                if (Selection.getFocus() != null) {
                        copy = Selection.getFocus();
                }
        } else if (Key.isDown(Key.CONTROL) and Key.isDown(86)) {
                if (Selection.getFocus() != null) {
                        _root[Selection.getFocus()] = eval(copy);
                }
        }
}
/*This goes on a controller clip somewhere off stage.
To copy click inside a text field and press Ctrl C, to
paste, click the target field and press Crtl V.*/

Posted by: Jesse Stratford | website http://www.actionscript.org
Copy the contents of one textfield and paste them into another
onClipEvent (enterFrame) {
        if (Key.isDown(17) && Key.isDown(67)) {
                Selection.setFocus("_root.text") && Selection.setFocus("_root.text2");
        } else if (Key.isDown(17) && Key.isDown(86)) {
                Selection.setFocus("_root.text2");
                _root.text2 = _root.text;
        }
}
First the user presses control C to copy, then control V to paste to a textfield.
The above example works in HTML and gets around the focus problem by setting the focus at the begining.

Unfortuanately it's not very practical as it doesn't set the focus on the first textfield properly. Maybe when I've a little more time I'll try and work it out.
Posted by: No name | website http://
Make the TAB button setFocus of the next text box in (LEVEL5)- for example
In the following example I load my movie with the text boxes into level5. All the actions focusing the text boxes are in the level 5 movie:
Level 5 Movie:
1) First set the focus of your text box in frame 1:
Selection.setFocus("box1");
This means the end user will be presented with a blinking cursor when the movie first loads. 2) Place the following action on an 'invisible button':
on (keyPress "<Tab>") {
        if (Selection.getFocus() == "_level5.box1") {
                Selection.setFocus("box2");
        } else if (Selection.getFocus() == "_level5.box2") {
                Selection.setFocus("box3");
        } else if (Selection.getFocus() == "_level5.box3") {
                Selection.setFocus("box4");
        } else if (Selection.getFocus() == "_level5.box4") {
                Selection.setFocus("box1");
        }
}
Change the variable names to the ones of your choice. You could have box1 leading onto box4 etc.
Posted by: No name | website http://
Random External Picture Selector
//randomis's the picture number
n = Math.round(Math.random() * 2);

//for selective pictures so that the other windows dont have the same
//picture on at the same time if there arnt any other windows just delete
//this section
if (n <= 0) {
        gotoAndPlay(1);
}

else if (n >= 3) {
        n = 2;
}
//selects the image that you want to load
else {
        loadMovie ('...\images\contact\image' + n + '.jpg', 'loadMovie');
}

//checkout www.copirite.com.au to see it in action if there are any other
//scripts that you might find interesting on there please dont hesitate to
//email me on [email protected]

Posted by: Travis Fitzgerald | website http://www.copirite.com.au

Next 5

Copyright 2000-2013 ActionScript.org. All Rights Reserved.
Your use of this site is subject to our Privacy Policy and Terms of Use.