Creating a reusable effect in ActionScript with Move class : Effect « Effects « Flex






Creating a reusable effect in ActionScript with Move class

Creating a reusable effect in ActionScript with Move class
   

<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml">
    <mx:Script>
        
        import flash.events.Event;
        import mx.effects.Effect;
        import mx.effects.Move;
        private var myMove:Move = new Move();
        private function playMove(target:Object,newX:Number, newY:Number):void {
            myMove.end();
            myMove.target = target;
            myMove.duration = 4000;
            myMove.xTo = newX - target.width/2;
            myMove.yTo = newY - target.height/2;
            myMove.play();
        }
        private function handleClick(eventObj:Event):void {
            var targetComponent:Object = eventObj.currentTarget;
            var parentCont:Object = targetComponent.parent;
            playMove(eventObj.target, parentCont.width/2, parentCont.height/2);
        }
      
    </mx:Script>
    <mx:Canvas width="200" height="200">
        <mx:Button id="myButton" label="Center me" click="handleClick(event);" />
    </mx:Canvas>
</mx:Application>

   
    
    
  








Related examples in the same category

1.Creating an instance of an effect using pure ActionScriptCreating an instance of an effect using pure ActionScript
2.Define effect in MXML, use ActionScript to apply itDefine effect in MXML, use ActionScript to apply it
3.Effect With ActionScript
4.Use ActionScript to play EffectUse ActionScript to play Effect
5.Grouping effects and playing them one after anotherGrouping effects and playing them one after another
6.Playing multiple effects at the same timePlaying multiple effects at the same time
7.Use a class selector to apply effectsUse a class selector to apply effects
8.Using MXML to define the effectUsing MXML to define the effect
9.Applying behaviors using the Effect.target and Effect.targets propertiesApplying behaviors using the Effect.target and Effect.targets properties
10.Setting effect durationsSetting effect durations
11.Add show effect to a controlAdd show effect to a control
12.Play effect for more than one controlsPlay effect for more than one controls
13.Set effect targetSet effect target
14.Reverse an EffectReverse an Effect
15.Pause an EffectPause an Effect
16.Composite EffectsComposite Effects
17.Enable Composite EffectsEnable Composite Effects
18.Using the Pause effect to pause between two other effectsUsing the Pause effect to pause between two other effects
19.Using easing functions with the Move effect to make motion less linearUsing easing functions with the Move effect to make motion less linear
20.rollOverEffect and rollOutEffectrollOverEffect and rollOutEffect
21.Create, configure, and apply effects to Flex componentsCreate, configure, and apply effects to Flex components
22.Mouse down effect for an Image controlMouse down effect for an Image control
23.specify the mx.effects.easing.Bounce.easeOut() method to the Accordionspecify the mx.effects.easing.Bounce.easeOut() method to the Accordion
24.Chart show data effectChart show data effect
25.Check property in effect filer functionCheck property in effect filer function
26.SeriesInterpolate effectSeriesInterpolate effect
27.Apply Shadow effectApply Shadow effect
28.Insertion's effect on the Array and the ArrayCollection representation of the ArrayInsertion's effect on the Array and the ArrayCollection representation of the Array
29.Applying MX effects in MXMLApplying MX effects in MXML
30.List Effect Custom and Default EffectsList Effect Custom and Default Effects
31.Easing function that creates a bounce motion when combined with the Flex Move effectEasing function that creates a bounce motion when combined with the Flex Move effect
32.Repeat EffectsRepeat Effects
33.Applying transform effectsApplying transform effects