ActionScript 1/2 :: Repeat Small Bit Of Code 1-100 Hundred Times With Each Code Having Different Instance Name?

Nov 20, 2010

here's a part of my code:
 
player_mc.onEnterFrame = function() {
if (enemy0.hitTest(this)) {
enemy0.speed = 0;
} else {

[code]...
 
Note the red code, I need to repeat this an unknown amount yet multiple times but with the number on the end of enemy incremented by 1 each time. It starts with 0 as you can see the code just above the red. I heard about for loops using 'i' but im unsure about how to use it.

edit: ah, this forum isnt letting me highlight red. Everything in this editor is also failing. well, when I say code in red i mean this code:

if (enemy1.hitTest(this)) {
enemy1.speed = 0;
} else {
enemy1.speed = 1;
}

View 3 Replies


Similar Posts:


ActionScript 1/2 :: Repeat/Loop Small Amount Of Code?

Jun 28, 2009

how do I get this code to repeat itself continually, because it just executes once. Im not that good with listeners, i know functions and variable etc though im not that bad.

Code:
if (health<=0) { gotoAndStop("mainDead");}
Its on a frame, not a MC.

[code].....

View 3 Replies

ActionScript 2.0 :: Explanation On One Small Part Of A Code?

Jan 4, 2007

I try to understand this code ( taken from a tuto). I am learning empty mc and AS... I catch it until a certain point, however some terms are still very very dark for me :So as far I see, there are only 2 objects in the file :An empty mc called Menuholder and a mc called menuitem ( a picture for example)I can track back those 2 objects in the code, however I can not understand what is the object "menu" doing there ???I highlighted it bellow your explanation :align = bottom;centerx = Stage.width/2;width/2;menuitems[i]._x = xpos;}};

View 4 Replies

ActionScript 3.0 :: Have A Hundred Instance Of A Movie Clip On The Stage?

Dec 9, 2009

ActionScript Code:
myVar.addEventListener(MouseEvent.MOUSE_OVER, dothis);
function dothis(event:MouseEvent):void
{
myVar.gotoAndPlay("rollover");
}

I have a hundred instance of a movie clip on the stage. I would like to use "myVar" to store the name of the instance that the mouse is currently hovering over, so the function will run for that instance.

how to dynamically assign the instance name to myVar on MOUSE_OVER?

View 1 Replies

Actionscript :: Get A Small Code For Testing A Microphone Which Is Written In Flex?

Dec 3, 2010

small code for testing a microphone which is written in flex/AS

View 1 Replies

ActionScript 3.0 :: Timeline Code Firing Two Times After Goto*()?

Sep 14, 2009

This is my movieclip, its on the root:frame1 code:

Code:
trace("clip()");
stop();

[code]....

View 5 Replies

ActionScript 3.0 :: Instead Of Repeating Line Of Code 16 Times, Use A Loop?

Jun 7, 2011

I have a movieclip called myButton,inside of myButton i have a textfield called buttonLabel. I have 16 instances of myButton placed on the stage with instancenames myButton1,myButton2, etc.I want the textfield inside of each button to display the same number as the one in their instance name. ie myButton1.buttonLabel.text = "1".instead of repeating that line of code 16 times, is there a way i can use a loop? something like

for (var i:int = 1; i < 17; i++)
{
myButton(i).buttonLabel.text = i
}

View 4 Replies

ActionScript 3.0 :: Create A Movie Clip By Code And Want Its Appear On Stage 5 Times?

Sep 15, 2010

actully i create a Movie Clip by Code and i Want its appear On stage 5 times ..But its add only single Movie clip on the stage ..program has no error

