Flash mimics the interactive effects of desktop icons

Source: Internet
Author: User
Tags range
The interactive demo file is as follows:

Click here to download the source file

Flash version: Flash MX 2004
Player version: 7
Actionscript:1
Specific steps:
No.1
Make two images, one for "unselected icon", Another for "Selected Icon" (This example uses the Photoshop icon and makes it a PNG image)

No.2
Open Flash, create a new blank document, the document defaults to a layer, we build a new layer, the above layer is named "unchecked icon", the layer below is named "selected Icon"
No.3
In the layer unchecked icon, import an image of the made unselected icon and convert it to a movie clip (MovieClip), and then name its instance names unselected
No.4
In the layer "checked icon", import the finished image of the selected icon and convert it to a movie clip (MovieClip), and then name its instance names as Selected
No.5
Now the status in the screen is as shown

No.6
Let's go to the scripting part
Select the movie clip "unchecked icon", press F9 to enter the action panel, and write the following code:

Onclipevent (load) {
_root.unselected._visible=0;
When the movie clip is loaded, the selected icon is hidden
}
Onclipevent (MouseDown) {
if (This.hittest (_root._xmouse,_root._ymouse,true)) {
_root.unselected._visible=1;
_root.unselected._x=this._x;
_root.unselected._y=this._y;
this._visible=0;
If the mouse clicks within the range of the movie clip, the icon appears when it is selected, and the movie clip is hidden when it is coincident with its coordinates
}else{
this._visible=1;
this._x=_root.unselected._x;
this._y=_root.unselected._y;
_root.unselected._visible=0;
If you click outside the range of the movie clip, the movie clip is displayed and the coordinates are coincident with the selected icon to hide the selected icon
}
}

No.7
Select the movie clip "selected Icon" and press F9 to enter the action panel and write the following code:

Onclipevent (MouseDown) {
if (_root.selected._visible==0) {
StartDrag ("");
When the mouse is pressed, if the unselected icon is hidden, start dragging
}
}
Onclipevent (mouseUp) {
Stopdrag ();
_root.selected._x=this._x;
_root.selected._y=this._y;
When the mouse is released, stop dragging and make the unchecked icon coincide with the movie clip coordinates
}

No.8
Finally, in the main scene, the coordinates of the two movie clips with the selected icon and the unchecked icon are overlapped to complete the production
Ctrl+enter tested the film.
There are other more convenient ways to achieve this effect, you are welcome to paste

Onclipevent (MouseDown) {
if (_root.selected._visible==0) {
StartDrag ("");
When the mouse is pressed, if the unselected icon is hidden, start dragging
}
}
Onclipevent (mouseUp) {
Stopdrag ();
_root.selected._x=this._x;
_root.selected._y=this._y;
When the mouse is released, stop dragging and make the unchecked icon coincide with the movie clip coordinates
}

No.8
Finally, in the main scene, the coordinates of the two movie clips with the selected icon and the unchecked icon are overlapped to complete the production
Ctrl+enter tested the film.
There are other more convenient ways to achieve this effect, you are welcome to paste

Onclipevent (load) {
_root.unselected._visible=0;
When the movie clip is loaded, the selected icon is hidden
}
Onclipevent (MouseDown) {
if (This.hittest (_root._xmouse,_root._ymouse,true)) {
_root.unselected._visible=1;
_root.unselected._x=this._x;
_root.unselected._y=this._y;
this._visible=0;
If the mouse clicks within the range of the movie clip, the icon appears when it is selected, and the movie clip is hidden when it is coincident with its coordinates
}else{
this._visible=1;
this._x=_root.unselected._x;
this._y=_root.unselected._y;
_root.unselected._visible=0;
If you click outside the range of the movie clip, the movie clip is displayed and the coordinates are coincident with the selected icon to hide the selected icon
}
}

No.7
Select the movie clip "selected Icon" and press F9 to enter the action panel and write the following code:

