New Here...Possible advice on future project

A place for tutorials on how to get the most out of Flash

New Here...Possible advice on future project

Postby Purplemantis » Sat Apr 13, 2013 3:12 pm

Hey guys. I recognize a few names from Hentai Foundry which is comforting :)

I have a possible commission coming up that will require a "pleasure bar" and keyboard inputs to navigate on the timeline. Even if it falls through I still think this is something I should know for future projects.

All my animations are made outside of flash as flv movies that loop so I've had to do very minimal coding experience on past projects. Mostly just click to goto frames, visibility toggles, music muting and frame delays. So my knowledge of AS3 language is minimal at best. That said, here is the gist of what I want to accomplish:

1. A status bar that gradually increases while certain loops are playing (I'll have an idle one where no action is happening that the bar shouldn't move on). When it reaches certain points I'll have new buttons come into view from offscreen that will jump to the next loop. (ie when bar reaches 40% button "x" moves into frame)

2. The character is from a fighting game so the commish wants the climax animation to be triggered by a keyboard sequence (ex. down arrow->back arrow->D key).

Any advice on how I could approach these code wise would be greatly appreciated.
User avatar
Purplemantis
 
Joined: Sat Apr 13, 2013 2:53 pm

Re: New Here...Possible advice on future project

Postby OwnerOfSuccuby » Sat Apr 13, 2013 10:49 pm

Why not to put animation of groving bar on the frame where you will load flv - than it will work automatically with out coding for example ?

To make some action on key in AS3 you can use this :

stage.addEventListener(KeyboardEvent.KEY_DOWN,myGetKey);

stage.addEventListener(KeyboardEvent.KEY_DOWN,myGetKey);

function myGetKey(e:KeyboardEvent):void{
trace(e.keyCode);
if (e.keyCode==SomeValue){bla bla bla}
trace(e.currentTarget);
trace(e.keyLocation);
}

You can look key codes there:
OwnerOfSuccuby
 
Joined: Fri Jun 11, 2010 9:33 pm

Re: New Here...Possible advice on future project

Postby Purplemantis » Sun Apr 14, 2013 2:11 pm

That's a great little reference thank you!

Now for the energy bar, could work...but I would have 3 different flvs. One for each position. And the second two shouldn't be accessible until the buttons for them appear. And when they appear will be dictated by the position of the energy bar.

A theoretical play-through: As position 1 plays the bar grows. When the bar reaches 35% the button to view position 2 slides in. They have the option to view that, but they could just as well keep watching the first loop. Either way the bar still moves over time. When the bar is totally full the option button for the 3 loop appears and they can view that as well.
User avatar
Purplemantis
 
Joined: Sat Apr 13, 2013 2:53 pm

Re: New Here...Possible advice on future project

Postby OwnerOfSuccuby » Mon Apr 15, 2013 12:01 am

As i understand you have 3 movies - and you want them to play in different time - when Some bar is at for example 33 / 100 or 66/100 or 99/ 100 position for example ?

Not a big problem there are many ways to do so - if you want this flv - to be in the flash you can just create MovieClip symbol and drag and drop video on the different layers of it. Or in different symbol - for example on frame 2 - and the first frame is empty.

Then when you need - you just gotoAndStop that symbol to frame 2 and it plays movie.

As a example of it you can look for *.fla in this source topic viewtopic.php?f=34&t=3055
The idea is a little different but the same realization.


If you want *.flv files to be seporated from your flash - you can for example use loader or FLV player object in flash or it named some kind like this.
As an example you can watch this topic:

viewtopic.php?f=28&t=3072&p=199783#p199783
OwnerOfSuccuby
 
Joined: Fri Jun 11, 2010 9:33 pm

Re: New Here...Possible advice on future project

Postby Purplemantis » Mon Apr 15, 2013 2:41 am

Well I know how to make movie clips from the flvs and have the gotoandstop commands on single frames, but that's not my issue.

There are going to be 3 buttons: one for each loop. BUT the buttons will not be visible initially when the flash starts. They will be out of the frame and will only move INTO frame when the progress bar reaches certain points. This flash here is a good example of what I mean, although this one is time based I think as opposed to having a pleasure bar.

http://www.hentai-foundry.com/pictures/ ... olly-Roger

