ActionScript 3.0 :: Removing An Object When It Reaches A Certain Point

Aug 15, 2010

I have a rounded rectangle that the x and y values will always stay the same. However it rotates around and it's height is increased (it follows moving targets). (Think of it as a turret that shoots out a beam of light that will always be anchored to the turret on one end but it gets longer and rotates so that it constantly tracks the moving targets) I want to remove the object when it moves off the screen.

Normally I would just do this with:

(if myObject.x >= 550){
removeChild(myObject);
}

and the same for each other direction of the screen. However, as mentioned, it's not the x and y values that are changing - it's the height that's changing.

Now I've tried just swapping out 'x' for height:

(if myObject.height>= 550){
removeChild(myObject);
}
etc. for the rest.

But the problem with that is that if my turret (the anchor point for beam of light) is closer to the edge of the screen (i.e. it's x is 500), then it will take a couple of second's for the light beam's height to reach 550.

View 0 Replies


Similar Posts:


ActionScript 2.0 :: Randomly Pick From The Three Mcs As The First One Reaches A Certain Point

Dec 29, 2004

i'm using Mx Flash and i am making a game. it is called "falldown". the 'ledges' that you run into as you are falling down need to go up. i have the mc that moves up and all, but there needs to be three of them that move up to keep you from hitting the bottom. i need it to randomly pick from the three mcs as the first one reaches a certain point. in case you don't understand ask questions and i am going to post the .fla when i get on my own comp.

View 2 Replies

ActionScript 2.0 :: Randomly Pick From The Three Mcs As The First One Reaches A Certain Point?

Dec 29, 2004

i'm using Mx Flash and i am making a game. it is called "falldown". the 'ledges' that you run into as you are falling down need to go up. i have the mc that moves up and all, but there needs to be three of them that move up to keep you from hitting the bottom. i need it to randomly pick from the three mcs as the first one reaches a certain point.

View 2 Replies

ActionScript 3.0 :: Play Mc If Scaling Of Loader Reaches Set Point?

Nov 4, 2010

I have a scale up and down function that increases or decreases the size of an external loaded image inside a loader. What i am now trying to do and having trouble with is playing certain messages when the scaling reaches a certain point.

For instance when the user uses the 'increaseScale' function and scales 'image_Content' up by 40% its original size then 'warning_msg.visible = true;'

When they increase it by 65% then 'stop_msg.visible = true;'

This will then respond the same way if the user decreases the scale back to 40% and so on.

I cannot work this one out, i have posted the code below and have attached the fla file...

Code:
//------------------------------------------------------------------------------------
// Messages
//-----------------------------------------------------------------------------------

[Code]....

View 2 Replies

ActionScript 2.0 :: If The Y Value Of The Mouse Cursor Reaches A Certain Point, The Scrolling Stops

Oct 13, 2009

Basically I have a scrolling bar with thumbs of images that you can click and view. The bar scrolls depending on where the mouse is located along the X plane. Basically, the greater the value of X, the faster the bar scrolls to a certain extent. I am trying to figure out a way that if the Y value of the mouse cursor reaches a certain point, the scrolling stops. Like if the mouse is scrolling off the bar of images itself, the scrolling stops. As it stands the scrolling is only controlled based on where the mouse is located along the X plane and it has nothing to do with the Y value. I would like to be able to stop the bar with a certain Y value. Make sense? I Hope So :P

[Code]...

View 1 Replies

ActionScript 3.0 :: Next Video Play When The First Video Reaches Cue Point - Error 1046

Jan 6, 2010

I have a project where I am bringing in one video with a cue point at the very end with the name of "End." I'm trying to have the next video play when the first video reaches that cue point. I keep getting this error: 1046: Type was not found or was not a compile-time constant: MetadataEvent. Here is the relevant code I believe:

[Code].....

View 7 Replies

ActionScript 3.0 :: Looking For An Alternative Way Of Coding "if(property Reaches This Point)"

Oct 31, 2010

I need to put in code something like "when". I mean i need to add an Enter Frame listener that establishes mc.rotation += 4; and then something like "when rotation == 0" (meaning when rotation reaches value 0) stop (mc.rotation += 0).

Code:
mc.rotation += mcRot;
if(mc.rotation == 0){
mcRot = 0;
}

View 2 Replies

ActionScript 2.0 :: A Line From One Point Past Another Point And Whether It Hits An Object?

Aug 19, 2009

I am using AS2 with Flash 8 Professional So, my problem is that I currently have a man in the middle of the screen, who shoots a line towards the mouse when I click. However, when I use hitTest to see if the line collides with another object, Flash recognizes the line as a large box if it is diagonal, so the hitTest isn't very accurate. The line only satys there for one frame, so I can't have the usual moving-bullet-style. I am either looking for a way to create an imaginary line with AS from the starting point to the mouse and beyond, and tell whether or not this line intersects with an object... or some other way that I haven't thought of to fix my problem. Keep in mind that the line rotates from a center point towards anywhere around it for 360 degrees.

View 1 Replies

ActionScript 2.0 :: Make An Object Move From Point A To Point B In An Arc?

Mar 27, 2008

how to use these in order to make an object move from point A to point B in an arc.Think of that classic game where you have to input the angle and power and try to hit your opponent.

View 1 Replies

ActionScript 2.0 :: Removing Everything After A Certain Point In A List

Mar 28, 2007

I've got a listbox that gets filled with a bunch of actions. But when there's a crash, i want everything at that point and beyond to be removed from the list. The list will then contain only everything upto the crash. I've been having trouble getting this to work:

[Code]...

View 3 Replies

IDE :: Move An Object From One Point To Another Point On Graph?

Jan 9, 2006

Basically what I like to ask is how to move a object from one point to another point based on the point tat you have clicked on a graph. For example, If I click on this coordinate (2,3) on graph, the object (movie clip) will move to that point.

View 3 Replies

ActionScript 3.0 :: Toggle Direction As Object Reaches Ends Of Frame

Jan 9, 2010

I am trying to achieve a "Knight Rider" KITT animation where the rectangle slides back and forth between the edges of the frame.The problem is I can only get the rectangle to move in one direction and then it back-steps and keeps moving in that same direction right off screen.How do I get the toggling effect?[code]

View 5 Replies

ActionScript 3.0 :: Playing MovieClip When Object Reaches Half Of Stage

Feb 2, 2011

I am creating a movieclip in which when my character reaches the half of the stage another movieclip will play.

package{
import flash.display.MovieClip;
import flash.events.Event
public class chesteragain extends MovieClip{
private var chesterback:MovieClip = new mcChesterback;
[Code] .....

View 3 Replies

ActionScript 3.0 :: Dropdown Menu RollOver Removing Click Point

Feb 8, 2010

I have a site which is basically made up of two swfs. TopNav.swf, which is a dropdown menu, and container.swf. TopNav.swf is loaded into the container.swf. Right underneath TopNav is a movieClip that serves as a link. But for some reason once the dropdown menu rolls over the movieClip, the link disappears and is no longer clickable.

View 1 Replies

ActionScript 3.0 :: Make An Object Point In The Direction Of Another Object And Move Towards?

Aug 19, 2009

I'm still new to AS3, and I was wondering how to make an object point in the direction of another object and move towards it if they are a certain distance from one another. I haven't been able to find out how to do this from the Adobe devnet, so I thought I'd ask here.

View 1 Replies

ActionScript 2.0 :: Removing The Shared Object Pop-up?

Aug 7, 2011

I was thinking if there was a way to remove the shared object pop up from popping up lol?Its because Im making a game where when the player saves the pop up comes up over a 100 times and it's really frustrating, so I was thinking if you could remove the pop up entirely by using actionscript?I've found a script that shows the popup:System.showSettings(1);So is there a way to reverse this script? like System.hideSettings(1); ?

View 1 Replies

ActionScript 2.0 :: Removing Object From Array

Dec 15, 2009

I've made a little movie that reads items from an XML document and when you click on a thumbnail it adds the details and the price to a list and totals the amount. The problem I'm having is when you want to remove an item; I want to make it so that the items all shift up and there isn't a gap in there but at the moment they're overlapping sometimes when you remove something from the middle of the list.I'm not really sure where the problem lies because I've been staring at this for a few days now nothing's coming to me. It's probably in the below area, I think it's going haywire when the array gets remade but the num property of the remove button doesn't get updated.[code]I've attached all of the relevant files if anyone wants to take a look at it in action. Also, I know some of the code might seem a bit strange (like reading the XML in a loop and then pushing that into a different array) but there is a reason for it, I've stripped that part of the application out though.

View 0 Replies

ActionScript 3.0 :: Removing A Parent Object?

Jul 3, 2011

I have an object called helpDialog that has a sub-object called "closeX"- You click the X and the helpDialog closes. But I'm a little stuck. Let's say I add a new helpDialog to the stage:

Code:
addChild(new helpDialog());
and let's say that closeX has the following class definition:

[code]........

View 5 Replies

ActionScript 3.0 :: Removing Object From Memory?

Aug 5, 2011

I have this line

Code:
this.parent.removeChild(this);

So basicaly the object is removing it self from the parent object,but I still think that it exisits in memory and doing its backend job.How can I remove it completely from memory?

View 8 Replies

ActionScript 3.0 :: Removing Null Object?

Nov 5, 2009

I am having some problem removing a null object and I realise that I have not been unloading my swf's properly. Could someone take a look at what I have been doing and tell me what I can do to make it better. I am putting my website in an exhibiton of my design work and if it lagged up due to all the clicking it would suck! so its important.

Code:
aboutBtn.addEventListener(MouseEvent.CLICK, aboutLoad);
function aboutLoad(e:MouseEvent):void {
ldr.unload();[code]....

View 2 Replies

Removing Object From Stage After A Period Of Time?

Jul 28, 2011

I have an item that I want to appear on stage (see code below); but only for 5 seconds. After 5 seconds I want the object to disappear. I know that I can use removeChild to remove the object, but I don't know how to keep the object on the stage for a specific amount of time.

Here's the code:

stop();
//Add a movie clip to stage
var sample_mc:LibrarySymbol = new LibrarySymbol();

[Code].....

View 2 Replies

ActionScript 3.0 :: Removing Child As Array Object?

Jul 24, 2009

I have written this little script, as i want to remove some of the text fields that are currently contained within the Display Objec, however it does not like to see the TextField as a varaible name. How would i convert the object from an array to become a textfield that can be removed, after being added through
addChild()
 
This is the script
 
var delayHeading:Number = 1500;var repeatHeading:int = 1;var setShow:Timer = new Timer(delayHeading, repeatHeading);setShow.start();setShow.addEventListener(TimerEvent.TIMER_COMPLETE, maybeLater);

[Code].....

View 5 Replies

Professional :: 3 Object HitTest - Removing Instance

Jul 7, 2011

I am trying to make the instance 'red' be removed when all 3 objects have hit it here is my code:

var hit = 0;
addEventListener(Event.ENTER_FRAME, hittest);
function hittest(e:Event){
addChild(blue);addChild(green);
addChild(pink);
addChild(red);
[Code] .....

View 2 Replies

Actionscript 3 :: Removing Just A Set Of Instances Of An Object From The Scene

Apr 11, 2012

I have a problem in ActionScript 3 with a project where I am to output a bunch of data in a diagram and as pure text. This is not the problem, though. The problem is that when the user changes the type of data he wants shown. I would then remove the currently shown columns in the diagram, and add new ones. But my code removes ALL columns, so that there is no diagram at all!

I've done it all in Flash CS5, and the columns are instances of an object I made (a rectangle) which I just add to the stage. All the instances are added to the container "container." When I want to remove them, and add new ones I use:

var container = new Sprite(); // The container for my diagram
function emptyContainer() {
if (container.numChildren > 0) {

[Code]...

I wonder where to place my function for removing all children, to remove just those children that were added earlier. To matter where I place the function (at the start of fChange, at the beginning of each case) there is NO diagram shown, either new or old.

View 1 Replies

Actionscript 3 :: Removing Object From The Display List?

May 10, 2011

I have an application that uses a main class to control other MovieClips, adding and removing them as needed, most of them are separate screens or sub menus.

When I leave the main menu and come back to it later from another screen, certain animations and roll over buttons still play, which I don't want, I basically need the main menu screen to reset every time it is seen.

I read up on this and found out that removing the child doesn't necessarily remove it from the memory.

I tried setting the mainmenu to null before moving onto a different screen but this threw up an error, stating that the parameter child must be none null.

how to completely kill my mainmenu when it is not needed.

public function confSubMenuOneScreen():void {
subMenuOneScreen = new SubMenuOne();
mainmenu = null;

[Code].....

This is the example of code that removes the menu and adds another screen, with the mainmenu = null code that throws up the error.

View 1 Replies

ActionScript 3.0 :: Closing Or Removing A Netstream Object

Jun 25, 2009

I have problem closing or removing a netstream object. the object is created in a class I wrote. that class is added to a sprite object. when I remove the sprite which the netstream is a child of the netstream still plays. I know I can use close() to close the netstream but the problem is that the object that removes the sprite does not know that there is a netstream object in the sprite.

View 2 Replies

ActionScript 3.0 :: Error When Removing Object From Stage

Sep 21, 2009

When I use parent.removeChild(this) it works, but throws out these errors: TypeError: Error #1009: Cannot access a property or method of a null object reference.

The object is supposed to remove itself when it ran out of energy.

View 1 Replies

ActionScript 3.0 :: Removing Object After Tween Completed

Oct 15, 2009

1. How to remove rec_mc after the tween is completed?
2. How to insert a period of time in between two states?

ActionScript Code:
import gs.TweenLite;
changeRectangle();
removeRectangle();
function changeRectangle():void{
TweenLite.to(rec_mc, 5, {tint:0xFF0000, alpha:1, x:150});
} function removeRectangle():void{
removeChild(rec_mc);
}

View 3 Replies

ActionScript 3.0 :: Removing Object With Delete Button?

Feb 2, 2010

I have created a delete button, and when the user clicks it.. I want it to delete the selected movie clip. I have created a variable selecteddrawing to store whatever movie clip is currently selected.

when i call the event listener, and tried removeChild(selecteddrawing) it gives me this error:

ArgumentError: Error #2025: The supplied DisplayObject must be a child of the caller.
at flash.display:isplayObjectContainer/removeChild()
at SendLove/deleteListener()

Here is the code that i just wrote for the delete button. I will attach the entire AS3 file as well.

ActionScript Code:
create.delete_btn.addEventListener(MouseEvent.MOUSE_UP, deleteListener);
private function deleteListener(event:MouseEvent):void {

[Code]....

View 1 Replies

Actionscript 3.0 :: A Btn With The Function - Adding N Removing D Object

May 21, 2009

I want to make a button with the function, adding and removing display objects. I have a button named solutions. I wrote the basic code for adding the external swf file and test the movie. When I click the button at first time, it loads the external swf file. However, when I click the button at 2nd time, it runs the external swf file again. I can't figure out how to write the code to tell the button not to load the file again when the file is already loaded.

View 2 Replies







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