[Tweener] FW: AS 3 If/Else issues with Tweener - Part two
Gerry Creighton
gerry at thespikeranch.com
Thu Nov 13 07:01:20 PST 2008
Nathan,
I don't think I mentioned in the code sample that I had posted that I
made a basic movieClip
symbol in the library of the fla and gave it the class name BlueBtn.
Once you do that you place it on
the stage using code... ie
var blue:BlueBtn = new BlueBtn();
blue.x = 166;
blue.y = 23;
addChild(blue);
You have conflicting names for blue in your sample code. blue can't be
a MovieClip and a new BlueBtn();
like you have in this line: var blue:MovieClip = new BlueBtn();
That line is used to say "here's a var blue it is a BlueBtn";
Your line says "here's a var blue that is a movieClip but is a new
BlueBtn()" Flash no likey.
-Gerry
On Nov 13, 2008, at 4:17 AM, Nathan Thompson wrote:
>
> Hey all. Thanks very much to Gerry (props for the sample movie) and
> Cedric for their help.
>
> I have managed to get it to work! BUT... And this is the last time
> you hear about if because if I can’t fix this I may have to resort
> to timelining (shudder).
>
> I have the following working great.
>
>
> var blue:MovieClip = new BlueBtn();
> blue.x = 166;
> blue.y = 23;
> blue.addEventListener(MouseEvent.MOUSE_UP,moveBtn);
> // if you want a hand cursor
> blue.buttonMode = true;
> blue.useHandCursor = true;
> addChild(blue);
> //
> function moveBtn(e:MouseEvent):void {
> var btn = e.target;
> if (btn.x == 166) {
> Tweener.addTween(btn, {x:638, time:1});
> Tweener.addTween(blue_content_MC, {x:166, time:1});
> } else if (btn.x == 638) {
> Tweener.addTween(btn, {x:166, time:1});
> Tweener.addTween(blue_content_MC, {x:-311, time:1});
> }
> }
>
>
> What I assumed was that to re-create that for 6 other elements
> (pink, grey, yellow etc...) I would copy/paste then swap out the
> mentions of blue for the colour required (all movie clips are named
> the same format)
>
> But I get this...
> 1021: Duplicate function definition. function
> moveBtn(e:MouseEvent):void {
>
> So I change the function to movePinkBtn
>
> And I get...
> 1180: Call to a possibly undefined method PinkBtn. var
> pink:MovieClip = new PinkBtn();
>
>
> Anyhoo – files are at http://www.mymindseye.co.uk/tween/tween.zip if
> anyone fancies a look.
>
> Thanks again people.
>
> ------ End of Forwarded Message
> _______________________________________________
> Tweener mailing list
> Tweener at lists.caurinauebi.com
> http://lists.caurinauebi.com/listinfo.cgi/tweener-caurinauebi.com
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.caurinauebi.com/pipermail/tweener-caurinauebi.com/attachments/20081113/6f5ca09a/attachment.htm>
More information about the Tweener
mailing list