ActionScript 3.0 :: Increase Efficiency Of Created Moves Around The Screen And Another Object

Sep 21, 2009

I wrote a class for an object that as soon as it is created moves around the screen and can create another object (replicating itself). That seems to work fine for a while, but after like 20 or so objects on the screen things slow down a lot! I create the first object on frame one. The rest is all done by the objects themselves.

Would it be better if the objects did not move around on their own, but rather through a loop on frame one or does it not matter? I am working on a simulation that should go up to over 100 objects, but with this problem can't get there. The object is just a movie clip (imported png picture about 4 by 7 pixel, not animated). I was going to replace it with an animated one later, but that seems unlikely now.

View 4 Replies


Similar Posts:


ActionScript 3.0 :: Get An Object To Increase In Size The Lower It Goes Down The Stage And Decrease In Size The High It Moves Up The Stage?

Dec 29, 2009

I'm trying to get an object to increase in size the lower it goes down the stage, and decrease in size the high it moves up the stage.

It only needs to increase or decrease by a small amount. Basically, it's for a game character. To ad realism to his movements, it would be nice to have this feature.

This is where i'm up to so far:

Code:
import fl.transitions.Tween;
import fl.transitions.TweenEvent;
import fl.transitions.easing.*;

[code]....

I think I need something like:

if (object moves up)
decrease
else if (object moves down)
increase

View 6 Replies

ActionScript 3.0 :: Keep Mc In Same Position On Screen If Its Container Mc Moves?

Apr 21, 2009

I have a large movieclip that contains all the elements of my game - the level backgrounds, the player character, the non-player characters etc. The stage is only a quarter of its width and when the player character moves off the edge of the stage the whole game movieclip moves a quarter width to the left or right, depending on which side the player character has left the stage from.

Each of the quarters of this large game movieclip are considered levels of the game (so there are four levels, obviously) and what I want to know is how do i get an object that exists in one level to appear in exactly the same position on screen in the next level, when the player moves to that level?

View 4 Replies

ActionScript 3.0 :: Change Coordinates Of Y Value So Y Increase In Value / When It Goes Up Screen?

Oct 13, 2010

is there a way to change the coordinates of the Y value so Y increase in value when it goes up the screen?Currently I change the Y points this way but of course when I do a hitTestPoint I ned to convert back Y value points.[code]

View 3 Replies

ActionScript 3.0 :: Screen Scrolling As Character Moves To Edge

Sep 16, 2009

I am trying to make my screen scroll as my character moves to the edge of it, but when I get to the edge of the screen nothing happens, I think this could be something to do with my registration points but I'm not sure. I have added trace statements for debugging but no luck. I have included my Fla so you can see what I mean.
Here: [URL]