ActionScript Code:
package com
{

[code]......

View 1 Replies

ActionScript 2.0 :: Code A Small Variation Into The Normal Roll Over Roll Out Animations?

Jan 4, 2006

i've been trying to code a small variation into the normal roll over roll out animations... i want the animation to stay on the last frame once i click the button. but when i put the code in it dosent even bother playing the rollover/out animations it just goes to the end frame...

Code:
stop();
this.onEnterFrame = function(){
if(rewind == true){
prevFrame();

[code]....

View 2 Replies

ActionScript 2.0 :: Code In Timeline Instead Of Mc Instance

May 11, 2010

I am using onLoad and onEnterFrame events to dynamically align my_mc. The problem I face is the following:When I put my code in the mc instance it works beautifully but when I put it in the timeline it does not work.[code]I assume it is something tiny, perhaps it is an issue with the correct paths of x and y. I tried in many ways changing paths to this._x and my_mc._x but unsuccessfully.

View 1 Replies

ActionScript 3.0 :: Create An Instance Of My Class When I Want To Use Code In It?

Nov 1, 2011

There's another thing I don't fully understand in ActionScript 3 yet...

Let's say I have a class that takes care of certain things (KeyPress events, to be specific). But when I want to access the functions inside this class, do I have to create a new instance of it?[code]....

View 1 Replies

ActionScript 2.0 :: Same Instance Name Makes Code Only Work For One Object?

Apr 17, 2010

I happen to have this real massive code for an object in my game.(please guys dont move this to the game section the problem has hardly anything to do with that) One of them is a propane tank, the other a box and the third is a barrel.(it doesnt really make much diff i just want you guys to get a better picture of whats going on)So inside of each movieclip i put in this MASSIVE code.

ActionScript Code:
onClipEvent(load) {
var right:Boolean = true;
}

[code]....

it works fine but when i put in an instance name the whole thing messes up.only one of them works and all the others follow commands from the same one. so lets say if presse is true for the working on, presse will be true for all the rest. The problem still happens if i use different combinations of objects like 3 crates or 1 propane tank and 2 crates. Can someone please help me find a solution without changing the instance name. By the way '_root.hater' is the character.

View 0 Replies

ActionScript 3.0 :: Repeat Main Timeline 3 Times, More?

Aug 20, 2010

I'm stumped on getting my coding movie consisting only of tweens to just play 3 times and stop on last frame. I'd also like it to delay and stay on last frame about 10 seconds and/or delay before playing the first frame about 2 seconds. that stuff i do now with timer events- I set both for the interval (100000 and 2000) and repeat  is set to one for each, with a timer on the last and first frames. (not sure if that's the best way to do that)

View 3 Replies

ActionScript 2.0 :: Repeat A Function X Number Of Times?

Jun 23, 2006

I am trying to repeat a function x number of times. How do I go about doing that?

Here is the function:

Code:
function dance(){
var animspeed = .4;
var back = 0;
var delay = (animspeed);

[Code]...

View 3 Replies

ActionScript 3.0 :: Taking Movieclip From Library And Giving It An Instance Name Through Code?

Oct 4, 2011

I am making a game where I reference "Player_mc" quite a lot. I have a bunch of full characters (movieclips) in the library that work as the player when put on the stage and referenced as "Player_mc". I need a code that can reference those characters (movieclips) in the library, and move them onto the stage and name them "Player_mc". Also I need a way of removing an existing "Player_mc" so that another character can be referenced and brought onto the stage as "Player_mc". Here is what I have: if (this.P1Character==(Whatever that character's number is)){

View 3 Replies

Flash To Have Multiple Objects With The Same Instance Name All Being Affected By One Piece Of Code?

Oct 6, 2009

I tried something interesting recently. I had code effecting an object with the instance name : object_mc.Now I added another object and gave it the same instance name.The result was, that the code only effected the most recent added object (no error).Is there a way in flash to have multiple objects with the same instance name all being affected by one piece of code?

View 5 Replies

Actionscript 3 :: Refer To An Instance From Inside It's Own Code In Adobe Flash?

May 16, 2010

In Adobe Flash, I have a movie clip that is added to the stage when the keyboard is pressed. I want it to travel across the screen and disappear once it reaches the edge of the stage. At the moment I use this but the image appears and then stops. Here is my code:

addEventListener(Event.ADDED_TO_STAGE,runtime);
var c = 0
function runtime(){

[code]....

View 2 Replies

Flash :: Timeline Code To Object Oriented Code - Access Instances Already On Stage

Jan 12, 2011

As stupid as my question might sound, i have spent the last 2 weeks reading oop books; but could use some guidance. I have a flash project that is basically a supped up slide show. On the stage i have the following: main_mc (instance name = images_mc) = movieclip which holds "pictures" ui1 (instance name = ui1_mc) = user interface that allows user to draw on picture (when drawing is enabled) ui2 (instance name = ui2_mc) = activates invisible hit areas (buttons) on select pics, when hit area is clicked, we jump to another pic in the main_mc.

I accomplished all of this on the timeline, but am updating the code to OOP. I am having A HELL OF A TIME trying to figure out how to store references to the instances (images_mc etc..), so i can control them from varying class files. I have found it is easy to control the instances from the documentclass, but not from unrelated class files. Example: images_mc.stop(); works in document class; but ovieclip(Parent).images_mc.stop() doesn't seem to work from any class file.(ui2 class file for example);

[Code]...

View 2 Replies

ActionScript 3.0 :: Way To Have Main Timeline Code Interact With Code Inside Of Symbol.

Jan 29, 2012

I'm looking for a way to have my main timeline code interact with code inside of a symbol.I'm tying to get my timeline inside the symbol to gotoAndPlay(10) when something happens in my main timeline code.

View 3 Replies

Javascript :: Can Js Code On Site Prevent Other Js Code From Detecting Presence Of Flash

Jan 22, 2011

I'm looking for a workaround to the "AdSense does not let you choose only images but no flash" issue. I'm rather a newbie to JS, but is there any way for one script to prevent other scripts embedded in a site from detecting the presence of the flash plugin? Even if it doesn't work with AdSense, it would be nice to know if there's a hack to do this that might work in other settings.By the way, I suppose I wouldn't care if it failed to work on IE or obsolete browser versions.

View 1 Replies

ActionScript 2.0 :: Centralize Code In All Movies Using Dot Notation Instead Of Spreading Code All Over The Place?

Jul 10, 2003

I have attached a simple test fla.I am trying to centralize my code in all my movies using dot notation instead of spreading my code all over the place. It never works, I must be doing something wrong.The test .fla has a movieclip with a timeline animation. I used the linkage identifier to name it 'reload' AND named the instance 'reload'.

_root.reload.onRollOver = function() {
this.gotoAndPlay(2);
}

The pointer doesnt even change to a hand.

View 4 Replies

Flash :: Relationship Of Code On First Frame Of Main Time Line To Class Code And Library Objects?

Mar 27, 2011

Got to the point where the hole in my AS3 knowledge is getting large!Realising I have confusion about the relationship of:Body of code on first frame of AS3 file.(Which I have so far used to create instances of library objects using addchild and make calls to class code).Is this code called the document code? What do people call it?Numerous classes linked together by extending each other etc.Library objects (usually graphical objects)Should it be done differently? have the following problems due to lack of understanding:Addchild complicated from a class but straight forward in main body code.Cant call functions on the main body code from classes, because class code does not know the main body code exists?

View 1 Replies

ActionScript 3.0 :: Delete Row With Code=4, But In The DetailTable, All The Rows With Code=4 Are NOT Deleted?

Feb 4, 2010

I have 2 tables,a main table with a field code as primary key, and other table detail, named p.e. DetailTable, with 3 fiels as primary key.What I want to do, it's a delete a row in MainTable, all the rows in DetailTable,where field code is the same as field code in MainTable should be deleted too.Here is the SQL to create the tables.

var sql2:String = "CREATE TABLE IF NOT EXISTS MainTable [code]....

when tables are created, insert data. I connect without problems, delete a row in MainTable (see the code), for example delete row with code=4, but in the DetailTable, all the rows with code=4 are NOT deleted Why?

[CODE]// Inside a class
private var conn:SQLConnection; 
public function constructorClass(){conn = new SQLConnection();ConexionBD();}[code]...

View 3 Replies

ActionScript 3.0 :: Copy And Pasted Code, First Code Works, Second Doesn't?

Jun 9, 2011

I've literally been staring at this for 7 hours. I'm missing something.I have two movie clips on the stage. The instance name of the first is puzzleAK. The instance name of the second is pieceAK.The first is linked to a custom class called GeoPuzzle. The second is linked to a custom class called GeoPiece.The code compiles but throws an error (as explained).The code in the main timeline:

puzzleAK.fullName = "Alaska";puzzleAK.abbrev = "AK";puzzleAK.isLocked = false;trace ("made it through puzzle definitions: " + puzzleAK.fullName + " " + puzzleAK.abbrev + " " + puzzleAK.isLocked);

[code].....

View 7 Replies

ActionScript 3.0 :: Timeline Code And Separate AS File Code Working Together

Dec 27, 2010

Is there a way to make code on the timeline and code in a separate AS file communicate with each other?I have two buttons, a yes button and a no button.I have a confirm box which is a movie clip. In the movie clip I have the two buttons on it and code so that every time one of the buttons is clicked it runs a function.I have the rest of my code for the movie (so the code to make the confirm box appear) on a separate AS file.Is there a way I can define the functions on the movie clip and run the functions with the separate AS file?

View 7 Replies

Library/API/program For Converting Flash Code Into Html5 Code?

Aug 25, 2004

What library/API or even a program for converting flash code into html 5 code automatically do you recommend me?

View 2 Replies

ActionScript 3.0 :: Make The Whole Ad Repeat X Number Of Times And Then Stop On The Last Frame?

Dec 26, 2009

I need to make the whole ad repeat X number of times and then stop on the last frame (it always stops in the first frame for me) then I need to link the clickable button to go to a website when clicked. [URL]

View 4 Replies

ActionScript 2.0 :: Converting On-clip Code To On-frame Code?

Mar 19, 2009

converting the following code (i got from some site, i can't remember which) to on-frame code:

Code:
onClipEvent (enterFrame) {
with (_root.player) {
// Controls Player Speed

[Code].....

Basically its a movement and hittest script for a maze. It works great but I need it running within an onEnterFrame in the frame code.

Currently the code is on a clip which contains the clip "walls". and player is on the _root timeline.

View 1 Replies

ActionScript 3.0 :: Code Vs Class Code / Stage Items Go?

Oct 22, 2011

I had a 2 frame setup with some actionscript for each frame. Tried to move it all into one class file and a

1. frame .fla. ; Hiding and showing the resp. moviclips when i virtually move from frame 1 to frame

2. Now I get these ...Error #1069: Property edit_panel_mc not found on flash.display and there is no default value. errors or..

when i thought beeing clever adding the stage. prefix ReferenceError: Error #1069: Property edit_panel_mc not found on flash.display.Stage and there is no default value. The mc's are on the stage... i have a single .as classfile. Why cant I reference them? or how should i do it/ what should i do to change it from beeing .fla script to class script.

View 9 Replies

ActionScript 3.0 :: Change Bitmap Code To MovieClip Code?

Nov 17, 2011

I'm working on an app for iOS where I want to load content dynamically from the library that contains text and graphics inside different MovieClip's.However, I have a problem, the code I have is for bitmap!How can I change it so it works for MovieClip instead?I want to use the MovieClip instead of bitmap?Also want to use the MovieClip class instead of Sprite class?[code]

View 5 Replies







Copyrights 2005-15 www.BigResource.com, All rights reserved