How I can create more than right selection. ( Flash ) - actionscript-3

A few fish come to the screen and after a while the other fishes come in.Then a while the stage is stopped and the player is trying to guess the first fishes.How can I create code to say that the chosen fish is wrong or true.For example:The first come 3 fishes it's correct and after then came fishes wrong.Player guess right all the fishes and earn coins or display win text bla bla..

Related

SikuliX: my script reacts too slow when detecting the image, how to improve it?

I am making a script that make my character do the fishing automatically
fishAppear = "exclamationMark.png"
getFish = Pattern("pullBackFishRod.png").targetOffset(2,0)
Settings.MoveMouseDelay = 0
# this three lines will click on the fishButton to drop the fish road to the sea
if exists(fishButton):
for x in range(4):
click (fishButton)
After the fish rod drop to the sea, I wait for the fish to get hooked, when the fish get hooked, there will be an exclamation mark show up for about 1 second.
so I wait for the fishAppear image to show up
wait(fishAppear, 2 * 60)
if exists(fishAppear):
for y in range(4):
click(getFish)
The problem now is: the getFish button only show up for like 1 second after the fish get hooked.
When the script detects fishAppear, then it take some time to click on the getFish button, which the getFish button already disappeared.
How can I make the script faster but so it can search the fishAppear image faster?
Thanks!
If the getFish button appears on a specific region of the screen, use Region class to restrict the area of search. Sikuli will react much faster.

Column not visible in Safari - UiKit v.2

Can you help me solve this problem? One column is not visible in Safari. I tried change display of .uk-grid class to everything, change order of CSS attributes and it didn't help.
Here is the page: http://pegasproperty.impnet.cz/
Here is image with mentioned issue (big red box should be visible):
You are mazafakin pohadkovy raper.
If not in the office is a habit, trust me,
in the streets I have the prestige, I go out with the truth out,
like pregnancy tests, you do not know anything about the street,
as a book with Majka Spirita and rappers from the villages,
I'll eat these shit like Nesquik,
do not rush before you grab over the lip,
I'll pull you out of the two-sixth of your brush
and you go home in the rain, these lyrics, tracks,
boards are not bullshit, I'm a problem I do not want to solve,

Chrome Devtools, copying over a set of answers

I have to do this repeatedly, so I was wondering if there was a working around....
here is a set of amenities for an apartment, they have to be transferred to a larger list containing those amenities by clicking off multiple choice cirlces. Is there away to edit the script to do it all at once>
example
accessible
air conditioning
dishwasher
garage
hardwood floors
parking
patio / balcony
gym
in unit laundry
cats allowed
dogs allowed
pet friendly
basketball court
bathtub
bbq/grill
bike storage
business center
carpet
ceiling fan
clubhouse
game room
granite counters
microwave
oven
package receiving
playground
pool table
range
refrigerator
stainless steel
walk in closets
I think you want to just checkmark all of the checkboxes on the amenities list so something like this will work:
$('div.whitelist-searchable-amenity input[type=checkbox]').each(function(){
$(this).prop('checked', true);
});
https://jsfiddle.net/r62qgou3/
Edit:
I am not sure of what you mean by "copying text to script" but I modified the script to check if the values that you are looking for are within the document. This should search the values of the checkboxes and then you can use your own script to "copy" the value elsewhere. Just add more values to the array if you need more keywords.
x = [
"accessible",
"air conditioning",
"dishwasher",
"garage",
];
$('div.whitelist-searchable-amenity input[type=checkbox]').each(function(){
if(x.indexOf(this.value) > -1)
{
alert("copy here");
}
});

What's stopping these variable's from being defined in my code?

