I have a symbol of a person standing, he have child movieClips like hands, legs, head, body....so then if i press a button or click in the stage how do i need to change the animation instantly?
I suppose:
1) create a new movieClip that has all the same parts but animated as walking(for example) and then make something like:
if(keypressed)
{
person.replaceSymbol(myNewAnimatedSymbol); //method that not exist
}
2) for example if my standing animation longs from 1 to 30, i can make another animation in the same line let's say from 31 to 60 where he is running and then write:
if(keypressed)
{
person.legs.gotoAndPlay(31); //in the 60 frame he go back to 31 by using gotoAndPlay(31)
person.hands.gotoAndPlay(31);
person.body.gotoAndPlay(31); //and so on...
}
Can you give me an advice of which of methods I need to use? or if you have a better idea how to make it...
Hm-m-m. I'd say your second approach is easier to both draw and control, especially if it'll eventually come to reskinning your MC, say your person will get dressed in a cloak that's attached to the body and arms, your "new animated symbol" will likely require a change to accommodate that clothing, while in case of one symbol you can assign its parts another look, like say person.hands.cover=clothing.handpart; person.legs.cover=clothing.legpart etc, and then the animation will contain references to cover being changed, so that correct parts of clothing will appear around all the moving parts.
In fact, you might not need separating your person into different body, hands, legs etc MCs, but instead make it so that your person's legs are a container that can hold either a bare body part (naked leg drawing) or a dressed body part (a boot, pants, etc), and animate the main part by making these containers move according to how a person should walk, stand, run, attack etc etc., so that you will have a single point to dress the entire set of your person's animations.
It depends for example my character has around 100 animations. Putting them in a single timeline and telling them to go from this label to that label (or frame) is a huge mess to manage.
So I have 100 library items with export symbols. I keep on switching between them. This makes it easy to manage.
So, I think the question is how many animations do you have? Can you manage them in a single timelines? If you can , I'd say go with labels or frame jumps.
Both of your methods are correct and your second method would be faster because you're not adding or removing anything from the display list.
Related
Normally tables are easy to manage , especially since autolayout can do most of the heavy lifting to determine cell sizes and so on. However, there are cases where things become a little bit more tricky like having a table of polls.
A poll in this case consists of labels with variable description lengths, images with varying sizes and a set of options for the user to choose from ( a nested table essentially ).
----Approach 1------
Break each poll into a number of cells
Pros:
Its easy to add more fields to a poll in the future, layout is easier to handle for a single cell for each element especially in the case of the nested table. If you need to fall back to manually calculating the size of a specific cell you can do it while keeping everything else on automatic.
Cons:
If you have multiple polls you need to keep track which cell corresponds to which poll, and you generally need to do some arithmetic to keep track of whats what.
----Approach 2-----
Have the poll that contains all these elements be one big cell and set the constraints between them appropriately.
Pros:
Its easy to implement, maps your model to your cell in a one to one fashion without having to multi-demultiplex your data.
Cons:
Autolayout can get hairy with nested tables. For example, for the height of the cell in this case, i used to return UITableViewAutomaticDimension until i realised this wont cut it as a nested table exists that could be any kind of size. Its quite straightforward to calculate the contentsize of the nested table, however, this would mean you would have to calculate ALL of the other elements as well as now you're returning a specific height and not automatic. Your job has become that much harder.
----Outro----
How do you approach issues like that? Approach 1, 2 or something entirely different? I've simplified the structure of the elements here to make things a bit more readable, there's more arcane stuff involved like shadowed views containing the elements you see to create the illusion of a floating card etc.
Thanks everyone.
P.S : If there's already an answer about this somewhere please point me towards that, i just haven't found much on this yet. Hopefully this post can spark some discussion on the matter and help other people in my shoes.
A straightforward alternative suggested by Paulw11 is to use sections and Approach 1. Even though this may not cover cases that have tables within tables within tables, it will suffice for what I imagine is mostly every conceivable case that has a respectable UI.
ok, here´s a first time noob question, sorry if that´s stupid.
I was just wondering, for a battleship kind of game, would it be a waste of memory to build a set of objects for each cell (10X10=100), with position(x,y) and state(empty,hit,missed) properties?
I was wondering if it would be better to only create an object Grid and use methods to calculate the cell positions whenever necessary (when handling cell selection with touches or drawing for example)..
The former is problematic because you may have ships that sit side-by-side or end to end and it will become difficult to know when one is completely destroyed just from the data structures you described. Two hits side-by-side could be two hits on the same ship, two hits to two different ships, or even a sinking for the smallest ship.
Go with the latter for sanity's sake.
If I was doing this, I would keep it simple, Have a 2 dimensional array, that's your 10 by 10 grid.
When someone takes a turn, calculate the position and;
if it's a miss, insert a 0 in that array cell
if it's a hit, insert a 1 in that array cell
I am creating a map in which i want a polygon to display two separate variables within it. Therefore I want a stripped polygon relating to both the keys from the separate factors however I have no idea on how to do this. I messed around with multiple attributes on the properties section and could get the two variables up however could see no way of making the polygon display them both.
Thank you, any help would be appreciated
This is partially manual, but you are going to have to make a separate category within one of the fields that identifies the multivariate features. You could also create a new layer that is a selection of these features. Once you have that, go to the layer properties and display the features as 'Categories - Unique values, many fields' and hit the 'Add All Values' button. Once the categories are populated select the one you are interested in and pick a hatched symbol such as 'Radiation Overlay'. Then go to the Symbol Property Editor (double-click the symbol) and modify the two layers that make up the hatched symbol. You need to adjust the color, line thickness, offset, etc. until you get it to look the way you want. Probably not as auto as you wanted, but it will satisfy display purposes.
I am a beginner at ActionScript3, and for my learning purpose, I am trying to build a match3 kind of game. I am making is a clone of bejeweled kind of game. but instead of swapping, I have to delete those elements and shift the upper elements down and add new elements above those shifted elements.
I am able to delete matched elements and after matching I'm removing those elements but I am stuck with the shifting code. I am not able to shift those elements down.
I believe that you should take a look at Richard Lord's Tetris source code as your game may be somehow similar in mechanics to Tetris. Tetris shifts down rows when you get lucky.
Richard Lord is one of the Flash Gurus and his way of doing things may seem pretty advanced for a starter like you. Take a look over the source code and see if it fits you. What I can tell is that this is the proper way to make a game but maybe it's not the best point to start for a novice like you that is in urgent need.
http://www.richardlord.net/blog/actionscript-3-tetris-source-code
I would approach it like this in 2 parts.
Loop through your array of board positions starting from the bottom row and check for an empty unoccupied slot, if you find one do another loop through the row above till you find a piece on the same column. If you find a piece on the row above apply a tween to move it down to the empty slot and continue your loop.
Once you have looped through all rows, and animated all the tweens you need to loop through again to find all the gaps that need gems dropped into them. Create new elements at those positions and then move them up by (element height * row), apply another tween to animate them back to their starting position.
I'm dynamically loading a file that will indicate when to show certain words at certain frames. However, I'm having trouble with the concept of timeline control from ActionScript (I'm building everything programmatically in Flash Builder). Let's say my tuples has frame and word:
5, "duck"
13, "cow"
22, "pig"
There is a sprite associated with each. What I would like to do is something like the following:
for (frame in timeline) { //should iterate from frame 0-22 (last frame in list)
if (frame in list) {
list[frame].alpha = 0;
}
}
I already know that my display of sprites works and whatnot, I'm just confused on how to play through the timeline in this kind of way, or if it's possible to dynamically do this.
EDIT: Related, can I control how fast the timeline plays?
EDIT: To give a more thorough explanation, I'm looking to visualize word appearances over time in a text. So "duck" may appear as the 5th word in a corpus, "cow" as the 13th word, etc. My list contains tuples of word positions (unique) and the word that appears at that position. I have a small selection of words that I'm interested in from the corpus, so not every position is represented. I would like to be able to have a SWF movies that essentially starts at the beginning of the corpus, go through my word list in order of appearance in the corpus, and then display the word (and have it fade out). So, if there's a word at position 5 and 10, then should appear in much more rapid succession than if there's a word at position 15, and the next one doesn't appear until 50. Basically, I would like to keep that temporal component.
I'm having a little trouble understanding exactly what you're asking about, but in general for controlling the timeline use the commands play() stop() gotoAndPlay() gotoAndStop()
Beyond that I'm gonna need you to explain more clearly what exactly you are trying to do.
ADDITION: From your edits it sounds like you simply want to trigger an animation when the user clicks a button or something. So make the animation in Flash and then use the commands I listed to play it.
ADDITION2: If however you definitely want to do this in code then that has nothing to do with the timeline; program the fading in and out using a tweening library like http://www.greensock.com/tweenlite/