Onclipevent (MouseDown) {
if (_root.selected._visible==0) {
StartDrag ("");
When the mouse is pressed, if the unselected icon is hidden, start dragging
}
}
Onclipevent (mouseUp) {
Stopdrag ();
_root.selected._x=this._x;
_root.selected._y=this._y;
When the mouse is released, stop dragging and make the unchecked icon coincide with the movie clip coordinates
}

No.8
Finally, in the main scene, the coordinates of the two movie clips with the selected icon and the unchecked icon are overlapped to complete the production
Ctrl+enter tested the film.
There are other more convenient ways to achieve this effect, you are welcome to paste

Onclipevent (MouseDown) {
if (_root.selected._visible==0) {
StartDrag ("");
When the mouse is pressed, if the unselected icon is hidden, start dragging
}
}
Onclipevent (mouseUp) {
Stopdrag ();
_root.selected._x=this._x;
_root.selected._y=this._y;
When the mouse is released, stop dragging and make the unchecked icon coincide with the movie clip coordinates
}

No.8
Finally, in the main scene, the coordinates of the two movie clips with the selected icon and the unchecked icon are overlapped to complete the production
Ctrl+enter tested the film.
There are other more convenient ways to achieve this effect, you are welcome to paste

Onclipevent (load) {
_root.unselected._visible=0;
When the movie clip is loaded, the selected icon is hidden
}
Onclipevent (MouseDown) {
if (This.hittest (_root._xmouse,_root._ymouse,true)) {
_root.unselected._visible=1;
_root.unselected._x=this._x;
_root.unselected._y=this._y;
this._visible=0;
If the mouse clicks within the range of the movie clip, the icon appears when it is selected, and the movie clip is hidden when it is coincident with its coordinates
}else{
this._visible=1;
this._x=_root.unselected._x;
this._y=_root.unselected._y;
_root.unselected._visible=0;
If you click outside the range of the movie clip, the movie clip is displayed and the coordinates are coincident with the selected icon to hide the selected icon
}
}

No.7
Select the movie clip "selected Icon" and press F9 to enter the action panel and write the following code:

Onclipevent (MouseDown) {
if (_root.selected._visible==0) {
StartDrag ("");
When the mouse is pressed, if the unselected icon is hidden, start dragging
}
}
Onclipevent (mouseUp) {
Stopdrag ();
_root.selected._x=this._x;
_root.selected._y=this._y;
When the mouse is released, stop dragging and make the unchecked icon coincide with the movie clip coordinates
}

No.8
Finally, in the main scene, the coordinates of the two movie clips with the selected icon and the unchecked icon are overlapped to complete the production
Ctrl+enter tested the film.
There are other more convenient ways to achieve this effect, you are welcome to paste

Onclipevent (MouseDown) {
if (_root.selected._visible==0) {
StartDrag ("");
When the mouse is pressed, if the unselected icon is hidden, start dragging
}
}
Onclipevent (mouseUp) {
Stopdrag ();
_root.selected._x=this._x;
_root.selected._y=this._y;
When the mouse is released, stop dragging and make the unchecked icon coincide with the movie clip coordinates
}

No.8
Finally, in the main scene, the coordinates of the two movie clips with the selected icon and the unchecked icon are overlapped to complete the production
Ctrl+enter tested the film.
There are other more convenient ways to achieve this effect, you are welcome to paste

Onclipevent (MouseDown) {
if (_root.selected._visible==0) {
StartDrag ("");
When the mouse is pressed, if the unselected icon is hidden, start dragging
}
}
Onclipevent (mouseUp) {
Stopdrag ();
_root.selected._x=this._x;
_root.selected._y=this._y;
When the mouse is released, stop dragging and make the unchecked icon coincide with the movie clip coordinates
}

No.8
Finally, in the main scene, the coordinates of the two movie clips with the selected icon and the unchecked icon are overlapped to complete the production
Ctrl+enter tested the film.
There are other more convenient ways to achieve this effect, you are welcome to paste



Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.