I've been designing this game, and Ive come across a weird problem. Now maybe it's just something simple I've missed or some way I formatted it. When I run my code I get these errors that suggest that none of the variables I've been defining are being declared/defined. On top of that none of the functions seem to run... Should I define text1, button1Name, etc... as Global variable? or is their a better way?
##Project 1 v4
##Structure whole program with base functionality
##Begin with an outline then fill in functions and windows from V2, and V3.
import Tkinter
import random
inventory=[]
playCount=0
def startGame():
##adds name
##button that calls StoryCard
text1="Welcome to Treasure Quest!! The Game that allows you to pick your own destiny! Treasure quest is a very simple game. The story will display on the screen until it reaches an event. At each event you will be shown two choices. Each decision may cause you to leave with more treasure or to die a horrible death... Still like any true or false question on a final exam, you only have a 50/50 chance of ruining your entire life if you do not know! Now that you know how to play, please click the button below to start the game!"
button1= introCard()
button1Name="Play"
button2= win.destroy
button2Name="Quit"
def introCard():
text1="You are the bravest knight in the service of the great kingdom Universitas! The kingdom has long been an icon throughout the world, but now it faces great peril. The king of Universitas has foolishly spent the entirety of the kingdoms fortune shopping online. The only hope for the kingdom, is to find the money to pay off it's debts. Luckily recently some scrolls have been found that describe the locations of hidden treasures. You have been selected to find these treasures. Do you except?"
button1=winCard()
outcome1="You embark upon your quest!"
button1Name="Accept!"
button2=lossCard()
outcome2="The kingdom falls into debt and you die of dysentary... Nice going Oregon Trail..."
button2Name="Decline!"
def storyCard(n):##This function will randomly select a story chunk
##recieves a random int
##tests for true int w/ if then else line
##Story blurbs for these are stored in V2 copy them!
if n ==1:
text1="You come across a dark cave... A dragon is said to lurk within... You enter and see the Holy Sword... How do you take it?"
button1=lossCard()
outcome1="The dragon bakes you to a crisp... Sorry!"
button1Name="Bargain for it!"
button2=winCard()
outcome2="Victory! You sneak past the dragon and make off with the sword!"
button2Name="Steal it!"
#get="Holy Sword"
elif n==2:
text1="You come across a mummys tomb... You see two doors. Take the front entrance or the hidden entrance?"
button1=winCard()
outcome1="The mummy is awake and glad for company! He feeds you tea and sets you on your way with gifts!"
button1Name="Front"
#get="A beautiful glass vase!"
button2=lossCard()
outcome2="The mummy sees you! It screams thief! and shivs you..."
button2Name="Hidden"
elif n==3:
text1="You come across a magic tree inhabited by elves. They ask you to climb up and see their beautiful home."
button1=lossCard()
outcome1="You climb high but slip off a branch and fall to your death. The elves laugh."
button1Name="Climb"
button2=winCard()
outcome2="The elves are perplexed as to why you do not want to see them. They come down and give you a new couch to show off their things."
button2Name="Stay"
#get="A rad couch"
elif n==4:
text1="You come across a cave filled with strange lights! A troll stands guard."
button1=winCard()
outcome1="This is a hip and happening new dwarven nightclub! The troll lets you in because you seem cool! The dwarves give you some rare cave mushrooms. It seems lame but they said the kings a regular and they will go over well. You have a fun night... You drink to much ale and get a late start the next morning though..."
button1Name="Strut in!"
#get="Rare Mushrooms"
button2=winCard()
outcome2="This is actually a hip new dwarven nightclub! The bouncer troll won't let you in though... Oh well! dwarves are hipsters anyways! Gratefull for your company the troll gives you an amulet!"
button2Name="Wait in line."
#get="Sweet Amulet"
elif n==5:
text1="You come across a hut in the woods! Its owned by Merlin! The great wizard starts up conversation and invites you inside!"
button1=lossCard()
outcome1="Insulted, Merlin kills you with an axe... you would have expected magic... but no, Merlin is a psychopath and prefers to murder with axes."
button1Name="Leave"
button2=winCard()
outcome2="He talks about his GOD DAMNED GRANDKIDS FOR FOUR HOURS... He is grateful for you company however and lets you leave with his staff."
button2Name="Enter"
#get="A sweet Staff"
## each if, elif, ect must contain
##Text blurb
##Button 1 function def
##Button 2 function def
##button 1 name
##button 2 name
##Outcome 1 Text
##Outcome 2 Text
def winGame():
text1="CONGRATULATIONS!! You have collected enough treasure to pay off the kingdoms debts! You will forever be known to the people as a great knight! The king is in your debt!"
button1Name="Hooray!"
button1=win.destroy
button2Name="Huzzah!"
button2=win.destroy
def winCard():##Describes how event played out
#inventory.append[get]
playCount+=1
text1= outcome1 or outcome2
if playCount == 5:
button1Name="Onward!"
button1=winGame()
button2Name="Go Forth!"
button2=winGame()
else:
button1Name="Onward!"
button1=storyCard(random.randint(1,5))
button2Name="Go Forth!"
button2=storyCard(random.randint(1,5))
def lossCard():
text1=outcome1 or outcome2
button1Name="Game Over"
button1= win.destroy
button2Name="Game Over"
button2= win.destroy
startGame()
win=Tkinter.Tk()
win.title("TREASURE QUEST!!")
Textlabel=Tkinter.Label(win,text = text1,font=('Times New Roman',12),justify=LEFT,)
Textlabel.pack()
Row2=Tkinter.Frame(win)
Btn1=Tkinter.Button\
(Row2, text=button1Name, command=button1,font=('Times New Roman',12))
Btn2=Tkinter.Button\
(Row2, text=button2Name, command=button2, font=('Times New Roman',12))
Btn1.pack(side='left')
Btn2.pack(side='left')
Row2.pack()
win.mainloop()
When I run the code I get these errors:
Traceback (most recent call last):
File "C:/Users/Logan/Desktop/Project#1V4.py", line 141, in <module>
startGame()
File "C:/Users/Logan/Desktop/Project#1V4.py", line 17, in startGame
button1= introCard()
File "C:/Users/Logan/Desktop/Project#1V4.py", line 26, in introCard
button1=winCard()
File "C:/Users/Logan/Desktop/Project#1V4.py", line 116, in winCard
playCount+=1
UnboundLocalError: local variable 'playCount' referenced before assignment
If you want to change a global variable in a function, you need to use the keyword global as follows -
def winCard():##Describes how event played out
global playCount
#inventory.append[get]
playCount+=1

