that does not sound like a newbie project.
but to start wouldn't be hard. you can create a form in flash by adding input textfields to the stage. i would think you'll want to add 5 or more (one for each card in the player's hand).
you can also add a button to the stage that the player would click when they've entered data for all their cards. then the fun begins.
yea, i figured out how to add form fields to the page - took a little head scratching but i think i have that figured out.
What i need to know now though is how do i access the values in those fields?
And how do i make an image appear at a specific location? Eventually i'll want to make it more animated where the card might slide over to the players hand. But for this first initial attempt, having the cards or chips just appear where i want them is good enough.
So any tips on how to read flash form fields and how to make an image appear/disappear at specific locations? I think those are the two main tasks involved in this right now.
Oh and i'm using flash cs4 - if it's easier with cs3 i'll install the cs3 trial just to get this done.
thanks for any tips
1 person found this helpful
you should assign an instance name to each textfield (click on the textfield and in the properties panel enter a name, say tf1). you can then access the text written into the textfield by referencing:
ok cool. So i'd create the form fields, create a submit button which i assume would be assigned to some as function which would then read all the form fields. Once i've read all the fields, I'd then have to play the 'movie' of the poker hand being played.
So lets say I have 54 images - one for each card in the deck. And a couple of images for different value poker chips.
How do i make a specific set of cards and chips appear or disappear at a specific location?
Would it be as simple as something like:
KingHeart.visible = true;
Kingheart.LocationX = 123
KingHeart.LocationY = 456;
Assuming the king of heart image was named KingHeart
thanks again for the help
it would work better if you assign each card a class (assuming you're using as3, which it appears you are) or assign a linkage id (if you're using as2). which are you using?
I was planning on using as3 - figured if i was going to learn action script might as well start with the latest version.
so when you say class - is that as in standard OO programming? i.e. there would be one class for all 54 cards, rather then 54 seperate classes?
Was I close in how i would make the images appear and disappear at specific locations?
1 person found this helpful
so, right click on the king of hearts movieclip in your library, click properties, tick export for actionscript and in the class textfield type something like KingHearts. likewise for the rest of the cards.
then if you want to display a hand of 5 cards you could use:
var card1:KingHearts=new KingHearts();
var card2:JackSpades=new JackSpades();
var card3:FourClubs=new FourClubs(); // don't start object names with a number in flash
var card4:KingDiamonds=new KingDiamonds();
var card5:FourSpaces=new FourSpaces();
ah ok, so i do make a class for each card and then create an instance of that class in order to use the card. got it.
And from the code you listed below, looks like that'll lay out the cards one on top of the other, but shifted over to the side a little so you can see all the cards layed out.
if i want to get rid of the card, do i just destroy it? Or move set the x/y position to somewhere off stage? I assume removing it completely is the best way to go to free up resources etc.
thanks again for your help with this.
the cards will be side-by-side with no overlap. you can play with the x,y properties to suit your needs.
to remove card1 use:
ok, thanks. I think that should give me something to start working with.
Hopefully i wont have any more questions for you - at least for a little while
thanks again for the help.
ok, looks like i lied. I do have one more question.
Someone sent me a adobe illustrator file containing images of all the cards of the deck. He sent me one file which contains all the cards, i think each card is in it's own layer.
I do not have AI installed.
Is there some way for me to import all the cards as seperate images?
create a new movieclip and while in that movieclips timeline click file/import/import to stage. see what you get.
hmm i was close. I was trying to import it to library.
When i do it to stage, i can access each card. They are all on top of each other so i have to hide them all and then just show one at a time.
do i then want to convert it to symbol?
If i select convert to symbol, i then have a choice of button, graphic or movie clip. I assume i want movie clip.
And under advanced settings, there's an option to export for actionscript, which i assume i should check. There's also a check box for
'export in frame 1' - not sure what that is.
Also wants me to set the class, which in this case i assume would be KingHearts, KingClubs etc etc and bass class is set to flash.display.MovieClip.
Also two checkboxes for export or inport for runtime sharing.
If i just have to click on each one, convert to symbol, enable AS and name the class, i can do that.
once you have them all on-stage, click the frame that contains them and over the image right click and click distribute to layers. each card should be in its own layer. now right click each one and click convert to symbol/movieclip, tick export for actionscript and assign a class name.
you don't need to do any runtime import/export so leave those unchecked.
a quick ( i hope) question.
I saw the code you showed for accessing the form field values. Can flash also access a regular html form field? I actually already have most of a form finished in html. So it would save me some time if i didnt have to create a flash form but could instead just have the html form post to the flash/actionscript file.
Is it possible to do that? If so, can you tell me what code i would use to access the html form fields? It's pretty much a combo of all html form fields - textbox, dropdown, checkbox, and radio button.
the form (on submit) may as well call the php or some other server-side script directly. nothing's gained by using flash in that process.
I'm a bit confused by your response.
Why/how would i use php or any other script for this? There is nothing server side going on here, other then playing the flash movie of the card game. I'm not saving anything into a database (yet) or anything like that. at this point all it is is someone filling out a form with the hands played in a card game, and then having a simple flash movie show those hands being played.
Are you saying there's a way to do that using php/asp.net instead of action script? (I'm going to feel really stupid if that was the question i should have asked from the beginining).
I was just wondering if you could explain your last post? I was a little confused by that. I've actually started getting some of this working thanks to the help you gave me.
I'm at the point now where i need to read the values submitted on the form and then display the appropriate images on screen. I already have an HTML page layed out with all the form fields on it. i was wondering if could use this page to allow someone to fill out their info, submit it and then read the values from the form and display the flash movie.
I know how to read form values from a flash form thanks to the sample code you showed me. But can i read form values from an html form? Do i just have the html form post to the .fla file?
i'm confused by my response, too. either one of your messages was changed or i was responding to someone elses thread and inadvertently responded in your thread.
thanks for the help again
i agree with the conclusion in the middle of your above paragraph. and, i think, the same conclusion is valid if you try to pass the query string.
you must have some aversion to creating a form in flash. and that's hard to understand because it's much easier to create a form in flash than it is to create a form in html.
granted i haven't created a full form in flash - i've only created 1 or 2 text fields to test with. But it seems like there are more steps involved in creating the flash form. Could just be because i am new to it so it just seems to take longer since i'm still getting used to it.
The main reason though i wanted to try and use an html form is that i already have an html form i can use so it would save me some work if i could use that instead of having to create one. Oh well, this is good enough. I just need to sit down, start making the form and start writing the code.
The only part of the code that I'm unclear on now (but i think i can figure it out) is how I can make an animation (a tween i think its called) of a card and then in the code apply that tween to whatever card i want. I assume that can be done, since i cant imaging i have to make an animation of the same thing for each individual card.
I'm reading through learning action script 3 - i'm sure there's a chapter in there on this that i just haven't gotten to yet
thank you again for your help
that's about it. add input textfields to the stage, give them instance name and place a label near each textfield so the user knows what's expected in that textfield.
you can then use the textfield's text property to retrieve what the user entered. for example, if you have a textfield labeled card1TF and the user enters "ace of clubs",
would contain the string "ace of clubs"
yup, i used that from your previous example