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

Car Customization (Flash Game) Problem

New Here ,
May 10, 2014 May 10, 2014

I'm currently making a car customization flash game, i've already done the coloring part (while user click "Red", the car become "Red").

The problem is i want to add an animation before changing the color, eg: when user click "Red", a sprayer is going left to right, and the car become "Red" after that. So i make a movie clip named "Spray", and i got 5 labels "Red", "Green", "Yellow", "Orange", "Blue" in following order, i add the movie clip in every label, but it look weird because when user click "Red", it play the movie clip and become "Red", after that user click "Orange", the car will become "Black" (Black is default color of the car) when playing the movie clip. And user click "Green", it become "Black" again before changing to "Green". It always become default color when user choose other colors.

What i want is remain the car's color when user choose the other color, eg: when user choose "Red", it play the movie clip first, and become "Red", after that user choose "Orange", it play the movie clip and remain "Orange" color in the same time, after that it change to "Orange", and so on so forth.

Any solution for this? Thanks

TOPICS
ActionScript
417
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 ,
May 10, 2014 May 10, 2014

You will need to explain how you have things set up on the timeline to get help solving this, but it sounds like your spray animation only lives in a section of the timeline where the car is black.  It needs to be in every frame along the timeline as a separate movieclip that you can play as needed.

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
New Here ,
May 10, 2014 May 10, 2014

Ok,i will describe the scene that i haven't make the "Spray" movie clip yet, so i won't confuse you. In the main scene, I got 1 movie clip, inside got few labels, as i mentioned before, "Red", "Green", "Yellow", "Orange", and "Blue" labels. Frame 1 contain a image, which is the black color's car image, the other labels contain different color of car image. So the sequence is Frame 1 is the black car, Frame 2 is the "Red" label, Frame 3 is the "Green" label, and continue until Frame 6.


I got another movie clip which is in the main scene, inside this movie clip is a menu and button, which contain different type of buttons that allow user change the color. It only have 1 Frame, and here is the AS:


var myCarArray = [Red, Green, Yellow, Orange, Blue];

for each (var Car in myCarArray) {

    Car.addEventListener(MouseEvent.CLICK, onCarClick);

  Car.buttonMode = true;

}

function onCarClick (event:MouseEvent):void {

    MovieClip(parent).car_color.gotoAndStop(event.target.name);

}

So what should i do in order to archive the target that i want? I need to show some animation before changing the car's color.





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 ,
May 10, 2014 May 10, 2014

Change your carClick function to assign the color value to a variable and call the spray animation that you want to show.  Have the end of the spray animation movieclip call another function that changes the color of the car using the variable that you assigned the color to.

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
Guru ,
May 12, 2014 May 12, 2014
LATEST

use the setTimeout function to delay the changing of your color

flash.utils - Details Adobe ActionScript® 3 (AS3) API Reference

//this delays the execution of the function for 3 seconds

function onCarClick (event:MouseEvent):void {

   setTimeout(delayedColorChange,3000, event.target.name);

}


function delayedColorChange(_car:string):void{

    MovieClip(parent).car_color.gotoAndStop(_car);

}

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
New Here ,
May 11, 2014 May 11, 2014

Thanks for the suggestion, but can you show the example of this? Because I'm quite confuse about what you mean

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