5 star rating system in actionscript 3

i need to build a 5 star rating for a image gallery. when someone rates a image from the gallery i need to retrieve the rating (say like .5 or 2.5 or 3 or 4.5 or 5)
How can we create something like a 5 star rating system in AS 3.0?
Edited:
not the solutions to send the rating vlues to database... I am looking for the logic to set the rating (stars changing the color indicating the rating has been updated) and get the rating values applied...
Now that the question has completely changed, lets look at displaying some stars:
You can use the Polygon tool to create stars. Select this tool and then in properties, select Options and then Star.
Draw 5 stars on a layer.
Convert these to a MovieClip.
Place them on their own layer. Copy them and then place them onto another layer.
Draw a rectangle that will be the color you want to fill the stars with large enough to cover all of the stars. Put this on another layer and then mask that with one of the star layers. Convert the rectangle to a MovieClip so you can tween it.
Create a tween of the rectangle moving from the left to the right so that it slowly covers the stars.
You should have something like this:
Use gotoAndStop() to stop on a desired frame. In my example, 50 is a full 5-star rating. 25 would be a 2.5 star rating and fill 2 and a half stars. Etc.
Old Answer
I'm keeping this here purely for the sake of people searching for things like "rating system in AS3" which will most likely require the below info.
You'll need to store the ratings in a database. The concept I use (and probably that everyone else uses) is that you store records containing a voter, the rating they assigned and what they voted on eg:
Marty | 3 | hat.jpg
John | 5 | hat.jpg
Simon | 1 | tasty-cereal.jpg
You then request all of the records that relate to a given image, combine all of the ratings found and then divide the total you get by the amount of ratings given. This will yield the average which will represent a rating out of 5.
As an example, the rating for hat.jpg could be found like this in PHP:
<?php
$score = 0;
$query = mysql_query("SELECT ratings.score FROM ratings WHERE image='$image_from_flash'");
while($row = mysql_fetch_assoc($query))
{
$score += $row["score"];
}
$average = $score / mysql_num_rows($query);
echo $average; // This will be sent back to AS3.
?>
To send and receive the ratings, you will need to use URLLoader to communicate with server-side technology, like PHP. This will talk to the database, work out the average as I mentioned above and then send back to AS3 the average rating for you to use.
If you need information about how to work with PHP + AS3 and send information between the two, that's an entirely different question that will require a very detailed answer. You're better off Googling for information about this.
Let me get you started:
Send and load variables with AS3 and PHP
You may want to think about it as a volume slider. for example:
you have a a movie clip of 5 stars that is 100px in width. you make a mask that is 100px wide to cover up the stars. Set up an event listener for MouseEvent.CLICK on the stars movieclip and make the width of the mask whatever the mouseX is relative to the the total width of the clip. something like:
var relativeMouseX:int = mouseX - stars.x; // you'll get a number between 0-100px
so if the value is say 67px then you can do this operation:
67/100 = .67 * 5 = 3.35;
3.35 stars would be the rating.
starsMask.width = relativeMouseX; //makes the mask's width reflect how many stars is showing.