-
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 i = 1; i<11; i++)
{
var p = ["plan"+i];
scalethis(p, "alpha", 0, 1, Strong.easeOut);
}
}
public function scalethis(mc, prop, end, time, type):void
{
var sT:Tween = new Tween(mc, prop, type, mc[prop], end, time, true);
}
}
}
Any help would be greatly appreciated.
Cheers
Matt
-
Total Universe Mod
What do you see when you insert a trace right after you assign p?
var p = ["plan"+i];
trace("p is", p);
-
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);
}
}
}
-
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 = 1; i<11; i++)
{
var p:DisplayObject=this["plan"+i];
scalethis(p, "alpha", 0, 1, Strong.easeOut);
}
}
scalethis(plan1, "alpha", 0, 1, Strong.easeOut);
public function scalethis(mc:DisplayObject, prop:String, end:Number, time:Number, type: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.
-
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
-
Total Universe Mod
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.
-
Originally Posted by jAQUAN
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?
-
Flash/Flex Developer
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
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|