PHP User Warning: fetch_template() calls should be replaced by the vB_Template class. Template name: bbcode_highlight in ..../includes/functions.php on line 4197
Why aren't movieclips fading out using tween class
A Flash Developer Resource Site

Results 1 to 8 of 8

Thread: Why aren't movieclips fading out using tween class

  1. #1
    Senior Member
    Join Date
    Apr 2001
    Posts
    260

    Why aren't movieclips fading out using tween class

    Hello,

    I've just started on my first AS3 project and have already run into a problem. Can someone please tell me why the following code is not working correctly. What's NOT happening is that the mc that is passed to the scalethis function is NOT alpha'ing to 0 and I can't for the life of me understand why.
    PHP Code:
    package 
    {
        
    import flash.display.*;
        
    import flash.events.*;
        
    import fl.transitions.Tween;
        
    import fl.transitions.easing.*;
        
    import fl.transitions.TweenEvent;
        
        public class 
    main extends MovieClip
        
    {
            
            public function 
    main()
            {
                for (var 
    1i<11i++)
                {
                    var 
    = ["plan"+i];
                    
    scalethis(p"alpha"01Strong.easeOut);
                }
            }

            public function 
    scalethis(mcpropendtimetype):void
            
    {
                var 
    sT:Tween = new Tween(mcproptypemc[prop], endtimetrue);
            }

            
        }

    Any help would be greatly appreciated.

    Cheers
    Matt

  2. #2
    Total Universe Mod jAQUAN's Avatar
    Join Date
    Jul 2000
    Location
    Honolulu
    Posts
    2,429
    What do you see when you insert a trace right after you assign p?

    var p = ["plan"+i];
    trace("p is", p);

  3. #3
    :
    Join Date
    Dec 2002
    Posts
    3,518
    Code:
    package {
    	import flash.display.*;
    	import flash.events.*;
    	import fl.transitions.Tween;
    	import fl.transitions.easing.*;
    	import fl.transitions.TweenEvent;
    
    	public class main extends MovieClip {
    
    		public function main() {
    			for (var i:int = 1; i<11; i++) {
    				var p:DisplayObject=this["plan"+i];
    				scalethis(p, "alpha", 0, 1, Strong.easeOut);
    			}
    		}
    
    		public function scalethis(mc:DisplayObject, prop:String, end:Number, time:Number, type:Function):void {
    			var sT:Tween=new Tween(mc,prop,type,mc[prop],end,time,true);
    		}
    	}
    }

  4. #4
    Senior Member
    Join Date
    Apr 2001
    Posts
    260
    Thanks for your responses guys, but unfortunately that's still not working. When I trace p I get [object MovieClip] 10 times.

    This is infuriating.

    I've tried calling the scalethis function separately like this:
    PHP Code:
    package 
    {
        
    import flash.display.*;
        
    import flash.events.*;
        
    import fl.transitions.Tween;
        
    import fl.transitions.easing.*;
        
    import fl.transitions.TweenEvent;

        public class 
    main extends MovieClip 
        
    {

            public function 
    main() 
            {
                for (var 
    i:int 1i<11i++) 
                {
                    var 
    p:DisplayObject=this["plan"+i];
                    
    scalethis(p"alpha"01Strong.easeOut);
                }
            }
            
            
    scalethis(plan1"alpha"01Strong.easeOut);
            
            public function 
    scalethis(mc:DisplayObjectprop:Stringend:Numbertime:Numbertype:Function):void 
            
    {
                
    trace(mc);
                var 
    sT:Tween=new Tween(mc,prop,type,mc[prop],end,time,true);
            }
        }

    But it's still not manipulating the object on stage. What on earth am I doing wrong?
    Last edited by madmath; 06-03-2010 at 03:41 AM.

  5. #5
    Senior Member
    Join Date
    Apr 2001
    Posts
    260
    Ok, verrrry strange. It won't work if I hit cmd+enter but once testing if I hit cmd+enter a second time it works. No idea why that is - can anyone shed some light on that issue?

    Cheers
    matt

  6. #6
    Total Universe Mod jAQUAN's Avatar
    Join Date
    Jul 2000
    Location
    Honolulu
    Posts
    2,429
    You can't have this line:
    scalethis(plan1, "alpha", 0, 1, Strong.easeOut);
    floating outside of a method enclosure.

    I took that out and it worked just fine for me.

  7. #7
    Senior Member
    Join Date
    Apr 2001
    Posts
    260
    Quote Originally Posted by jAQUAN View Post
    You can't have this line:
    scalethis(plan1, "alpha", 0, 1, Strong.easeOut);
    floating outside of a method enclosure.

    I took that out and it worked just fine for me.
    What do you mean? Where did you put it instead?
    So can I not just call functions that are in the 'main' class?
    Just starting out on the long road that is AS3 - and already want to turn back!!!
    FrApple - get a free iPad

  8. #8
    Flash/Flex Developer samac1068's Avatar
    Join Date
    Apr 2007
    Location
    Here, no there
    Posts
    1,813
    This line 'scalethis(plan1, "alpha", 0, 1, Strong.easeOut); ' sits outside of both functions (main and scalethis). Because this is a class file, and is not a declaration, it needs to appear within a function. I suggest moving it up a little into the main function, like this:

    Actionscript Code:
    public function main()
            {
                for (var i:int = 1; i<11; i++)
                {
                    var p:DisplayObject=this["plan"+i];
                    scalethis(p, "alpha", 0, 1, Strong.easeOut);
                }
                scalethis(plan1, "alpha", 0, 1, Strong.easeOut);
            }
    Some people are like Slinkies, not really good for anything, but they bring a smile to your face when pushed down the stairs.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  




Click Here to Expand Forum to Full Width

HTML5 Development Center