我实际上是多媒体设计专业的学生,我们有一个项目要在3周内进行渲染,称为交互式动画。
好吧,我试图产生不同的效果。
Glowing with easing
Scaling with easing
using alpha
我只使用Adobe手册,有些人回答了这里发布的内容。
这是我的代码
stop();
import fl.transitions.*;
import fl.transitions.easing.*;
// START :: BULLET Link Glowing ONCLICK- MOUSE EVENT delay declaration //
var glowONColor:Number = 0xFFFFFF;
var glowONAlpha:Number = 0.3;
var glowONBlurX:Number = 20;
var glowONBlurY:Number = 20;
var glowONStrength:Number = 3;
var glowONQuality:Number = BitmapFilterQuality.HIGH;
var glowONInner:Boolean = false;
var glowONKnockout:Boolean = false;
var gfON:GlowFilter = new GlowFilter(glowONColor, glowONAlpha, glowONBlurX, glowONBlurY, glowONStrength, glowONQuality, glowONInner, glowONKnockout);
var glowOFFColor:Number = 0x000000;
var glowOFFAlpha:Number = 0;
var glowOFFBlurX:Number = 0;
var glowOFFBlurY:Number = 0;
var glowOFFStrength:Number = 0;
var glowOFFQuality:Number = BitmapFilterQuality.HIGH;
var glowOFFInner:Boolean = false;
var glowOFFKnockout:Boolean = false;
var gfOFF:GlowFilter = new GlowFilter(glowOFFColor, glowOFFAlpha, glowOFFBlurX, glowOFFBlurY, glowOFFStrength, glowOFFQuality, glowOFFInner, glowOFFKnockout);
mc_bullet_7mm.addEventListener(MouseEvent.CLICK, go_to_item1);
function go_to_item1(event:MouseEvent):void
{
gotoAndStop("Item1");
mc_bullet_7mm.filters = [gfON];
}
mc_bullet_280mm.addEventListener(MouseEvent.CLICK, go_to_item2);
function go_to_item2(event:MouseEvent):void
{
gotoAndStop("Item2");
mc_bullet_280mm.filters = [gfON];
}
mc_bullet_270mm.addEventListener(MouseEvent.CLICK, go_to_item3);
function go_to_item3(event:MouseEvent):void
{
gotoAndStop("Item3");
mc_bullet_270mm.filters = [gfON];
}
mc_bullet_30_06mm.addEventListener(MouseEvent.CLICK, go_to_item4);
function go_to_item4(event:MouseEvent):void
{
gotoAndStop("Item4");
mc_bullet_30_06mm.filters = [gfON];
}
mc_bullet_300_mag.addEventListener(MouseEvent.CLICK, go_to_item5);
function go_to_item5(event:MouseEvent):void
{
gotoAndStop("Item5");
mc_bullet_300_mag.filters = [gfON];
}
mc_bullet_7_64mm.addEventListener(MouseEvent.CLICK, go_to_item6);
function go_to_item6(event:MouseEvent):void
{
gotoAndStop("Item6");
mc_bullet_7_64mm.filters = [gfON];
}
mc_bullet_300mm.addEventListener(MouseEvent.CLICK, go_to_item7);
function go_to_item7(event:MouseEvent):void
{
gotoAndStop("Item7");
mc_bullet_300mm.filters = [gfON];
}
mc_bullet_308mm.addEventListener(MouseEvent.CLICK, go_to_item8);
function go_to_item8(event:MouseEvent):void
{
gotoAndStop("Item8");
mc_bullet_308mm.filters = [gfON];
}
// END:: BULLET OVER Link Glowing - MOUSE EVENT declaration //
//--------------------------------------------------------------------//
// START :: BULLET menu Easing & Rotation - ENTER_FRAME delay declaration //
TransitionManager.start(mc_bullet_7mm, {type:Fade, direction:Transition.IN, duration:9, easing:Strong.easeOut});
TransitionManager.start(mc_bullet_280mm, {type:Fade, direction:Transition.IN, duration:9, easing:Strong.easeOut});
TransitionManager.start(mc_bullet_270mm, {type:Fade, direction:Transition.IN, duration:9, easing:Strong.easeOut});
TransitionManager.start(mc_bullet_30_06mm, {type:Fade, direction:Transition.IN, duration:9, easing:Strong.easeOut});
TransitionManager.start(mc_bullet_300_mag, {type:Fade, direction:Transition.IN, duration:9, easing:Strong.easeOut});
TransitionManager.start(mc_bullet_7_64mm, {type:Fade, direction:Transition.IN, duration:9, easing:Strong.easeOut});
TransitionManager.start(mc_bullet_300mm, {type:Fade, direction:Transition.IN, duration:9, easing:Strong.easeOut});
TransitionManager.start(mc_bullet_308mm, {type:Fade, direction:Transition.IN, duration:9, easing:Strong.easeOut});
function defaultrotate (event:Event)
{
mc_bullet_7mm.rotation += 1;
mc_bullet_280mm.rotation += 1;
mc_bullet_270mm.rotation += 1;
mc_bullet_30_06mm.rotation += 1;
mc_bullet_300_mag.rotation += 1;
mc_bullet_7_64mm.rotation += 1;
mc_bullet_300mm.rotation += 1;
mc_bullet_308mm.rotation += 1;
}
function continuerotate (event:MouseEvent)
{
mc_bullet_7mm.addEventListener(Event.ENTER_FRAME, defaultrotate);
}
mc_bullet_7mm.addEventListener(MouseEvent.MOUSE_OUT, continuerotate);
mc_bullet_280mm.addEventListener(MouseEvent.MOUSE_OUT, continuerotate);
mc_bullet_270mm.addEventListener(MouseEvent.MOUSE_OUT, continuerotate);
mc_bullet_30_06mm.addEventListener(MouseEvent.MOUSE_OUT, continuerotate);
mc_bullet_300_mag.addEventListener(MouseEvent.MOUSE_OUT, continuerotate);
mc_bullet_7_64mm.addEventListener(MouseEvent.MOUSE_OUT, continuerotate);
mc_bullet_300mm.addEventListener(MouseEvent.MOUSE_OUT, continuerotate);
mc_bullet_308mm.addEventListener(MouseEvent.MOUSE_OUT, continuerotate);
function stoprotate (event:MouseEvent)
{
mc_bullet_7mm.removeEventListener(Event.ENTER_FRAME, defaultrotate);
}
mc_bullet_7mm.addEventListener(MouseEvent.MOUSE_OVER, stoprotate);
mc_bullet_280mm.addEventListener(MouseEvent.MOUSE_OVER, stoprotate);
mc_bullet_270mm.addEventListener(MouseEvent.MOUSE_OVER, stoprotate);
mc_bullet_30_06mm.addEventListener(MouseEvent.MOUSE_OVER, stoprotate);
mc_bullet_300_mag.addEventListener(MouseEvent.MOUSE_OVER, stoprotate);
mc_bullet_7_64mm.addEventListener(MouseEvent.MOUSE_OVER, stoprotate);
mc_bullet_300mm.addEventListener(MouseEvent.MOUSE_OVER, stoprotate);
mc_bullet_308mm.addEventListener(MouseEvent.MOUSE_OVER, stoprotate);
// END:: BULLET menu Easing & Rotation - ENTER_FRAME delay declaration //
//--------------------------------------------------------------------//
// START :: Background Easing in the frame - ENTER_FRAME declaration //
var dest1:Number = 89.95;
addEventListener(Event.ENTER_FRAME, radar_country_enter);
function radar_country_enter(event:Event):void{
if (dest1 != mc_radar_country.y){
var easeNum:Number = 0.9
mc_radar_country.x = mc_radar_country.x * easeNum + dest1 * (1-easeNum);
}
}
var dest2:Number = 89.95;
addEventListener(Event.ENTER_FRAME, radar_rotation_enter);
function radar_rotation_enter(event:Event):void{
if (dest2 != mc_radar_turning.y){
var easeNum:Number = 0.9
mc_radar_turning.x = mc_radar_turning.x * easeNum + dest2 * (1-easeNum);
}
}
import flash.events.Event;
addEventListener(Event.ENTER_FRAME, radar_rotation);
function radar_rotation(event:Event):void
{
mc_radar_turning.rotation +=1;
}
var dest3:Number = 667.85;
addEventListener(Event.ENTER_FRAME, bottom_tween);
function bottom_tween(event:Event):void{
if (dest3 != mc_bottom.y){
var easeNum:Number = 0.9
mc_bottom.y = mc_bottom.y * easeNum + dest3 * (1-easeNum);
}
}
var dest4:Number = 160.2;
addEventListener(Event.ENTER_FRAME, top_tween);
function top_tween(event:Event):void{
if (dest4 != mc_top.y){
var easeNum:Number = 0.8
mc_top.y = mc_top.y * easeNum + dest4 * (1-easeNum);
}
}
var backsound_enter:Sound = new ENTER_FRAME_SONG();
backsound_enter.play();
// END :: Background Easing in the frame - ENTER_FRAME declaration //
问题是,当我转到LABEL Item1时,我点击另一个项目符号(按钮)。它不会播放位于LABEL AS3中的缩放缓动
当我点击另一颗子弹(按钮)时,它也不会发光
import fl.transitions.Tween;
import fl.transitions.easing.*;
import flash.events.Event;
var tweenGrowX:Tween = new Tween(background_items, "scaleX", Elastic.easeIn, 10, 400, 0.2, true);
var tweenGrowY:Tween = new Tween(background_items, "scaleY", Elastic.easeIn, 10, 400, 0.2, true);
function grow_background_items(event:Event)
{
tweenGrowY.start();
tweenGrowX.start();
}
background_items.addEventListener(Event.ENTER_FRAME, grow_background_items);
stop();
function bullet_glow_off(event:MouseEvent):void
{
mc_bullet_7mm.filters = [gfOFF];
mc_bullet_280mm.filters = [gfOFF];
mc_bullet_270mm.filters = [gfOFF];
mc_bullet_30_06mm.filters = [gfOFF];
mc_bullet_300_mag.filters = [gfOFF];
mc_bullet_7_64mm.filters = [gfOFF];
mc_bullet_300mm.filters = [gfOFF];
mc_bullet_308mm.filters = [gfOFF];
}
mc_bullet_280mm.addEventListener(MouseEvent.CLICK, bullet_glow_off);
mc_bullet_270mm.addEventListener(MouseEvent.CLICK, bullet_glow_off);
mc_bullet_30_06mm.addEventListener(MouseEvent.CLICK, bullet_glow_off);
mc_bullet_300_mag.addEventListener(MouseEvent.CLICK, bullet_glow_off);
mc_bullet_7_64mm.addEventListener(MouseEvent.CLICK, bullet_glow_off);
mc_bullet_300mm.addEventListener(MouseEvent.CLICK, bullet_glow_off);
mc_bullet_308mm.addEventListener(MouseEvent.CLICK, bullet_glow_off);
stop();
答案 0 :(得分:0)
我已经获得了明确的印象,即您将代码放入MainTimeline上的各种框架中。这是一个令人头疼的问题。
如前所述,您不需要执行类似任务的相同功能的多个副本。相反,您可以通过使用在循环期间引用每个对象的变量来简化代码(从而在循环中执行类似的任务)。
根据您的background_items
存在的DisplayList层次结构中的位置,您需要更改相对于运行代码的MainTimeline框架的dot.notation路径。每次重新加载动画时,您可能都希望重置background_items
的缩放比例,否则它似乎不会进行转换。
另外,我鼓励你崩溃"一次性运行"片段成单一功能。特别是当你开始重置你的舞台时,将它们放在一个地方将是非常宝贵的。
试一试......
stop();
init();
import fl.transitions.*;
import fl.transitions.easing.*;
import flash.events.Event;
// Whether the 7mm should be allow the other clips to rotate.
var rotate7mm:Boolean = true;
// This array holds references to the clips we'll handle, and their related goto frames.
var bullets:Array = [
{
"clip":mc_bullet_7mm,
"frame":"Item1"
},
{
"clip":mc_bullet_280mm,
"frame":"Item2"
},
{
"clip":mc_bullet_270mm,
"frame":"Item3"
},
{
"clip":mc_bullet_30_06mm,
"frame":"Item4"
},
{
"clip":mc_bullet_300_mag,
"frame":"Item5"
},
{
"clip":mc_bullet_7_64mm,
"frame":"Item6"
},
{
"clip":mc_bullet_300mm,
"frame":"Item7"
},
{
"clip":mc_bullet_308mm,
"frame":"Item8"
}
]
function init():void {
// Everything that should happen once
var backsound_enter:Sound = new ENTER_FRAME_SONG();
backsound_enter.play();
addEventListener(Event.ENTER_FRAME, tick);
for each {var entry:Object in bullets} {
entry.clip.addEventListener(MouseEvent.CLICK, go_to_item)
entry.clip.addEventListener(MouseEvent.MOUSE_OUT, toggleRotation);
entry.clip.addEventListener(MouseEvent.MOUSE_OVER, toggleRotation);
TransitionManager.start(entry.clip, {type:Fade, direction:Transition.IN, duration:9, easing:Strong.easeOut});
}
}
function go_to_item(e:MouseEvent):void {
// Handles glowing the clicked button, and turning off the glow to the ones not selected.
var gfON:GlowFilter = new GlowFilter(
0xFFFFFF, // Color
0.3, // Alpha
20, // BlurX
20, // BlurY
3, // Strength
BitmapFilterQuality.HIGH, // Quality
false, // Inner
false // Knockout
);
var gfOFF:GlowFilter = new GlowFilter(
0x000000, // Color
0, // Alpha
0, // BlurX
0, // BlurY
0, // Strength
BitmapFilterQuality.HIGH, // Quality
false, // Inner
false // Knockout
);
for each (var entry:Object in bullets) {
if (e.currentTarget == entry.clip) {
gotoAndStop(entry.frame)
entry.clip.filters = [gfON];
// Animate the background in
var tweenGrowX:Tween = new Tween(background_items, "scaleX", Elastic.easeIn, 10, 400, 0.2, true);
tweenGrowX.start();
var tweenGrowY:Tween = new Tween(background_items, "scaleY", Elastic.easeIn, 10, 400, 0.2, true);
tweenGrowY.start();
} else {
entry.clip.filters = [gfOFF]
}
}
}
function toggleRotation(e:Event):void {
// Rather than registering another function for enterframe events, we simply set a boolean which tells the existing tick() function to run the rotation transforms.
switch (e.type) {
case "mouseOut":
rotate7mm = true;
break;
case "mouseOver":
rotate7mm = false;
break;
}
}
function tick(e:Event):void {
// Anything that needs to happen in a frame update occurs in this function.
mc_radar_turning.rotation +=1;
var radarDest:Number = 89.95; // Radar Dest
var bottomDest:Number = 667.85; // Bottom Dest
var topDest:Number = 160.2; // Top Dest
var easeNumSlow:Number = 0.9
var easeNumFast:Number = 0.8
// Country Enter
if (radarDest != mc_radar_country.y) {
mc_radar_country.x = mc_radar_country.x * easeNumSlow + radarDest * (1-easeNumSlow);
}
// Radar Rotation
if (radarDest != mc_radar_turning.y) {
mc_radar_turning.x = mc_radar_turning.x * easeNumSlow + radarDest * (1-easeNumSlow);
}
// Bottom Tween
if (dest3 != mc_bottom.y) {
mc_bottom.y = mc_bottom.y * easeNumSlow + dest3 * (1-easeNumSlow);
}
// Top Tween
if (topDest != mc_top.y) {
mc_top.y = mc_top.y * easeNumFast + topDest * (1-easeNumFast);
}
// 7mm Rotation
if (rotate7mm) {
for each (var entry:Object in bullets) {
entry.clip.rotation += 1;
}
}
}