Hi,
 
- You need import the class your subclassing.
- Effects API has changed a little, there are some changes in method signatures.
- You need override keyword while overriding a method in subclass.
- _rotation is changed to rotation
- You need to surrounding <mx:Effects> tag anymore
- name attribute of effects has been deprecated and instead "id" attribute is recommended.
 
 
 
<?xml version="1.0"?>
<mx:Application xmlns:mx="http://www.macromedia.com/2005/mxml" xmlns="com.peterelst.*">   
    <Rotate id="myRotateEffect" rotateBy="1000" duration="1000" />
  <mx:Image id="myAnimation" source="@Embed('flash_platform.jpg')" mouseDownEffect="myRotateEffect" />
</mx:Application>
 
Untested code:
 
 
package com.peterelst {
    import mx.effects.*;

    public class Rotate extends mx.effects.TweenEffect {
       
       var target:Object;
       var rotateBy:Number;
       var rotateTween:mx.effects.Tween;
           
    function Rotate(targetObj:Object)   {
          target = targetObj;
       }
           
       override public function playEffect(targets:Array = null):Array
       {
            rotateTween = new mx.effects.Tween(this, target._rotation,
            target._rotation+rotateBy, duration);
       }
          
       function onTweenUpdate(tweenValue):Void   {
          target._rotation = tweenValue;
       }
          
    }

}
 
 


From: [email protected] [mailto:[EMAIL PROTECTED] On Behalf Of Peter Elst
Sent: Thursday, October 20, 2005 1:19 AM
To: [email protected]
Subject: Re: [flexcoders] custom effect in Flex Builder 2

Thanks for those pointers Phil -- it still gives me a "base class not found" error in the AS file (on the class definition) when I try to make it public. I've got my updated code below.

The strange thing is that if I do an import of mx.effects.* first and extend TweenEffect it doesn't give that base class error but "conflict with inherited definition target in namespace public" for the target property and "incompatible override" and "overriding function that is not marked for override" for the playEffect method.


testEffect.mxml

<?xml version="1.0"?>
<mx:Application xmlns:mx="http://www.macromedia.com/2005/mxml" xmlns="com.peterelst.*">  
  <mx:Effect>
    <Rotate name="myRotateEffect" rotateBy="1000" duration="1000" />
  </mx:Effect>
  <mx:Image id="myAnimation" source="@Embed('flash_platform.jpg')" mouseDownEffect="myRotateEffect" />
</mx:Application>


Rotate.as

package com.peterelst {

    public class Rotate extends mx.effects.TweenEffect {
       
       var target:Object;
       var rotateBy:Number;
       var rotateTween:mx.effects.Tween;
          
       function Rotate(targetObj:Object)   {
          target = targetObj;
       }
          
       function playEffect():Void   {
            rotateTween = new mx.effects.Tween(this, target._rotation,
            target._rotation+rotateBy, duration);
       }
          
       function onTweenUpdate(tweenValue):Void   {
          target._rotation = tweenValue;
       }
          
    }

}






On 10/19/05, Philip Costa <[EMAIL PROTECTED]> wrote:
You have to mark your class public.
 
The default in AS3 is private, so that's why your MXML page can't see it.
 
Phil Costa
Sr. Product Manager
Macromedia



--
Flexcoders Mailing List
FAQ: http://groups.yahoo.com/group/flexcoders/files/flexcodersFAQ.txt
Search Archives: http://www.mail-archive.com/flexcoders%40yahoogroups.com




SPONSORED LINKS
Web site design development Computer software development Software design and development
Macromedia flex Software development best practice


YAHOO! GROUPS LINKS




Reply via email to