Home Tutorials Forums Articles Blogs Movies Library Employment Press

Go Back   ActionScript.org Forums > ActionScript Forums Group > ActionScript 3.0

Reply
 
Thread Tools Rate Thread Display Modes
Old 01-15-2011, 01:13 PM   #1
Loken
Registered User
 
Join Date: Jan 2011
Posts: 4
Default Trouble Implementing Tween Script

Hey, I'm new to actionscript to please forgive any amateur mistakes ^^

I want to implement a class that creates tweens (to fade in an alpha change on some nav buttons) and then use 'evt.target.name' in the function rather than having to copy it 5 times for each of my buttons.

Here is the code..

ActionScript Code:
import caurina.transitions.*; home_btn.alpha = 0; home_btn.addEventListener(MouseEvent.MOUSE_OVER, alphaIn); home_btn.addEventListener(MouseEvent.MOUSE_OUT, alphaOut); about_btn.alpha = 0; about_btn.addEventListener(MouseEvent.MOUSE_OVER, alphaIn); about_btn.addEventListener(MouseEvent.MOUSE_OUT, alphaOut); services_btn.alpha = 0; services_btn.addEventListener(MouseEvent.MOUSE_OVER, alphaIn); services_btn.addEventListener(MouseEvent.MOUSE_OUT, alphaOut); gallery_btn.alpha = 0; gallery_btn.addEventListener(MouseEvent.MOUSE_OVER, alphaIn); gallery_btn.addEventListener(MouseEvent.MOUSE_OUT, alphaOut); contact_btn.alpha = 0; contact_btn.addEventListener(MouseEvent.MOUSE_OVER, alphaIn); contact_btn.addEventListener(MouseEvent.MOUSE_OUT, alphaOut); function alphaIn(evt:Event):void { Tweener.addTween(evt.target.name, {alpha:1, time:0.2, transition:"easeInOutQuad"}); } function alphaOut(evt:Event):void { Tweener.addTween(evt.target.name, {alpha:0, time:0.2, transition:"easeInOutQuad"}); }

As you can see, it calls the class at the beginning so that is not an issue. I have tried it with 'home_btn' instead of 'evt.target.name' and it works fine, so it is just a problem with that part of the code. Here is the error I am receiving when rolling over and out of the buttons:

ActionScript Code:
ReferenceError: Error #1069: Property alpha not found on String and there is no default value.     at caurina.transitions::Tweener$/addTween()     at FlashHeader_fla::MainTimeline/alphaIn() ReferenceError: Error #1069: Property alpha not found on String and there is no default value.     at caurina.transitions::Tweener$/addTween()     at FlashHeader_fla::MainTimeline/alphaOut()
Loken is offline   Reply With Quote
Old 01-15-2011, 01:39 PM   #2
henke37
Senior Member
 
henke37's Avatar
 
Join Date: Mar 2009
Location: Sweden
Posts: 10,679
Send a message via Skype™ to henke37
Default

Do you understand the diference between a string and an object reference?
__________________
Signature: I wrote a pair of articles about the timeline.
henke37 is offline   Reply With Quote
Old 01-15-2011, 01:43 PM   #3
Loken
Registered User
 
Join Date: Jan 2011
Posts: 4
Default

Apparently not hah ;P Any help would be great
Loken is offline   Reply With Quote
Old 01-15-2011, 02:00 PM   #4
ASWC
Super Moderator
 
ASWC's Avatar
 
Join Date: Dec 2007
Location: Greenville, SC
Posts: 6,528
Default

evt.target is what you want to tween. evt.target.name is the name of the object and there's nothing to tween in a name since it's a string.
__________________
aswebcreations
Super Duper!
ASWC is offline   Reply With Quote
Old 01-15-2011, 02:07 PM   #5
Loken
Registered User
 
Join Date: Jan 2011
Posts: 4
Default

Riiight, so if i just use evt.target instead of the name?

This is me spending too much time learning PHP lately, I assumed that would substitute 'evt.target.name' with the string, which would be the same as typing 'home_btn'

Works perfect now, thanks for the help
Loken is offline   Reply With Quote
Old 01-15-2011, 02:12 PM   #6
henke37
Senior Member
 
henke37's Avatar
 
Join Date: Mar 2009
Location: Sweden
Posts: 10,679
Send a message via Skype™ to henke37
Default

That logic doesn't work in php either.
__________________
Signature: I wrote a pair of articles about the timeline.
henke37 is offline   Reply With Quote
Old 01-15-2011, 02:17 PM   #7
Loken
Registered User
 
Join Date: Jan 2011
Posts: 4
Default

Well if I were to type time() it would substitute it with the time, but regardless, the problem has been solved now, thanks.
Loken is offline   Reply With Quote
Reply


Thread Tools
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT. The time now is 02:14 AM.

///
Follow actionscriptorg on Twitter

 


Powered by vBulletin® Version 3.8.5
Copyright ©2000 - 2014, Jelsoft Enterprises Ltd.
Ad Management plugin by RedTyger
Copyright 2000-2013 ActionScript.org. All Rights Reserved.
Your use of this site is subject to our Privacy Policy and Terms of Use.