PDA

View Full Version : Basic Tween problem for AS3.0 beginner



thursday0384
July 31st, 2008, 08:05 AM
hey i'm new to as3.0 just like this guy was (http://www.kirupa.com/forum/showthread.php?t=280037&page=1) and i was trying to do the same thing. however, i WAS starting out w/ a movie clip. the original mc was called us_mc and then i gave it an instance name of pic_mc

Problem is i keep getting the following error message from flash cs3:

Error Message:
1120: Access of undefined property pic_mc.

For Source:

outTween = new Tween(pic_mc, "alpha", None.easeNone,1,0,1,true);

and

pic_mc.addEventListener(MouseEvent.MOUSE_OVER, fadeOut);



here's my code:


import fl.transitions.Tween;
import fl.transitions.easing.*;

import fl.transitions.Tween;
import fl.transitions.easing.*;

var outTween:Tween;

pic_mc.addEventListener(MouseEvent.MOUSE_OVER, fadeOut);


function fadeOut(event:MouseEvent):void
{
outTween = new Tween(pic_mc, "alpha", None.easeNone,1,0,1,true);
}
what am i doing wrong?!?!?! i'm very new to AS3.0, and any help would be greatly appreciated b/c this is really frustrating

Magik5
July 31st, 2008, 08:14 AM
i just copy'd and pasted your code in to a new document and it works fine,

youve probably got the code on a frame where the scope of the pic_mc is not visible

basically make sure you pic_mc is on stage at the time the code is called =]

Pier25
July 31st, 2008, 09:39 AM
dude... use any tween engine except the one you're using... there are tons out there and all of them are far better (performance, features, ease of use) than the included one.

Check out this thread. It started for as2 but there's a post from prg9 that explains the whole tween engine thingy in detail:
http://www.kirupa.com/forum/showthread.php?t=296156

In as2 I used Fuse, but now I only use TweenLite/Max from Greensock in both worlds as2/as3

Alex Lexcuk
July 31st, 2008, 09:52 AM
Test standart Tween it's works mega good
http://kind-armadillo.pochta.ru/FlaAC3/tweenDemo.swf
http://kind-armadillo.pochta.ru/FlaAC3/tweenDemo.rar

http://dnadillo.dn.ua/fla/js-swf-html/tween-amplitude-regulator.swf
http://dnadillo.dn.ua/fla/js-swf-html/tween-amplitude-regulator.zip

http://murmadillo.tut.su/fla/tween_event.swf
http://murmadillo.tut.su/fla/tween_event.zip

http://www.dnadillo.dn.ua/fla/TextField-BitmapData.html

http://www.dnadillo.dn.ua/fla/rain-snow-sheet.html

fs_tigre
July 31st, 2008, 10:02 AM
New to AS3? Use TweenLite/Max http://blog.greensock.com/tweening-family-comparison/

It is very easy to use.

Pier25
July 31st, 2008, 10:16 AM
Test standart Tween it's works mega good

mega good?

http://blog.greensock.com/tweening-speed-test/

It's the worst in terms of performance... by far.

It's the worst in terms of features...

And you have to write more code...

it's mega bad! :)

thursday0384
July 31st, 2008, 11:26 AM
i just copy'd and pasted your code in to a new document and it works fine,

youve probably got the code on a frame where the scope of the pic_mc is not visible

basically make sure you pic_mc is on stage at the time the code is called =]

thanks for the reply, so would using an addChild() be necessary to make sure my pic is on stage.

and what's a good way to learn how to troubleshoot stuff in regards to understanding what the error messages are really trying to say? is it just experience and trial and error?


thanks everyone for the replies!!! further assistance would be awesome.


thanks!

Magik5
July 31st, 2008, 01:13 PM
if you wanted to addChild(), you would have to give the movieclip a linkage name in the library, then do something like:


var picMC:PicMC = new PicMC();
addChild(picMC);

where PicMC is the movieclip linkage name, and picMC is the instance of that movieclip...

as for trouble shooting, the more you come across the same errors, the more you know how to fix them.
in this case whenever i see "Access of undefined property" i know either ive spelt a name wrong or it cant find what im trying to reference at that point in the timeline.
tbh most of it is down to experience and you pick things up as you go along =]

thursday0384
July 31st, 2008, 05:54 PM
thanks for the reply. well i'm glad to know that what i was doing in all of this wasn't too far off. i guess i figured that since i could see the photo that i imported to the stage, that somehow it was in the display list. ooops total beginner move.

now that i have time to try it out, i typed in the following code into my actions panel and my library only has a movie clip in it.

that being said when i export the movie i DON'T get any error messages but my movie clip still doesn't appear on the stage.

what's wrong? why isn't the movie clip in my library not showing up on the stage?


here's my code now:


import fl.transitions.Tween;
import fl.transitions.easing.*;

var outTween:Tween;
var picMC:PicMC = new PicMC();
addChild(picMC);

picMC.addEventListener(MouseEvent.MOUSE_OVER, fadeOut);


function fadeOut(event:MouseEvent):void
{
outTween = new Tween(picMC, "alpha", None.easeNone,1,0,1,true);
}



by the way the class in my linkage window is called PicMC and the base class is flash.display.MovieClip. is that the way you were telling me to do it in your first description?


also, why isn't the datatype in your earlier example a MovieClip or something

why write


var picMC:PicMC = new PicMC();

and not

var picMC:MovieClip = new MovieClip();
and as a rule in AS 3.0 does every tween i make need to be put in its own variable??

so i saw people talk about tweening engines in my first post and i had no clue what that meant but i had general idea. that being said, what are the benefits of a tweening engine? some practical uses? can anyone offer some links or reading about what tween engines do and such?

thanks !!!