Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

Switch out a symbol button

Explorer ,
Apr 16, 2015 Apr 16, 2015

How do i create a button that would switch out a symbol in a flash animation??

TOPICS
ActionScript
865
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Apr 16, 2015 Apr 16, 2015

Can you describe the situation with more detail?  What code would you use to switch out the symbol without a button?

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Apr 16, 2015 Apr 16, 2015

AS3 - want to show 4 different shoes at the beginning of movie, you click on one and the person in the animation wears that pair of shoes for the remainder of movie.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Apr 16, 2015 Apr 16, 2015

How is the animation done?  Does it involve timeline tweening?

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Apr 16, 2015 Apr 16, 2015

yes the shoe does move back and forth. It is actually for demonstrating how a hydraulic brake line works. Thought it would be kind of fun in the beginning to be able to pick a shoe.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Apr 16, 2015 Apr 16, 2015

This is the movie AC hydraulicBrakeSystem

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Apr 16, 2015 Apr 16, 2015

One simple way of managing this would be to have the shoe as a movieclip with 4 frames.  Each frame would be a different colored shoe and the first frame would have a stop(); command in it.  Then create the 4 buttons by using the same shoe movieclip 4 times.  Give the instance name "shoe" to the one in the diagram, and name the buttons "b1" thru "b4".  The code for the buttons and changing the shoe color could be...

for(var i:int=1; i<5; i++){

     this["b"+String(i)].gotoAndStop(i); // to adjust the button color choices

     this["b"+String(i)].addEventListener(MouseEvent.CLICK, changeColor); // assign listeners to buttons

}

function changeColor(evt:MouseEvent):void {

     shoe.gotoAndStop(Movieclip(evt.currentTarget).currentFrame);  // change the shoe frame

}

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Apr 16, 2015 Apr 16, 2015

Great idea! i will give it a try, thanks.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Apr 16, 2015 Apr 16, 2015

got this error: 1180: Call to a possible undefined method Movieclip column 23 of this line:

     shoe.gotoAndStop(Movieclip(evt.currentTarget).currentFrame);  // change the shoe frame

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Apr 16, 2015 Apr 16, 2015

A typo on my part.... That should be MovieClip

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Apr 17, 2015 Apr 17, 2015

Hey Ned, thanks again for your assistance. I don't get any errors now but the four buttons i made all are showing the first shoe and when rolled over they cycle through the 4 shoes and when clicked the "shoe" on the brake pedal doesn't change. Any idea what i am doing wrong? Here it the animation AC hydraulicBrakeSystem Thanks

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Apr 17, 2015 Apr 17, 2015

What code are you using?  Rollovers appear to be used but were not part of what I offered and are likely to interfere.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Apr 17, 2015 Apr 17, 2015

as3, and wish I knew it better than I do. 

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Apr 17, 2015 Apr 17, 2015

I mean the actual code... show it.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Apr 17, 2015 Apr 17, 2015

I made a quick example file for you to look at using the code I showed (with the fix)...

http://www.nedwebs.com/Flash/AS3_change_shoe.fla

in case you missed doing it, be sure to check how the instance names are assigned for each object on the stage... select one and look in the Properties panel for its name.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Apr 17, 2015 Apr 17, 2015

Got it, thanks so much. What i did wrong is made the 4 shoes with the movie clip inside of a button instead of just leaving the 4 shoe movie clips on the stage. Thanks, again.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Apr 17, 2015 Apr 17, 2015
LATEST

You're welcome

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines