Flash as write code to achieve three-dimensional look effect

Source: Internet
Author: User
Tags range set background

Some time ago on the Korean landscape website to see this three-dimensional look at the effect, the foreground and background separation effect, feeling very good. I try to do one, today, the original document and practice shared out.

Let's take a look at the effect I do: (mouse over the picture to see the effect)

http://bbs.flash8.net/bbs/UploadFile/2005-7/2005725155213247.swf

Click here to download the source file

1, first find a picture of the clouds, to a larger, can be spliced to look at the best picture.
2, look for a picture of the landscape, and then the clouds or the sky part removed, become transparent, save as PNG transparent format.
3. Create a movie clip in the first frame of the first floor of the home scene, with the instance name: BG_MC, creating a movie clip instance under BG_MC: BG, enter BG Edit, import the cloud image just found. The alignment coordinates are 0, 0;
4. Create a movie clip in the first frame of the second floor of the home scene, with the instance name: IMG_MC, creating a movie clip instance under IMG_MC: IMG, enter the IMG editor, import the scenery pictures just processed. The alignment coordinates are 0, 0;
5. Add the following as code in the first frame of the third floor of the home scene:

As----------------------------------------------------
Stop ();
Stage.showmenu = false;
Stage.scalemode = "Noscale";
Fscommand (Allowscale, true);
Img_mc.img.duplicateMovieClip ("Img1", 2);/copy foreground;
Bg_mc.bg.duplicateMovieClip ("Bg1", 2);//Copy Cloud Beijing;
Page_width = stage.width;//Set Mouse sensing range width
Page_height = stage.height;//Set mouse sensor range height;
Step = 40;//Set interval time;
img_mc.img._x = 0;//initial foreground coordinate position;
img_mc.img1._x =-img_mc.img._width;//Initial foreground is flattened into a glance
bg_mc.bg._x = 0;//initial background coordinate position;
bg_mc.bg1._x =-bg_mc.bg._width;//The initial background is spelled and is a scan;
img_mc._y = 0;//initial foreground and background y-axis position;
Bg_mc._y = 0;//
_root.onenterframe = function () {//The continuous invocation of functions based on frame frequency;
Img_width = img_mc._width/2;//Set foreground mouse detection range;
Bg_width = bg_mc._width/2;//Set background mouse detection range;
if (_root._xmouse>0 && _root._xmouse<page_width && _root._ymouse>0 && _root._ymouse <page_height) {
Determine whether the mouse is within the scene range;
img_mc._x = img_mc._x-(_ROOT._XMOUSE-PAGE_WIDTH/2)/step;//control foreground loop;
bg_mc._x = bg_mc._x-(_ROOT._XMOUSE-PAGE_WIDTH/2)/step*1.3;//control background circulation, speed is 1.3 times times faster than the foreground;
if (img_mc._x<-(img_width-page_width)) {//following a few if loops to detect whether the range is out of bounds;
img_mc._x = Page_width;
}
if (img_mc._x>page_width) {
img_mc._x = Page_width-img_width;
}
if (bg_mc._x<-(bg_width-page_width)) {
bg_mc._x = Page_width;
}
if (bg_mc._x>page_width) {
bg_mc._x = Page_width-bg_width;
}
}
};

Now direct Ctrl+enter can see the effect. Now share the two pictures I used to do this effect;

Cloud Picture:

Landscape Picture:



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.