dcsimg
A Flash Developer Resource Site

Results 1 to 2 of 2

Thread: Help me! :)

  1. #1
    Registered User
    Join Date
    Nov 2011
    Posts
    1

    Help me! :)

    Hi,

    I am new to actionscript and flash so bear with me. I am really willing to learn though and I'm already starting to get to grip with the basics but am struggling to find something to help me with what I am aiming to create - hopefully you guys can point me in the right direction!

    I am currently creating an online virtual game where you will be able to create your own characters. So I want to create a simple flash object that allows you to scroll through hair styles, a top, a bottom, an shoes. These will all appear in place on the character as you click them... I am hoping this makes sense so far? So for example it will look like this:


    <-----O----->
    <----/ \ ---->
    < ----/\ ----->
    < --_/ \_---->

    (sorry for the poor drawing - i had to use lines to space it out properly!)

    I managed to find a tutorial on how to create an image gallery with forward and back buttons which is exactly what I needed.

    How do I know create a layer above this to place for example, the hair, and then have arrows to scroll through the hair types... yet keep below the skin tone that the user was on. So for example if they select a dark skin tone, then when they click the arrows for hair, the skin tone stays dark but the hair colours change.

    Does this make sense?

    This is my script so far:
    stop()

    btn2.addEventListener(MouseEvent.CLICK, backward);
    btn1.addEventListener(MouseEvent.CLICK, forward);

    function forward(event:MouseEvent) {
    if (this.currentFrame == this.totalFrames) {
    gotoAndStop(1);
    }
    else {
    nextFrame();
    }
    }


    function backward(event:MouseEvent) {
    if (this.currentFrame == 1) {
    gotoAndStop(this.totalFrames);
    }
    else
    {
    prevFrame();
    }
    }
    Later on I would look at then when they press "save" it will screenshot the image they have created and save it as their avatar in my php database. (I have seen some tutorials on how to do this so know that this is also possible)

    I hope you guys can advise me on how to get going on this as it will really improve my game a great deal and help me get a better grade (it is for a university project!)

    Thank you in advance

    Alex

  2. #2
    Total Universe Mod jAQUAN's Avatar
    Join Date
    Jul 2000
    Location
    Honolulu
    Posts
    2,429
    Try creating a variable that keeps track of weather "hair" editing mode is on or off. Then when you click, you can make a decision to either turn the face movie clip or the hair movie clip to the next frame.

    Changes are in bold
    Code:
    stop()
    // the button that turns hair mode will have to set this to true;
    var hairMode:Boolean = false;
    btn2.addEventListener(MouseEvent.CLICK, backward);
    btn1.addEventListener(MouseEvent.CLICK, forward);
    
    function forward(event:MouseEvent) {
      // here we decide which movieclip to manipulate
      var movie:MovieClip;
      if(hairMode == true){
        movie = myHairMovieClip;
      }else{
        movie = this;
      }
    
      if (movie.currentFrame == movie.totalFrames) {
        movie.gotoAndStop(1);
      }else{
        movie.nextFrame();
      }
    }
    
    
    function backward(event:MouseEvent) {
      // do the same here
      var movie:MovieClip;
      if(hairMode == true){
        movie = myHairMovieClip;
      }else{
        movie = this;
      }
     
      if (movie.currentFrame == 1) {
        movie.gotoAndStop(movie.totalFrames);
      }else{
        movie.prevFrame();
      }
    }

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  




Click Here to Expand Forum to Full Width

HTML5 Development Center