ActionScript 2.0 :: Correct Function/xml Game?
Dec 6, 2006
I am making a matching game for my company. I created an xml document to load in flash of medications and their descriptions. I used a dropdown menu component to load the categories the user can choose from and randomly load a med from that category. If they match it correctly, I want that item to disappear from the list to randomly load in that category.
However, the way it is working is...it does not randomly load a med (it loads the first item in the list [0]), it does not keep looping through the categories, nor does it remove an item from the list. I imagine if I can get direction to properly/initially load and randomize the data, that I can figure out the rest from there. I have been working on this for a long time...and I am stumped.
var Answer:Array;
var checkAnswer:Array;
//------------------Load the XML,populate the combo box and load med info into categories---------------------------------
import mx.utils.Delegate;
[code].....
View 1 Replies
Similar Posts:
Sep 19, 2009
In actions in my .fla file I create a new object of a class (addChild) which is in an separate .as file. Now, in my .as file I want to call a function in the .fla file. This should be the parent right? So, I try parent.correct(); which does not work. I get the error #1061 (call to a possibly undefined method). However, when I do this:
var par:* = parent;
par.correct();
Everything works. Why is this?
View 3 Replies
Aug 27, 2009
Using Flex 3.2, I have a object which extends a TitleWindow. In this TitleWindow I have an AdvancedDataGrid.
On creation of this object, I pass it 2 lists, one full of data to display, and the other I pass an array of column definitions. This allows me to, at runtime, create the correct columns and define the correct display attributes for each column (e.g. booleans will show up as checkboxes, and dates are formatted in a specific format (coming in from an XML feed in a variety of STRING formats where nulls are a possibility)
The problem is that the default sort, being based on string, doesn't work 100% of the time and even when the format is one that would be sorted nicely, it fails when nulls are involved.
The above problem would be easily solved using a sortCompareFunction, but the fact is when you set the sortCompareFunction of the column, it seems to require you to hardcode in the column name into the function.
for reference here's the function I'm using to create the columns:
private function setupGrid():void
{
var localcols:Array = new Array();
[Code].....
View 3 Replies
Dec 30, 2009
I'm trying to get the depths of all the blocks to be at the correct levels at the correct times so that the 3d effect is maintained. I've tried many things, but have had little success. All the instances of the blocks are stored in an array, but since it's adding them in accordance with when they're added to the stage, it doesn't help me locate them to swap depths. Is there a way to arrange them by location on the board?
View 4 Replies
Jun 10, 2004
I'm on a very big scale project and it is a game. What I need done is a walking version, but not just some easy script for it. It's like there are 545 diffrent buttons in my game, and each other has a diffrent location. Now what I want to do is to use a function for moving between them. Here is an example screenshot of the location where you can move: http:[url].....The numbers aren't there in the real game off course, it's for the button number. Now what I want to do is that you click the button, and the move function is called. The function should be like:
- The movieclip that should move is a player, instance name is 'character'
- You move to the x and y positions of the button you've clicked.
- The movement speed should be a variable, you make the name up, just be sure I can edit it by changing 1 value
- The character must move through a good line, meaning if you are at position #16 and you want to go to 31, it first goes to 32 and then to 31 and not directly to 31
- There's a big Array (its called _root.takenArray ) and it checks Every spot where you have to move to (if you move from 16 to 31 it checks 31 and 32) it checks if the values of _root.takenArray[31] and _root.takenArray[32] are not bigger than 1
- If you're moving to 31 from 16 and _root.takenArray[32] (in other words, spot 32) is taken, it tries to find another route, like through 15 and then to 31. If there is one, it follows that route.
- If they are bigger than 1, The moving action shouldn't be done, if they aren't bigger than 1, move the player
All the spots of above are positioned like in http://vert.2webh.com/all.jpg
That's all. Sounds complicated doesn't it? Well I'm pretty advanced at actionscript and I couldn't manage to make it work.
View 4 Replies
Jul 13, 2009
i have been trying to work out a way to have a endlevel function on my game....this function would, remove all event listeners, reset the cursor and most importantly clear all dynamically created movie clips(this is the part im having problems with).the first thing i tried was this:
[Code]...
View 2 Replies
Feb 11, 2010
I made a memory game with a tutorial. My knowledge of AS3 is not that good so I have to following question.There is a function like Math.Random to random generate number and put them on stage. I made a memory game and the cards are on the same place every time I play the "movie".I want them to shuffle every time I restart the game. How can I write a good random function in AS3?
View 10 Replies
Jun 8, 2011
I'm implementing a pause function in a game, it stops the main game timer and then dispatches an event ("Game_Paused") to stop a second timer. Both timers stop (and start) correctly but the second one throws a null object reference error.
Here's the ActionScript Code:
private function onAddedToStage(e:Event):void{
_timerD = new Timer(100);
_timerD.start();
_timerD.addEventListener(TimerEvent.TIMER, onUpdateTime);
stage.addEventListener("Game_Paused", onPauseGame);
[Code] .....
And this is the output:
Code:
Paused Timer=null
TypeError: Error #1009: Cannot access a property or method of a null object reference.
at com.rtr.game.UI::timer_display/onPauseGame()
at flash.events::EventDispatcher/dispatchEventFunction()
at flash.events::EventDispatcher/dispatchEvent()
at flash.display::Stage/dispatchEvent()
at com.rtr.game::Game_Timer/onKeyDown()
Paused Timer=[object Timer]
What's really confusing me is that the timer is still getting paused correctly, and the trace is showing up in the output before and after the error with two different objects.
View 2 Replies
Feb 16, 2010
I have gotten to a point with my platform game where I am completely stuck. I have the player movement working fine but the only thing is, it doesn't fall off the blocks.
I have a Floor class which references the Character class and tells it to stop jumping when it is on a block through a hitTestObject. I have tried to research how other games have added functions but can't seem to find one which will work in mine.
View 1 Replies
Feb 17, 2010
I have a little game with a timer in it. What I want is to stop the timer when you pass the finish.I wrote the if function with timer.stop();The timer stops but it is gone too. I want to see the time you have left to make it into a score.Is there a function to freeze the timer after finish the game?
View 3 Replies
Mar 5, 2010
I am developing a game project, in which I have many functions on it. I have all the major functions on the frame 50. And I don't want these functions on the next frame. Indeed I didn't have these functions on the 51st frame, the 51st frame only contains a stop action. But flash calls all the major function on the 51st frame also, I don't want these function to call on the 51st frame. Is there any way to stop this? Or else my program contains error?
Here is the program...
= The 50th Frame =
stop();
fscommand("allowscale",false);
fscommand("fullscreen",false);
var die:Boolean = false;
var currGun:String="hd_gun";
[Code] .....
View 3 Replies
Feb 19, 2009
I'm making this game with complex visual effects (some rendered lighting using bitmaps), so it takes about 1 second or so generating a level with 3 big lights, so it may take a little more using more lights. The map is built when the player clicks to play the level. The thing is I can't show him the game is busy processing the level elements, because the graphic elements won't refresh until the start level function returns, which would make some sort of info sign while the map is loading useless. How would I make it so this information is visible right after I click Start level and disappear as soon as the level is built? I'm assuming the event handler from clicking Start level has to return before the level starts loading, but how can I schedule the game for loading?
View 4 Replies
Dec 2, 2009
I have benn programming in AS2 for a while, but I'm moving to AS3, and I'm having some trouble with syntax and mostly with management of parameters and variables (actually I tried to work with functions in packages without good results T.T). The game has four different types of shooters, and all of them use the same bullet (shoot function). I have succeeded on disappearing the target (a coin in this case) when it is hit by the bullet, but the problem is that I can't quite find the way to dissapear the bullet properly. I keep receiving this message:
ArgumentError: Error #2025: The supplied DisplayObject must be a child of the caller.
at flash.display:isplayObjectContainer/removeChild()
at eco_adm9_fla::MainTimeline/moveBullet()
[code].....
View 3 Replies
Apr 23, 2012
I am experimenting with a card game. In what I have been working on, I got a button to be able to be click and "draw" a card into the players hand. This is all done through the use of arrays and tracing. I have set it up in a class file called drawClass.This, however, is where I am beginning to have trouble. I want it to take a random array value from the array called currentDeck and then place it in the players hand when the player clicks on the draw button. I am using a for loop to try and get a random array value and push it into the playerHand array.
Code:
for(i = 0; i < currentHand.length; i++)
{
if(currentDeck.length == 0) break;[code]....
In addition I have another question in regards to class files. I am relatively new to Actionscript 3. Making the change from Actionscript 2 to 3. It seems that most things should be done in classes and code should be kept out of the main flash file. However, it seems that you have to manually attach a singular class file to the main flash file, through the use of the properties tab in Flash CS5. Meaning it doesn't seem like you can have multiple class files attached.My question is, is there a way to have multiple class files and would that way be to just have them in the same file destination has the main flash file or can you actually only have one class file attached at any given time?
View 3 Replies
Mar 13, 2010
i'm Currently creating an interactive video game. There are 66 movies. I'm new to AS3, and have little experience in AS2.
The game in short:
You choose from 5 ingredients, each has this product provides a number of calories:Rice R = <- for all standard!
[code].....
View 6 Replies
Mar 4, 2008
So your playing a flash game that's fast paced and mouse-based (hey that rhymes somewhat)... And then you accidentally move your mouse outside of the area of the swf... And then it pauses automatically with a "Continue" button, instead of you just dying or whatever. I've thought you could have a huge button the size of the stage and make it do something when the frame isn't 'mouseover' or whatever, but there's gotta be a better way. Also setting limits on the _xmouse and _ymouse wouldn't work cos sometimes the mouse moves too fast for them to accurately get the last mouseposition...
View 8 Replies
Feb 9, 2009
I have problem with the setInterval function. I have a game application that sets a time limit of 3 minutes. From 3 minutes counting down by 1 second up to zero. The problem is, the counting of the timer is by 2 seconds and sometimes by 4 seconds. I tested the movie in my local computer and looks fine but when I upload it to a server and it is embeded in a website. And by the time the user clicks the link to play the game application and starts playing the problem about the timer occurs.
View 6 Replies
Mar 13, 2010
I'm Currently creating an interactive video game. There are 66 movies. I'm new to AS3 and have a little experience with AS2. I will try to explain the game! You choose from 5 ingredients, each has this product provides a number of calories:
Rice R = <- standard value!
Mais =-C
Roots =-W
Tofu =-T
Onions =-U
Champions =-M
Each ingredient can be added only 1 once.
Good combinations:
R-U-T-CR-U-C-TR-T-U-CR-T-U-CR-C-U-TR-C-T-U
Each movie is in a movie clip. And the frame where the movieclip is on, is labeled with the combination. For this I wrote the following script:
ActionScript 3 Code:
stop ();
var caloriesVar: Number = 10, / / default Rice
var inpanVar: String = "R", / / R = Rice
iLabel.info_txt.text = (caloriesVar);
iLabel.info_txt2.text = (inpanVar) / / idem
[Code] .....
But this does not work. When you click a button, the script doesn't do anything. Do not know where it goes wrong because he does not update the text fields.
View 2 Replies
Oct 23, 2004
I have a button that I would like to enable and disable a function within my game. The button is called "flashBang". I'm thinking this may need to be done with global variables to make the switch do this procedure. How would I go about scripting this variable? Also I want to be able to target this function during gameplay, if this function is enabled do this line of code - _root.gotoAndPlay("flash");
The code needs to fit somewhere in here i guess.
//hitTest top + bottom wall
if (_root.ball.hitTest(_root.topwall) or _root.ball.hitTest(
_root.bottomwall)) {
_root.yspeed = -_root.yspeed;
_root.audio.gotoAndPlay("flash_bang");
View 3 Replies
Jan 4, 2012
I am newer in FLEX and currently i am using FLEX 3.0 I want to develop a Tic Tac Toe game in FLEX. At first i think this one is the easiest for me but now its going to be very tough for me. I have searched on Internet but not a single link that much so please give me proper Idea with proper code. Here i am giving you the sample code. its a bit of complex so sorry for that.
[Code]...
I have check the winning condition on btn_click() function but you can give me the idea to change it when the one row is completed. I want to know how to handle the array of TicTacToe Game.
View 4 Replies
Jan 19, 2009
I'm trying to use a loadMovie function inside a loop to load external PNG files when my game is loaded. Unfortunately, I can't get even a single loadMovie to work correctly, much less execute a bunch of them.The code is on the root time line, and is targetting an empty movie clip that is nested inside about 3 levels. There is a button, with a movie clip on it, and the empty clip I'm trying to load into on that.so the full target path is myBox_00.smallBox.myLogo(myBox_00 is the button, smallBox is the movie clip, and myLogo is the empty)[code].I even tried using a JPG image instead of a PNG and still no luck. The best I could do was number 4; and that didn't work, all it did was SOMETHING instead of NOTHING... unfortunately that something was to make the button (myBox_00) disappear entirely T_T.I've never had much luck with loading external images. What am I missing here?
View 9 Replies
Feb 18, 2009
I have a button that triggers the function addToBet on a card game and doesn't allow the textfileds to show any larger number but I can't top the clips with the coins I'm trying to attach. The function showBet keeps running.
bet = 1;
function addToBet() {
bet ++;
[code]....
View 2 Replies
Jun 24, 2011
am creating a shooting game. my main class in first frame now i want to add the title in front of the game if a adding frame in front make it stop function. the game play runs what can i do?
View 1 Replies
Mar 7, 2012
I am going to develop a very simple game for android and for iphone/ipad I have the option to develop it in cocos2d or in adobe flash air (i am not a developer, but i have 2 developers who are offering me the service)I have a developer that states that cocos2d is better and other one that states that adobe flash air.I want it in cross platform.the cost offered by both developers is the same..i have heard that adobe air has the flaw that it is very slow, is this real? if you had the 2 options which will you use to develop your game and why?
View 1 Replies
Apr 24, 2011
I'm making a game that populates user-designed cards into the game using an external xml file. My main class loads the xml file and then calls to the "Card" class, which wants to use the xml file. I've tried using this.parent and it just gives me a null object reference error. This is what I have so far: Main.as
[Code]...
View 2 Replies
Jul 4, 2010
currently i making this game and objects would spawn at random and be able to click but when de game starts itself, the spawn is correct but i am unable to make it stop when time goes to 0seconds.
View 1 Replies
Feb 28, 2011
I'm creating a game at the moment for my university course and it involves the player character jumping on top of boxs twice to break them as opposed to just once.What would be the most efficient/simple way of writing this in Actionscript 3.
View 1 Replies
Aug 3, 2011
I have recently started working with Mahjong game. But being not so experienced developer. I am just confuse about many aspects of it. So if anyone could throw some light on it. I have to build the game where there could be different number of tiles on screen. 32, 48, 64 , 80, 96, 112 and so on Now I have questions regarding the levels of blocks in this game. I mean the layouts of the game should be predefined or they should be dynamically created? Also I wanted to know how the surface of enable and disable symbols are created?
View 2 Replies
Jun 13, 2009
I was trying to make a game, and the character inside the game could swim. However, I only wanted him to swim in short bursts that refueled every time he hit the ground.
View 9 Replies
Jul 23, 2010
im trying hard to make a Game like the Pokemon TCG .
View 2 Replies