Here is the code I am using to try and make this happen
PHP Code:
// scroll the LBground if character gets past half way up or down the stage
function scrollLevel():void {
// Horizontal scrolling
var horizontalCentre:Number = stage.stageWidth / 2;
var horizontalPosition:Number = LBground.x + Mchar;
[Code] .....

View 2 Replies

ActionScript 3.0 :: Full Screen - Works But On Esc - The FLVPlayback Moves And Shrinks

Sep 22, 2009

I'm currently working on a project using FLVPlayback Components. I'm having this issue: The user launches the page, the Component loads fine. They play the video and click the "FullScreen" button. The video launches nicely in fullscreen by using this code

[Code]....

When the user hits esc. or exits fullscreen, they come back to the movie and see that it has shrunk and moved over a few pixels. It doesnt move the entire SWF, just the component. I assume it has something to do with the "else" line. Let me know if you can be of some assistance. Linked please find my FLA and a link to the page where the issue occurs.

View 1 Replies

ActionScript 3.0 :: Programmatic Animation - Ball Moves At A Certain Speed From The Left Of The Screen To The Right?

Feb 27, 2009

I've just learned the basics of programmatic animation in Actionscript 3.0 but I can't seem to think of the right solution for this problem.Here is what I'm trying to do: A ball moves at a certain speed from the left of the screen to the right end. If there's a box in the way, it keeps bumping into it until the box breaks and it continues moving forward.The box will have a set weight that will control how much it slides when it is bumped by the ball. The ball will be pushed back a bit when it bumps the box.I have a very specific idea and all I need is a little help starting. How would you tackle this problem?

View 4 Replies

ActionScript 3.0 :: Custom Event Dispatcher - Spot Where A Player Moves Around The Screen?

Aug 25, 2009

So I have a small game where I have implemented a* path finding. I have a spot where a player moves around the screen along the path found. I have a section where i know the user is at the end of the path and I am looking to dispatch an event at this moment so I can do things at the end of the path.

i have imported the aStar_path_dispatcher file into the move class then i do,

[code]...

then in my main document class i import the aStar_path_dispatcher again, and set up an instance of it: then add a listener:

[code]...

however this "move finished" doesn't seem to want to work. I have never used custom events before

View 2 Replies

ActionScript 3.0 :: Get The Scroller Icon To Move, But It Moves All Over The Screen & Doesn't Stay Put?

Mar 5, 2011

I've searched for almost a whole week to get this thing converted,I found a great tutorial for a scrollbar that was exactly what I was looking for. I wanted something that didn't have up or down buttons, had a thin line for the track, and a circular dragger. However, it was written in AS2. I've tried to convert it myself, but I'm a complete beginner, and I know nothing about AS3 code, or AS2 for that matter. So, I've managed to get the scroller icon to move, but it moves all over the screen & doesn't stay put

var scrollUpper:Number = 31.5;
var scrollLower:Number = 381.5;
var textLower:Number = 40;

[code].....

View 3 Replies

Flash - Make A Dynamic Text Field Increase In Increments Of 1 If The User Hovers At The Upper Half Of The Screen?

Jan 15, 2012

If the counter reaches 350 and I move my mouse down now it hops on over to 250. I just want it to start counting down. I.e. 349, 348, 347 and so on. What do I need to change?

//Function
function countUp(e:TimerEvent):void{
if (mouseY < 180)
{

[code]...

EDIT: What do I need to write in AS3 to make a dynamic text field increase in increments of 1 if the user hovers at the upper half of the screen, and decrease in increments of 1 if the user hovers at the lower half of the screen?Purpose, it isn't a game.

What I have right now isn't actually doing any of those things, I've just been mucking about trying to get all the masks working and they finally are.

I've included the code to offer as much information as possible about my specific project. There is also a few more lines that changes the colour of the dial when the user rolls over the specific coloured bars. I can post that as well if it helps.

To clarify the scene, the arrow part of the dial tracks the user's mouse. Always pointing towards it. The bars, when rolled over changes the colour of said dial. The "73M" is static, as well is "POINTS" but the 380 value is dynamic. It is that string I need to affect.

If anything is unclear please feel free to ask, I've been at this all night so there is a chance I'm so into it that I can't see straight.

[code]

View 1 Replies

ActionScript 3.0 :: Object Moves With Scrollrect?

Aug 18, 2011

I have a scrolling background that is 1320 x 1000 big. I'm using a sprite as a container where my background canvas is placed inside of it. Additionally I add (via addChild) a score sprite inside of the background sprite (the one that holds the bg canvas so the score appears on top of the bg canvas).The goal is that when I add a score it shall be stuck to the background (even when the scrollrect moves; it shall have a fixed position on the background).The problem is that this doesn't work because when the score appears it moves with the scrollrect and this is not what I want. I already tried it with globalToLocal but had no success yet. Probably because I don't really understand globalToLocal (and vice versa)These are some code excerpts:

Code:
private var backgroundBitmapData:BitmapData = new BitmapData(1320, 1000, false, 0x000000);
private var canvasBitmapData:BitmapData = new BitmapData(1320, 1000, false, 0x000000);

[code].....

View 7 Replies

ActionScript 3.0 :: Flash Object Moves With Scrollrect?

Aug 18, 2011

I have a scrolling background that is 1320 x 1000 big. I'm using a sprite as a container where my background canvas is placed inside of it. Additionally I add (via addChild) a score sprite inside of the background sprite (the one that holds the bg canvas so the score appears on top of the bg canvas).

The goal is that when I add a score it shall be stuck to the background (even when the scrollrect moves; it shall have a fixed position on the background).

The problem is that this doesn't work because when the score appears it moves with the scrollrect and this is not what I want. I already tried it with globalToLocal but had no success yet. Probably because I don't really understand globalToLocal (and vice versa).

These are some code excerpts:

Code:
private var backgroundBitmapData:BitmapData = new BitmapData(1320, 1000, false, 0x000000);
private var canvasBitmapData:BitmapData = new BitmapData(1320, 1000, false,

[Code].....

View 1 Replies

ActionScript 3.0 :: How To Increase Height Of Object

Jun 13, 2010

I am a very fresh guy in flash, I have experince in Javascript , C++ and other programming languages. So I am very much interested in doing task with Action script and get results which are not possible by GUI.I want increase the height of Movie clip using action script, So I tried to increase .height property the height increased but It increased in both direction top & bottom) I want to keep it bottom fix. I tried ScaleY, too but no luck.Somehow we can adjust the bottom after resizing but it won;t give good effect when we are using tweening or other animation.

View 1 Replies

Using The 'for' Loop For Efficiency?

Jun 17, 2009

I've got a long list of code which I think can be made far more shorter by using a 'for' loop, however, I'm not entirely sure how to go about this? Here's the code I have at the moment

if(event.target.hitTestObject(zone0_mc) && zoneFull[0] == false && event.target._ballPlaced[event.target.name.substring(4,5)] == false) event.target.x

[code].....

View 2 Replies

ActionScript 3.0 :: Continuous Object Motion When Mouse Moves Over

Sep 18, 2010

I'm working on a school project. Below is an image of what I am working on. My cursor in this movie is the heart. When I move my mouse over Hello Kitty she jumps -- but only once. How can I get her to keep jumping when my mouse is over her, and make her stop jumping when I pull away?

Also, because I am new to ActionScript I might have messed up with the motion of the animation. Hello Kitty used to jump continuously without me doing anything. Then I copied the motion code into my ACTIONS layer and put stop(); in the Hello Kitty object code. So, she doesn't jump all the time anymore, just when my mouse moves over her... but she only jumps once and that is the problem. I want her to keep jumping as long as my mouse is over her.

[Code]...

View 8 Replies

ActionScript 3.0 :: Falling Object To Increase The Speed Every 20 Second?

Apr 26, 2011

I trying to learn and follow some tutorials about classes and stuff like that. If you look att my code I have posted a object called "FallingObject" falls every third second in the speed of "y += 10;" I want my falling object to increase the speed every 20 second. How do I do that?

PHP Code:

var TimerFallingObject:Timer = new Timer(3000);TimerFallingObject.addEventListener(TimerEvent.TIMER, OnStartFallingObject);TimerFallingObject.start(); function OnStartFallingObject(e:Event){    var af:Sprite = new FallingObject();    af.x= Math.random()*640;    addChild(af);}[code].....

View 6 Replies

ActionScript 3.0 :: Moving Menu That Moves On Its Own When The Mouse Moves Around It?

Dec 11, 2009

To start things off, I use Flash CS3.moving menu that moves on its own when the mouse moves around it. Like the menu moves up when the mouse moves down.[URL]i have found similar tutorials for what i wanted.. but they are AS2 or older versions of flash..and what i needed is more along the lines of AS3 as that's what my class is learning and using.Does anyone know of an AS3 or anything that works with Flash CS3 tutorial thats what I'm asking?

View 0 Replies

ActionScript 2.0 :: OnEnterFrame Efficiency?

Dec 16, 2009

Say I have 100 MC's (movie clips) in my scene that are spreading out in _x and _y. On every frame I need to check each of those MC's for a hitTest (or anything really). Would it be more programatically efficient to:A) Create a single array to hold all the MC's and do a for...loop to check all of themorB) When each MC is created create an onEnterFrame to check only itself (x100)?Hope this makes sense. This is an argument between me and my partner as to which will be the less processor intensive. My theory is that there would be no difference but I've read no documentation for it

View 3 Replies

ActionScript 2.0 :: Increase The _height Property Of A Window Without Increase The Height Of The Title?

Aug 19, 2011

How can I increase the _height property of a window without increase the height of the title and the bar at the top of the window ?

I want only to increase the part of the window where I put textFields and buttons.

View 6 Replies

ActionScript 3.0 :: A Tweened GlowFiltered Object - Movieclip No Longer Moves?

Oct 29, 2008

I have a few MovieClips that are motion-tweened via the timeline. I have a function that places a glow filter on the tweened movieclip. The glow works, but... the movieclip no longer moves. I found that if I tween via actionscript (AS3) that it does tween. However, I have about 1000 movieclips, all w/ different tween properties.Is there a (much easier) walk around or am I going to have to code for a few days/weeks?

View 1 Replies

Event Handling :: Flash Object Moves When Click On Button?

Mar 18, 2012

Possible Duplicate:ActionScript 2 Moving an object I am new to AC. I have a button and a object. Is there a way for the object to move horizontally if i press down on the button in Action Script 2

View 3 Replies

Flash :: Event Handling - Object Moves When Click On Button

Dec 8, 2011

Possible Duplicate: ActionScript 2 Moving an object I am new to AC. I have a button and a object. Is there a way for the object to move horizontally if i press down on the button in Action Script 2

View 1 Replies

Professional :: Motion Tweened Object Wiped Off Screen In Fullscreen But Remains On Screen In Closeup?

Jan 23, 2010

I'm new to Adobe Flash CS4. I'm making an animation of some fish underwater. I have 2 small fish motion tweened to follow a large fish from left to right. When I view the animation in full screen the small fish seem to be wiped off the screen at a certain point. The tween box continues to follow it's path but the symbol disappears. This only seems to happen with larger objects.

[Code]...

View 2 Replies

ActionScript 3.0 :: Create Random Object That Moves In Direction Upon Testing Movie

Oct 13, 2009

I have a flash programming research assignment using AS3.The assignment is to create a random object that moves in a direction upon testing movie. After 2-3 seconds the object needs to change random directions.

View 1 Replies

ActionScript 3.0 :: Create A Random Object That Moves In A Direction Upon Testing Movie

Oct 13, 2009

The assignment is to create a random object that moves in a direction upon testing movie. After 2-3 seconds the object needs to change random directions.

View 1 Replies

Actionscript 3 :: Why Do Object And Function Counts Increase When Setting Text

Nov 24, 2011

-Firstly can some one please explain what is meant by Object and Function in a profiling environment.

-Secondly, why does the Object and Function count increase when I repeatedly set the text property of a textfield:[code]

View 2 Replies

ActionScript 3.0 :: Flash Does It Increase Memory Use To Add And Object To Display List

Oct 18, 2010

If an asset (say an swf) is already loaded. Does it increase memory use to add and object to the display list?

View 4 Replies

Actionscript 2.0 :: Group To Object When One Object Is Drag Across The Screen The Other Object Sticks With It

Mar 26, 2009

is there a way in action to group to object so when one object is drag across the screen the other object sticks with it, im using flash btw

View 6 Replies

Professional :: Building A Music Player / Efficiency?

Mar 8, 2012

I'm creating a music player to be on my website and so far I have it set up as such: The player is contained in a movieclip with a 'song progress bar', a pause and a play button.The songs are played by clicking the song title in a list in the main stage (not contained in the player movie clip), which sends the music player to the frame in which the song starts.
 
My audio is set as event audio so that the play and pause buttons can be coded as play(); and stop(): respectively which will stop the main player movie clip thus yeilding the progress bar from moving further and the song from playing.
 
This works just fine, except for the following:
 
- When I select event as my audio type the quality reduces dramatically Having the audio files in my library and not obtained from some outside source (i.e on my website's server) causes the .fla file to be much larger as well as the .swf Being as my project is at 24 FPS and each song is represented in as many frames as it takesto play the song out, my music player at present has only 3 songs 'in it', and my frames in the movie clip are approaching 20,000 (this is VERY tedious to work with) 
 
I'm sure there is a more efficient way of doing things, but my knowledge is limited. I'd imagine I can do something along the lines of loading .mp3's off of my website into the frame and the play pause buttons will enact more elaborate scripts that not only stop the progress bar but also stop the music from playing temporarily, or something like this. But I have no idea how to implement it

View 2 Replies

Flash :: Massive Efficiency In Timeline Project?

Feb 1, 2012

this is the offending bit of code:

for (var i in yearMarkersArray) {
yearMarkersArray[i].x = ((timelines.x + 350) % 140) + (140 * i) - 5;
yearMarkersArray[i].text = "0";
}

This is part of the main loop that triggers whenever the user drags the zoomed-out timelines (the sprites in eventsArray) left or right. The six TLFText objects in yearMarkersArray appear to scroll left or right with the user, but are really repositioned and relabeled with the correct year markers as calculated by a function I did not include above (it's working and not relevant to this problem, I simply replaced it with the "0" for clarity).

The text-setting statement is the problem code...I've commented literally everything else out of the main loop to verify it. I even changed the statement to not involve any function call (simply setting the text attribute to "0"), and it still causes the final .swf to eat an extra 1% of my CPU every 15 seconds until finally the FPS crashes through the floor. The rest of the main loop has much, MUCH more complex and I'm sure inefficient code that also runs every frame,Since this project reads a data file with a list of timeline events whose span of years I cannot predict, I do need the displayed year markers to be done dynamically in some way. The code ultimately works (I only noticed the ridiculous slowdown when I accidentally left the movie open and idle for a few minutes),

View 2 Replies







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