1 [FL]Flash Tutorial Photo listing animation using the AS3 and mouse cur Wed Sep 22, 2010 10:54 am
Admin
Admin
Today, I’m going to show you how to create advanced photo listing animation using the action script 3 and mouse cursor. You can use this AS animation for some presentation or for some [color:9e1d=#467b08 !important][color:9e1d=#467b08 !important]web banner. Using this lesson, You will also learn how to import any photos into a flash library, how to animate it, apply action script code, create instance name and much more.
Example:
[color:9e1d=#467b08 !important][color:9e1d=#467b08 !important]Move [color:9e1d=#467b08 !important]Your [color:9e1d=#467b08 !important]Mouse Over Photo!
Step 1
First, download photos that we will use for this lesson.
Vertical1243170 = false;ShowAdHereBanner1243170 = true;RepeatAll1243170 = false;NoFollowAll1243170 = false;BannerStyles1243170 = new Array( "a{display:block;font-size:11px;color:#888;font-family:verdana,sans-serif;margin:0 4px 10px 0;text-align:center;text-decoration:none;overflow:hidden;}", "img{border:0;clear:right;}", "a.adhere{color:#666;font-weight:bold;font-size:12px;border:1px solid #ccc;background:#e7e7e7;text-align:center;}", "a.adhere:hover{border:1px solid #999;background:#ddd;color:#333;}");document.write(unescape("%3Cscript src='"+document.location.protocol+"//s3.buysellads.com/1243170/1243170.js?v="+Date.parse(new Date())+"' type='text/javascript'%3E%3C/script%3E"));
div.bsap_1243170 {width:100%;display:block;} div.bsap_1243170 a{width:300px;} div.bsap_1243170 a img{padding:0;} div.bsap_1243170 a em{font-style:normal;} div.bsap_1243170 a{display:block;font-size:11px;color:#888;font-family:verdana,sans-serif;margin:0 4px 10px 0;text-align:center;text-decoration:none;overflow:hidden;} div.bsap_1243170 img{border:0;clear:right;} div.bsap_1243170 a.adhere{color:#666;font-weight:bold;font-size:12px;border:1px solid #ccc;background:#e7e7e7;text-align:center;} div.bsap_1243170 a.adhere:hover{border:1px solid #999;background:#ddd;color:#333;} div.bsap_1243170 a.adhere{width:300px;height:250px;line-height:2000%;} html>body div.bsap_1243170 a.adhere{width:298px;height:248px;} div.bsap_1243170 img.s{height:0;width:0;}div#bsap_1243170 {width:100%;display:block;} div#bsap_1243170 a{width:300px;} div#bsap_1243170 a img{padding:0;} div#bsap_1243170 a em{font-style:normal;} div#bsap_1243170 a{display:block;font-size:11px;color:#888;font-family:verdana,sans-serif;margin:0 4px 10px 0;text-align:center;text-decoration:none;overflow:hidden;} div#bsap_1243170 img{border:0;clear:right;} div#bsap_1243170 a.adhere{color:#666;font-weight:bold;font-size:12px;border:1px solid #ccc;background:#e7e7e7;text-align:center;} div#bsap_1243170 a.adhere:hover{border:1px solid #999;background:#ddd;color:#333;} div#bsap_1243170 a.adhere{width:300px;height:250px;line-height:2000%;} html>body div#bsap_1243170 a.adhere{width:298px;height:248px;} div#bsap_1243170 img.s{height:0;width:0;}
Step 2
Create a new flash [color:9e1d=#467b08 !important][color:9e1d=#467b08 !important]document. Press Ctrl+J key on the keyboard (Document Properties) and set the width of your document to 350 pixels and the height to 263 pixels. Select white color as background color. Set your [color:9e1d=#467b08 !important][color:9e1d=#467b08 !important]Flash [color:9e1d=#467b08 !important]movie's frame rate to 28 and click ok.
Step 3
Call the current layer photos. Double-click on its default name (Layer 1) to change it. Press Enter once you have typed in the new name!
Step 4
Choose File > Import > Import to Library. In the file explorer window that appears, find a siy photos and Shift-click to select them all. Then click open. If you now open your flash library (Ctrl+L key) you will see six photos that you just imported.
[You must be registered and logged in to see this image.]
Step 5
Using the Selection Tool (V) and drag and drop technique, move the first photo from flash library on flash stage. After that, while the photo is still selected, go to the Align Panel (Ctrl+K) and do the following:
1. Make sure that the Align/Distribute to Stage button is turned on,
2. Click on the Align horizontal center button and
3. Click the Align vertical center button.
[You must be registered and logged in to see this image.]
Step 6
While the photo is still selected, hit F8 key (Convert to Symbol) to convert it into a Movie Clip Symbol. [color:9e1d=#467b08 !important][color:9e1d=#467b08 !important]Registration point set to the top left side.
[You must be registered and logged in to see this image.]
Step 7
Double-click on the movie [color:9e1d=#467b08 !important][color:9e1d=#467b08 !important]clip on stage with the Selection tool(V).You should now be inside the Movie Clip.
[You must be registered and logged in to see this image.]
Step 8
Select now frame 2 and hit F7 key. After that, move the second photo from the flash library on the flash stage and aligned it with the background. Do this also for photos 3,4,5 and 6 and also for frame 3,4,5 and 6. See the picture below!
[You must be registered and logged in to see this image.]
Step 9
Go back on the main stage (Scene 1).
Step 10
Select the Selection Tool (V) and click once on the movie clip (photo) to select it. Then, go to the Properties Panel below the stage. On the left side, You will find the Instance name input field there. Call this Movie Clip photos_mc. See the picture below!
[You must be registered and logged in to see this image.]
Step 11
Create a new layer above the layer photos and name it actions.
Step 12
Select the first frame of layer actions and go to the AS panel (F9). Then, enter this code inside the actions panel:
photos_mc.stop();
photos_mc.addEventListener(MouseEvent.ROLL_OVER, overHandler);
photos_mc.addEventListener(MouseEvent.ROLL_OUT, outHandler);
function overHandler(e:Event):void {
photos_mc.addEventListener(MouseEvent.MOUSE_MOVE,changeFrame);
}
function changeFrame(e:Event):void {
var frame : uint = Math.ceil(photos_mc.totalFrames * photos_mc.mouseX /
photos_mc.width);
photos_mc.gotoAndStop(frame);
}
function outHandler(e:Event):void {
photos_mc.removeEventListener(MouseEvent.MOUSE_MOVE, changeFrame);
}
We're done!
Please Enjoy!
Download source file (.fla)]
Example:
[color:9e1d=#467b08 !important][color:9e1d=#467b08 !important]Move [color:9e1d=#467b08 !important]Your [color:9e1d=#467b08 !important]Mouse Over Photo!
Step 1
First, download photos that we will use for this lesson.
Vertical1243170 = false;ShowAdHereBanner1243170 = true;RepeatAll1243170 = false;NoFollowAll1243170 = false;BannerStyles1243170 = new Array( "a{display:block;font-size:11px;color:#888;font-family:verdana,sans-serif;margin:0 4px 10px 0;text-align:center;text-decoration:none;overflow:hidden;}", "img{border:0;clear:right;}", "a.adhere{color:#666;font-weight:bold;font-size:12px;border:1px solid #ccc;background:#e7e7e7;text-align:center;}", "a.adhere:hover{border:1px solid #999;background:#ddd;color:#333;}");document.write(unescape("%3Cscript src='"+document.location.protocol+"//s3.buysellads.com/1243170/1243170.js?v="+Date.parse(new Date())+"' type='text/javascript'%3E%3C/script%3E"));
div.bsap_1243170 {width:100%;display:block;} div.bsap_1243170 a{width:300px;} div.bsap_1243170 a img{padding:0;} div.bsap_1243170 a em{font-style:normal;} div.bsap_1243170 a{display:block;font-size:11px;color:#888;font-family:verdana,sans-serif;margin:0 4px 10px 0;text-align:center;text-decoration:none;overflow:hidden;} div.bsap_1243170 img{border:0;clear:right;} div.bsap_1243170 a.adhere{color:#666;font-weight:bold;font-size:12px;border:1px solid #ccc;background:#e7e7e7;text-align:center;} div.bsap_1243170 a.adhere:hover{border:1px solid #999;background:#ddd;color:#333;} div.bsap_1243170 a.adhere{width:300px;height:250px;line-height:2000%;} html>body div.bsap_1243170 a.adhere{width:298px;height:248px;} div.bsap_1243170 img.s{height:0;width:0;}div#bsap_1243170 {width:100%;display:block;} div#bsap_1243170 a{width:300px;} div#bsap_1243170 a img{padding:0;} div#bsap_1243170 a em{font-style:normal;} div#bsap_1243170 a{display:block;font-size:11px;color:#888;font-family:verdana,sans-serif;margin:0 4px 10px 0;text-align:center;text-decoration:none;overflow:hidden;} div#bsap_1243170 img{border:0;clear:right;} div#bsap_1243170 a.adhere{color:#666;font-weight:bold;font-size:12px;border:1px solid #ccc;background:#e7e7e7;text-align:center;} div#bsap_1243170 a.adhere:hover{border:1px solid #999;background:#ddd;color:#333;} div#bsap_1243170 a.adhere{width:300px;height:250px;line-height:2000%;} html>body div#bsap_1243170 a.adhere{width:298px;height:248px;} div#bsap_1243170 img.s{height:0;width:0;}
Step 2
Create a new flash [color:9e1d=#467b08 !important][color:9e1d=#467b08 !important]document. Press Ctrl+J key on the keyboard (Document Properties) and set the width of your document to 350 pixels and the height to 263 pixels. Select white color as background color. Set your [color:9e1d=#467b08 !important][color:9e1d=#467b08 !important]Flash [color:9e1d=#467b08 !important]movie's frame rate to 28 and click ok.
Step 3
Call the current layer photos. Double-click on its default name (Layer 1) to change it. Press Enter once you have typed in the new name!
Step 4
Choose File > Import > Import to Library. In the file explorer window that appears, find a siy photos and Shift-click to select them all. Then click open. If you now open your flash library (Ctrl+L key) you will see six photos that you just imported.
[You must be registered and logged in to see this image.]
Step 5
Using the Selection Tool (V) and drag and drop technique, move the first photo from flash library on flash stage. After that, while the photo is still selected, go to the Align Panel (Ctrl+K) and do the following:
1. Make sure that the Align/Distribute to Stage button is turned on,
2. Click on the Align horizontal center button and
3. Click the Align vertical center button.
[You must be registered and logged in to see this image.]
Step 6
While the photo is still selected, hit F8 key (Convert to Symbol) to convert it into a Movie Clip Symbol. [color:9e1d=#467b08 !important][color:9e1d=#467b08 !important]Registration point set to the top left side.
[You must be registered and logged in to see this image.]
Step 7
Double-click on the movie [color:9e1d=#467b08 !important][color:9e1d=#467b08 !important]clip on stage with the Selection tool(V).You should now be inside the Movie Clip.
[You must be registered and logged in to see this image.]
Step 8
Select now frame 2 and hit F7 key. After that, move the second photo from the flash library on the flash stage and aligned it with the background. Do this also for photos 3,4,5 and 6 and also for frame 3,4,5 and 6. See the picture below!
[You must be registered and logged in to see this image.]
Step 9
Go back on the main stage (Scene 1).
Step 10
Select the Selection Tool (V) and click once on the movie clip (photo) to select it. Then, go to the Properties Panel below the stage. On the left side, You will find the Instance name input field there. Call this Movie Clip photos_mc. See the picture below!
[You must be registered and logged in to see this image.]
Step 11
Create a new layer above the layer photos and name it actions.
Step 12
Select the first frame of layer actions and go to the AS panel (F9). Then, enter this code inside the actions panel:
photos_mc.stop();
photos_mc.addEventListener(MouseEvent.ROLL_OVER, overHandler);
photos_mc.addEventListener(MouseEvent.ROLL_OUT, outHandler);
function overHandler(e:Event):void {
photos_mc.addEventListener(MouseEvent.MOUSE_MOVE,changeFrame);
}
function changeFrame(e:Event):void {
var frame : uint = Math.ceil(photos_mc.totalFrames * photos_mc.mouseX /
photos_mc.width);
photos_mc.gotoAndStop(frame);
}
function outHandler(e:Event):void {
photos_mc.removeEventListener(MouseEvent.MOUSE_MOVE, changeFrame);
}
We're done!
Please Enjoy!
Download source file (.fla)]