ActionScript 3.0 :: Shorten Some Lines Of Codes With A For Loop?
Jun 17, 2008ave some lines of code that i would like to shorten.
View 5 Repliesave some lines of code that i would like to shorten.
View 5 RepliesI 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].....
i will like to add a loop to this codes below
var myTimer: Timer = new Timer(1000);
myTimer.start();
myTimer.addEventListener(TimerEvent.TIMER, nextPic)
[code]...
I am trying to convert the longer code i have below into shorter codes, the codes that i have is for Actionscript 2, while i am using as2 debugger, trace(), its getting the loop, however it will not recognize that is a movieclip (button1 - button3 are 3 different movie clips that i assigned).
[CODE]...
I am dynamically adding a set of grid lines to a movieclip using a for loop. And I was wondering how I go about removing all of them so that I can add another set of grid lines to the same movieclip.This may sound weird but what I am doing is dynamically creating a table from an array and I wanted to dynamically add gridlines in between the table entries depending on how many entries there are in the array. I got this to work fine but when you go from one table with more entries to a table with less then the grid lines from the longer table are still there.Hence I want to be able to remove all the grid line instances before creating the next table.
View 6 RepliesI 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]....
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();
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 Repliesis 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]...
I have been working on a map viewer based blitting technique. As part of the map I need to draw approximately 50000 lines and performance is currently really poor.
Code: Select allvar movie:Shape = new Shape();
for( ... )
{
movie.graphics.clear();[code].....
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 RepliesI 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]...
My code is on the main timeline.I call a function loop to draw lines between them.The lines are drawing between the right x, y values BUT between those values on the main stage, not those values within the kite.For example, dot1_mc is at x100, y0 inside kite. the line that should go from its center, draws from stage x100, 0.How do I draw the lines inside kite so that they draw between the dots?Heres my code that draws the linesPHP Code:
function loop():void{ lineDrawing.graphics.clear(); var a:Point = new Point(kite_mc.dot1_mc.x, kite_mc.dot1_mc.y); var b:Point = new Point(kite_mc.dot2_mc.x, kite_mc.dot2_mc.y); var c:Point = new
[code].....
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].....
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 RepliesSo 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 RepliesLet say, I am loading xml file. And I have done addEventListener for Event.Complet. while xml is loaded, After completion of complete event, I declare I passed value to my attribute but it does not show in.
E.g.:
....this is a class main
var keyword:KeyWord = new KeyWord();
I'm new to AS3 and I need some help putting something with the FLVPlayBack component together.
When I put this in the first frame of my timeline:
player.volume = 0; player._uiMgr._isMuted = true;
[Code]...
We are trying to build a game in flash with AS3 (Im no pro with this)I've got 7 Movieclips and 7 Buttons.none of the 7 Movieclips should be on stage, they only appear when you've clicked 3 of the 7 buttons. once these 3 are clicked 1 of the 7 Movieclips should appear.Now I've got the code to make 3 selections and make it show 1 movieclip.and I've gotten the code to make a random movieclip appear.My question: How do I combine these two to make them do what's supposed to for the game.[code]
View 1 Repliesdoes anyone know how to play a sound when a mouse is over an object (image, text, button)?
View 4 RepliesI have to connect my flash application with php+mysql .how can i integrate my php code into flash..?
View 1 RepliesI'm making a Flash piece consisting of a few different pages and clicks to take you to different chapters. The company I'm making it for have sent me URL's of pages that will track the person on it - what page they're on, what chapters they view etc.
So, where do I put these url's?If I put them in a getURL won't that just redirect the person away from the page with the SWF in it?
When I am loading external UTF-8 text files (or texts from an mySQL DB) with Flash, if those files contains enters (by the user that create them) I noticed that those enters are replaced by two char codes: 10 and 13 (new line feed + carriage return). If I put the loaded string to a TextField.htmlText I get 2 enters pressed, and thus instead of having 1 line change I got 1 paragraph change.
[Code].....
Can I really do that with the phone? Perhaps I would have to call any of the native API's, but I am not really sure whether and what is possible. I am pretty sure that the camera is accessible, so at the worst case I could send the picture to the server, decode the QR code on the server, and get the results on the phone, right ?
View 1 RepliesI use flash MX 2004, and I've been facing a problem. I made this flash program to load a jpeg, and to resize and display it.. But the problem is, it works, but not in a stream I mean My program work in 4 phases::
1. Load the jpeg
2. Check and compare the image's height and width with the given parameters
3. resize the image... 3.1.. First height... 3.2.. Then width
4. Display the resized image
The problem I am having is, it does phase 1, then does nothing... I experimented with it a bit, and then i found... Let it do the phase 1, then goto another frame, then back to previous frame... It does step 2.. Do same thing again for other phases... Its sort of like I am refreshing my frame again and again to make my code work in bits and pieces.
I am working on a Flex project that is interfacing with physical hardware.Using the AS3 command of socket.send I can set a particular feature on the physical hardware.The problem I am having is I need access to send from the Extended ASCII codes.[code]This would be translated to me sending two numbers to the hardware.7F and 07. The Dec equivalent of these Hex codes are 127 and 7.The hardware takes these two numbers and calculates a length along with a third integer.[code]
Unfortunately the Hex 88 is in the extended ASCII table.The highest the regular goes up to is 7f which is a Dex of 127.I need the ability to send full 0 to 255 numbers in ASCII form.I can't send from 128-255 without using the codes from the ASCII extended table.I get an error every time I try to send something form the extended ASCII table back from the hardware.Can anyone confirm that AS3 does not support the Extended ASCII codes?
I have some basic as3 knowledge and I have built 2 apps. in as3 but I want to use them for mobile systems as I guess for symbians.Which program should I use. I searched here flash lite but there is no forum about it. Ä°s there any other forum to help me learn flash mobile appliÅŸcations
View 2 RepliesI am brand new to Flash and I am completely unsure on how to diagnose and resolve the problems I am having.I am in an online program through the Art Institute and I am currently taking a course to learn the basics of Flash.I am running Flash from CS4 on my MacBook Pro running OS X 10.6.8 and I am having problems opening some of the .fla files that people post. One of two things happens, either:
(1) when I try to open the .fla file I get an pop-up alert (below) and if I click OK the file doesn't open (and clicking OK is my only option, as you see);
(2) I go to open the .fla file and it appears to be opening but then the screen is blank and I get two error reports in the Output pane which says:"VerifyError: Error #1053: Illegal override of isRelatedObjectInaccessible in .RemappedMouseEvent.ReferenceError: Error #1065: Variable_ e9a7 52f233536079fc4486d6ac92a1b05a633a5657d5b83ad7fac2246298 b191_flash_ display_ Sprite is not defined."I tried installing all available updates for Flash and that did not solve it. I also tried opening the same .fla files on my husbands MacBook Pro OS X 10.6.8 running CS4 and got the same problems.
can i recognise a movement on a joystick with ascii codes???
View 1 RepliesI'm trying to allow ascii codes to be entered into a textField, using num codes (ALT+Num), and am seeing some very strange behaviour. If I enter: Alt + 14, I get a charCode of 9835, and ♫ is displayed in my trace output, but a placeholder square is entered in the textField. If I enter: Alt + 0014, I get a charCode of 14, placeholder square is displayed in trace, and ♫ is displayed properly in the text field.
View 3 Replies