Actionscript 3.0 :: Shorten Code With Conditional Logic?
Jan 31, 2010
I want to shorten this piece of code with conditional logic:[code]But i keep getting this error - TypeError: Error #1009: Cannot access a property or method of a null object reference.
View 4 Replies
Similar Posts:
Dec 2, 2010
I have the following code below. Is there any way to shorten it by putting it in a for loop. I want all values to be false, apart from go2 which will be true
Code:
var goArray=[go1,go2,go3,go4, go5];
var go1:Boolean=false;
var go2:Boolean=false;[code].....
View 9 Replies
Sep 30, 2009
my code works, but is way too long, infact to get the result I want it would need to be very very long.Here is *some* of my code, this is for Left. I have 3 other similar bits of code for Up, Right and Down.
on (keyPress "<Left>") { _root.player.gotoAndStop("left"); leftFunc = function () { if (_root.player.hitL.hitTest(_root.everything.hitAll.hitLeft) || _root.player.hitL.hitTest(_root.everything.hitAll2.hitLeft) ||
[code].....
View 7 Replies
May 29, 2011
I have the following logic in my code
if((leftCombo.getSelectedIndex() !> rightCombo.getSelectedIndex())&&(rightCombo.getSelectedIndex() !< leftCombo.getSelectedIndex())
Doing something wrong obviously.Here are the errorsScene 1, Layer 'Layer 1', Frame 1, Line 112 1084: Syntax error: expecting rightparen before not.Scene 1, Layer 'Layer 1', Frame 1, Line 112 1084: Syntax error: expecting identifier before logicaland.Scene 1, Layer 'Layer 1', Frame 1, Line 112 1084: Syntax error: expecting semicolon before not.
View 2 Replies
Jul 17, 2004
explain the logic of circular motion (them radians and degrees). I've found the code for it and modified it a bit to make it do what I want.But I haven't a clue as to how it works..This is a slightly modified code taken from the Kirupa Tutorial.
xcenter = 0;
ycenter =0;
onClipEvent (enterFrame) {[code]....
The above code will change the position of the movieClip at every 22.5 degrees (thereby making sixteen distinct stops) and will trace a circle of radius 100 px. concept behind the math equations?
View 1 Replies
Dec 20, 2005
I have some code that is supposed to detect if a movie subsection is currently "active" or "destroyed", and respond to these conditions. When a subsection first loads it sets _root variable "state" to "active". When a new menu item is rolled over, it triggers several events. It tells current movie to destroy itself. On the final frame of the movie subsections they change the _root variable "state" to "destroyed". After the button tells the current movie to play destroy, it begins an on enter frame function that looks for state to be != to "active" (I've tried == "destroyed" here as well). [code]...
View 3 Replies
Feb 17, 2010
I have created an image gallery where each "slide" is an image loaded by one UILoader component. Everything works, except I noticed that as a user it is annoying to wait for each new slide to load.So, even with my limited knowledge of AS3, I decided to figure out a way to load the next upcoming image before the user requests itone for odd numbered slides, one for even numbered slides. That way, when the user is viewing a slide with an odd number in the first loader, the next image can be loaded into the second (currently invisible) loader and ready to go when requested button would simply toggle the visibility of these two loaders.
function nextButton(event:MouseEvent):void
{
imageNumber++;
[code].....
View 11 Replies
Aug 10, 2007
I have some scripts that almost doing same thing, but just different buttons, how should i shorten it down? Cause i would have a lot, damn lot function to write :s*the buttons are not dynamic created so i would be easier to do some other stuff.
Code:
lv1_bsp1.onPress = function() {
shop1();
[code]....
View 1 Replies
Apr 18, 2011
Is there an easy way to shorten the length of a target name? As you can see in the code below I have added "_snd" to "e.target.name".
Let's say "e.target.name" equals "square_1" so the code below returns "square_1_snd", when the square is clicked on.
What I want to know is how do I get "square_snd" to return?
I would think if you can do (e.target.name + "_snd") then you could do (e.target.name - "_1" + "_snd"), to get just (square_snd), but it doesn't work.
I'm sure .split() and .join() is what I need to use but can someone show how to use it in the code below?
Actionscript Code:
var ClassReference:Class = getDefinitionByName(e.target.name + "_snd") as Class; var mySound = new ClassReference(); mySound();
View 1 Replies
Feb 9, 2012
How can I shorten this if else statement which just simply counts up? I know there's gotta be a way. I tried a for loop in the middle of it but I couldn't get the syntax right.Basically, it compares a date range that is in an array and then loads the correct banner by date from an xml file. It's part of a scheduled banner system controlled my one xml file. It has to have that else fallback at the end.[code]
View 6 Replies
May 31, 2003
is there a way to use the 'tertiary operator' to shorten this code?
[AS]if (this._x<0) {
this._x = Width;
}
if (this._x>Width) {
this._x = 0;
[Code]...
View 5 Replies
Jun 17, 2008
ave some lines of code that i would like to shorten.
View 5 Replies
Mar 12, 2004
I have a movie clip that is about 80 frames. It just cycles through 4 pictures at 20 frames per pic. I want to use actionscript so I can cut down the number of frames. I thought I could use a while loop to do this. Here is what my code looked like:
[Code]...
View 9 Replies
Dec 12, 2010
I'm using Fl for the first time and I'm trying to create a slideshow. Everything was going fine until I realized I had spaced out the different image timelines too far to the right. Now that I've moved them all leftward I have these blank ends that make the slideshow end with a long empty nothing. How do I cut those timelines off to eliminate that dead time?
View 3 Replies
Dec 11, 2011
So if you press and hold a button, it does the function once, then waits 0.5 of a second or so then repeats the action quickly. How do I remove the 0.5 of a second wait?
View 3 Replies
Dec 9, 2011
Would like to understand the basic process behind an ecard before I attempt to construct one!Obviously there could be the following elements:Initial web page containing a Swf (choose swf) offering a user a choise of ecards and a consisting of a series of text input fields to collect recipients and senders address and a message. With actionscript that calls a php file on the server.
Passing variables holding the card choise the card text the email from and to etc from swf to php file.The php script runs and creates a copy of a swf card, the one chosen by the user(swf1) It populates the swf copy with text from the variables set by the choose card swf.the php then sends an email to the recipient address with ? and this is where I am unclear?Does it send an attachment of the swf1 or how does it do it?
View 2 Replies
Sep 19, 2005
Im doing a tutorial in a book that moves a car from one end of the screen to the next by buttons.When you release a button it moves the car 10 pixels more down the X axis.The code confuses me and I want to understand it Please Help!
Here is the code:
// stop the cars traveling
stop();
// callback for onPress event on 'back' button
back_btn.onPress = function() {
// move my car -10 pix
[code]...
Why does the - sign and + sign appear before the = instead of after?Is this a logic operator(-= or +?Why doesn't putting the - sign or + sign after the = work?
View 2 Replies
Jan 19, 2011
In a RIA application you are supposed to put as much business logic as possible outside of the RIA layers (flash/silverlight etc). What is the reason behind this? Any logic that goes into the presentation tier gets the benefit of executing faster...
Is this because the RIA technology will most likely need a face lift down the road and you will have to rewrite all the business logic?
View 3 Replies
Feb 5, 2011
I was given a task to make a match making game in actionscript 2, problem is, i have very little knowledge about the language (well, and how matching works in as2, what are the important codes, code emplacements, and all I am new in AS2, and i really need a lot of help with our project. :)
I plan to match images. But.. I was planning to have a sort of "Compatibility" match-up game, like,..let's say we have two batteries, one has a 50v capacity(how do u measure batteries?) then the other has a 100v capacity, then there's this battery slot that only accepts a 50v battery, then you will have to match this 50v battery to that battery slot, that's my concept for the game, sir. I hope you got what i said, sir. :D
View 1 Replies
Aug 26, 2009
i missed something in the Aplly of ColorTransform, but i can't see...I made a background for the menu buttons that changes depending to the container x position.the problem is that it changes the text color too, and I don't figure why... here is the code :
Code:
import fl.transitions.Tween;
import fl.transitions.TweenEvent;
import fl.transitions.easing.*;[code]......
View 2 Replies
May 3, 2010
I want to update 50 "Circle sprites" (sprite with a circle in graphics object) on a timer event. Each circle's radius and position is calculated with a formula based on preloaded xml data.
[Code]....
View 4 Replies
Jul 9, 2009
Where I can find a complete set of Flash CS3 logical errors and what they refer to? I know Adobe has a list but for some reason it is incompelete.
View 2 Replies
Oct 19, 2009
I'm working on an app which will, like most apps, have a whole boat load of buisness logic, almost all of which will need to be executed both on the server and the Flash-based client And I'm trying to figure out the best (read: least complex) way to implement the rules engine.
These are the parameters of the problem:
The rules engine must both run in a web browser (ie, in Flash Player) and on the server. Duplicating the logic (eg, by writing a "server" version and a "client" version) would be an unacceptable risk. The input/output data is fairly complex, so serialization is a nontrivial problem. We are currently using AMF for all of our serialization needs, and using another protocol would add significant complexity So it should probably be avoided. It is infeasible to implement a "rules description language". Experimentation has shown that rules are sufficiently complex that any such language would need to be Turing complete Which would also add a significant amount of complexity. The rules engine will not need to make some, but not very many, service calls.
Currently, the best contenders are:
Writing the code in ActionScript, then running it on the server. In theory it's possible to start up an AVM instance, get it long-polling a gateway, then pass data back and forth that way But that seems less than ideal. Writing the code in haXe. I don't know anything about haXe's AMF support, so that could be a deal-breaker. Something involving Tamarin. Seems like a viable option, but I haven't done enough research to tell either way.
View 1 Replies
May 24, 2010
i want to develop AI car(opponent) in car race game what should be my direction to develop them with less complexity because i don't have any idea. because the player car is moving on the scrolling track plz suggest me should i have to use relative motion or way point concept but that should also be change on the scrolling track (i.e. player car movement)
View 3 Replies
Mar 22, 2011
how to design logic gates using flash?its a part of a project
View 4 Replies
Apr 11, 2006
I am trying to figure out the mini putt logic.. I understand that you give an angle and force then hit the ball. Now, once it hits a border, is it : the straight angle of the border minus ou plus (depending on the side) the angle of the ball that gives us the bounce angle? Any tips/formulas welcome
View 2 Replies
May 6, 2002
This is my problem that I have been fighting for way too long. I have a grid with some 300 boxes in it. I want these boxes to populate the grid randomly with random number of boxes populating each time.
My grid is a MC and all of the squares in it are the child of a another MC. All squares are named 1-300 and as you can see in the array, I am testing just 18 right now. I am hoping that it is possible to do what I want to do with an array because I think it would save me a lot of time and save computers a lot of processor juice.
I have been able to get the setProperty to affect the squares that the array points to, but it won't move on to any other squares. Or it will make the entire MC invisible.
CODE for frame 1:
//This code should wipe the grid clean
Boxes = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18];
for (count = 0; count<=18; count++) {
[Code].....
View 9 Replies
Jul 31, 2010
I'm builiding some sort of data portfolio in a section of a website. The method i'm using is the next one:
- Load an XML with all the data
- Call a function to build the portfolio.
- Use a "for" within said function to place all of the images at their respective positions
So, what I'm trying to achieve is to place the all of the nodes at the same time on and off screen following the next pattern:
[Code]...
View 1 Replies
Aug 11, 2010
@ 1) I have a big problem with Math.random logic in the animation on the top of this website ( danceacademy.cz ). If you leave it for lets say 3 minutes it'll start breaking (see for yourself please).
@ 2) Also animation shows mostly the Yemi guy which is undesirable behavior . That's because he is on the end of the code ( else { // In case the random number is 1 myMainMovieClip = new yemimain(); )
[Code]...
View 1 Replies
Apr 18, 2011
shorten the length of a target name? As you can see in the code below I have added "_snd" to "e.target.name".Let's say "e.target.name" equals "square_1" so the code below returns "square_1_snd", when the square is clicked on.What I want to know is how do I get "square_snd" to return? I would think if you can do (e.target.name + "_snd") then you could do (e.target.name - "_1" + "_snd"), to get just (square_snd), but it doesn't work.
PHP Code:
var ClassReference:Class = getDefinitionByName(e.target.name + "_snd") as Class;
var mySound = new ClassReference();
mySound();
View 5 Replies