What I need to know is the appropriate AS3 language to basically say (if energy bar equals xx%...missionary position button moves from XY position (off screen) into XY position (on screen). Than the player can jump between loops at their leisure.
User avatar
Purplemantis
 
Joined: Sat Apr 13, 2013 2:53 pm

Re: New Here...Possible advice on future project

Postby OwnerOfSuccuby » Mon Apr 15, 2013 12:20 pm

A little tutorial about language:
viewtopic.php?f=29&t=2370

About how to say it - it is possible to do in any different ways - you can put buttons in different layers of MovieClip object to make it visile if you do not want to code more, you can make them visible and invisible - and you can really move them if you want - how to make it:

1)If you put them in MovieClip and just gotoAndStop to frame with buttons you need i do not think that it will be any problems.
2)To change visible you can use this - name the Button some how like "Button1"

Then when you need you just write Button1.visible=false // or Button1.visible=true - if you need to make it visible

3)To move object - name it like in 2) - for example we name button like "Button1"
On some condition you make Button1.x=500; For example and it moves to position 500 the same for y: Button1.y=500
But i do not think that 3) is the best solution. May be 1 or 2 is better.

How to write conditions - for example you have some variable (var BarPower:int=0;)
And on some event you make it BarPower=BarPower+1;
Then for example on enter frame event (or when your movie clip enters the frame on the frame where it will enter) - you write condition:

if (BarPower>some value)&&(BarPower<some other value) {gotoAndStop(some sceen number);}
or
if (BarPower==some value) {gotoAndStop(some sceen number);}

And etc.
OwnerOfSuccuby
 
Joined: Fri Jun 11, 2010 9:33 pm

Re: New Here...Possible advice on future project

Postby IrrelevantComment » Mon Apr 15, 2013 7:06 pm

You might want to consider setting the visible property of the buttons if all you want is for it to appear on screen you can just do something like
Code: Select All Code
button.visible = (pleasure > 35);
If you need the button to actually slide on to the screen, then you need to do something a bit more complicated. Assuming you are using as3, something like this would do the trick:
Code: Select All Code
import flash.events.Event;
addEventListener(Event.ENTER_FRAME, enterFrame);
button.x = -100;

// update the game each frame
function enterFrame(e : Event) : void
{
     if (pleasure > 35 && button.x < 50)
     {
           button.x += 10;
     }
}

// slide the button on
function slideOn(e : Event) : void
{
   
}


Edit: I'm never really sure how to answer questions like this, because I don't want it to be either be too hard to follow or too easy and sound patronizing, but I'll go into more depth about how I would handle this. I would create a Flash symbol for all the animations to be in, then in one layer create four keyframes and place the animation FLVs on the 2nd, 3rd and 4th frames, leaving the first one blank. Then create a second layer above the previous one and on it place your pleasure bar.

If you are unsure how to create a pleasure bar, then basically you want to have some symbol the size of the full bar, and set the registration point at the very bottom of the object. Then outside of that symbol, you can call bar.scaleY = pleasure / maxPleasure; and it will scale the bar to represent the current pleasure as a fraction of full pleasure.

Now, back to your first symbol. Leaving the top layer as one keyframe and three blank keyframes place your code in the first frame. (The point of having the animations start on the second frame is that you can use gotoAndStop on all frames without re-running your first frame code). This code will need to include an ENTER_FRAME function and an event listener for it.

Hope that helps. If I didn't answer your question, let me know and I'll try to explain it better.

Edit 2:
Spoiler (click to show/hide):

Code: Select All Code
import flash.events.Event;
import flash.events.MouseEvent;

var pleasure : Number = 0;
// the three buttons, which share names with the frames that they go to
anim1.x = 50;
anim2.x = -100;
anim3.x = -100;

addEventListener(Event.ENTER_FRAME, enterFrame);

// update the game each frame
function enterFrame(e : Event) : void
{
     if (pleasure > 35 && button2.x < 50)
           button2.x += 10;
     if (pleasure > 70 && button3.x < 50)
           button3.x += 10;
}

function gotoAnimation(e : MouseEvent) : void
{
     gotoAndStop(e.currentTarget.name);
}
IrrelevantComment
 
Joined: Tue Mar 15, 2011 7:46 pm


Return to Tutorials



Who is online

Users browsing this forum: No registered users