0

I'm Actually a student in Multimedia Design, and we are having a project to render within 3 weeks called interactive animation.

Well I'M trying to have different effect.

Glowing with easing
Scaling with easing
using alpha

I only use the Adobe manual, and some answer that as been posted here.

This is my code

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 //

The problem is that when i click on another bullet (button) when it goes to LABEL Item1. It doesn't play the scale easing that is located into the LABEL AS3

And also when i click on another bullet (button) it's doesn't glow off

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();
gunr2171
  • 16,104
  • 25
  • 61
  • 88
Arsenil98
  • 16
  • 6
  • AS3 =/= JavaScript. Tag removed. – Cerbrus Sep 02 '15 at 12:06
  • You have so many enter frame listeners. That won't work correctly, and I don't see you removing them either. Use a single enter frame and put all your relevant code inside it to begin with. And remove it when done. – Gurtej Singh Sep 02 '15 at 12:28

1 Answers1

0

I've got the distinct impression you're placing code into various frames on your MainTimeline. This is a headache to be avoided.

As has been recommended before, you don't need multple copies of the same function that perform similar tasks. Rather, you can simplify your code by using variables that reference each object during a loop (thus performing the similar tasks in the loop).

Depending on where in your DisplayList hierarchy your background_items exists, you'll want to change the dot.notation pathing relative to the MainTimeline frame where your code is running. You'll likely want to reset the scaling of background_items every time you reload the animation, otherwise it'd appear not to be doing its transform.

Additionally, I encourage you to collapse "run-once" fragments into a single function. Especially when you begin resetting your stage, having them in one place will be invaluable.

Give this a try...

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;
        }
    }
}
Atriace
  • 2,572
  • 1
  • 14
  • 27