ActionScript 3.0 :: Two Sprite Objects - Adjusting Position (X And Y)

Jan 23, 2012

I am trying to do adjustment of position (x and y) of display objects, relative to other display objects. In other words: I have two Sprite objects (rectangle and circle). The rectangle can have their width changed during execution. Yet the circle has a fixed size. What I do is this: regardless of the width of the rectangle, the circle is positioned at the far right of this rectangle.

I tried as follows:
ActionScript Code:
rectangle.width = someValue;
circle.x = rectangle.x + (rectangle.width-circle.width);

In theory it should work, but look what happens:
imageshack.us/photo/my-images/837/positionq.png

As the width of the rectangle increases the distance from the desired location also increases.
Using:
ActionScript Code:
trace (rectangle.width);

I realized that the value of property 'width' does not match the exact amount of pixels that the object is wide. I just did a test and realized that this problem only happens when the rectangle has edge. When the rectangle has only fill, this problem does not occur.

View 9 Replies


Similar Posts:


ActionScript 2.0 :: Resizing Two Movie Clips Whilst Adjusting It's X,y Position?

Jul 26, 2006

I am trying to resize a 2 or more movieclips, but when I resize them I want them to have a relative postion to one another for example decreasing the size of two movieclip touching each other, I would like the movieclips to maintain a relative x,y position.. so if decreased or increased in size they will still look the same.This movie clips are on the stage, so I can not attach it from the library.

View 1 Replies

Professional :: Adjusting Objects (Menu And Logo) On Screen

Dec 18, 2010

I am making a Flash website and I need to know how to make my Menu on left and Logo on right stay on left and right as the screen size is changed. A similar example I am trying to accomplish is this well know site. [URL]. Notice how the menu and logo stay on the right and left...I have been searching for days on how to do this. I have everything built on my stage but cannot achieve this and thought someone may be familiar with this technique.

View 1 Replies

Java :: Intercepting Date Objects Coming From BlazeDS And Adjusting For Timezone Differences?

Oct 27, 2010

I am working on an application that is near the end of its development cycle and has mostly passed user testing. We recently realized that having flex convert dates to the client's local timezone is not desired, as all of our dates are in EST and contain no time data. Since BlazeDS sends dates in UTC, this results in the dates being converted to the day before in timezones west of EST.

The best solution is to go in and refactor all dates to adjust for the timezone offset, but that is just not doable at this stage. Since all dates in our application don't care about time, I would really like to be able to intercept all Date objects that come across BlazeDS and adjust for the timezone offset.

View 1 Replies

Sprite Y Based On Mouse Position?

Jul 20, 2011

So I'm working on my portfolio and I got this problem. The code posted scrolls the sprite "cellContainer" based on the position of stage.mouseY. Perfect.Problem is that I want stage.mouseY to equal the entire cellContainer height. Kind of like how a small tablet equals a huge monitor. So when stage.mouseY = 0,cellContainer.y = 0 and when stage.mouseY = stage.stageHeight, cellContainer.y = stage.stageHeight - cellContainer.height. Right now, it scrolls, but it takes a while to scroll throught the entire height of cellContainer. I want it to be proportional to stage.mouseY.

Actionscript Code:
private function scrollStart(e:Event)[code]....

View 4 Replies

ActionScript 3.0 :: Set X And Y Position Of A Class That Inherits From Sprite?

Feb 15, 2009

I have a clas that inherits from sprite but i want to know when the x and y is set so i can make changes inside the instance, but i cant figure out how to do that...

i need it so that say if i set the x with the normal x property, it can set another variable or run a function.

View 2 Replies

ActionScript 3.0 :: Position A Loader Image Inside A Sprite?

Sep 18, 2009

In AS3 / CS4 I'm trying to programmatically create a bunch of rectangular objects, let's call them 'cards', that will contain an image and a colored background and eventually some other elements like text.  I want to create alot of these cards and move them around inside of a larger panel (also a Sprite) of sorts.  I can successfully create colored rectangles in my cards and place the cards where I want in the panel, but whenever I try to add an image to a card, I can't seem to position the image inside the card's coordinate space, it ends up being placed inside the larger panel's coordinate space instead, even though I'm adding the image/loader as a child of the card.  I thought maybe it had something to do with having to wait until the image loading was complete, so I added the listener as a test but that didn't work.  Here's the code:

[Code]...

View 1 Replies

Actionscript 3 :: Force A Sprite To Position Children In Reference To 0,0?

Sep 26, 2010

I'm trying to add some scroll bars to a Sprite using ScrollRect. The Sprite starts empty and when I add something at 500, 500, it should scroll, as it is outside the viewport. Unfortunately, adding a 10x10 Sprite at 500, 500, doesn't make my Sprite change its size to 510, 510, but to 10, 10 ::- (.

We all know that DisplayObjectContainers resize according to what's put in them. But I didn't know up until today that if you put something at 500, 500, the Sprite / DObjContainer will NOT resize from 0, 0 to 500, 500, but simply jump directly at 500, 500. Annoying, as I cannot put Scrollbars on something whose content fluctuates so. I need 0, 0 to remain 0, 0 and if something is placed at 500, 500, the sprite's height should increase with 500 + that something's height.

View 3 Replies

ActionScript 3.0 :: Force A Sprite To Position Children In Reference To 0,0?

Sep 26, 2010

I'm trying to add some scroll bars to a Sprite using ScrollRect. The Sprite starts empty and when I add something at 500, 500, it should scroll, as it is outside the viewport. Unfortunately, adding a 10x10 Sprite at 500, 500, doesn't make my Sprite change its size to 510, 510, but to 10, 10 ::- (.

We all know that DisplayObjectContainers resize according to what's put in them. But I didn't know up until today that if you put something at 500, 500, the Sprite / DObjContainer will NOT resize from 0, 0 to 500, 500, but simply jump directly at 500, 500. Annoying, as I cannot put Scrollbars on something whose content fluctuates so. I need 0, 0 to remain 0, 0 and if something is placed at 500, 500, the sprite's height should increase with 500 + that something's height.

View 9 Replies

IDE :: How To Remove Sprite Objects

Jan 31, 2010

I once saw an effect on a flash add I wanted to try make myself also - the cursor makes a vake that blur out and disapear, much like the vake of a plane, just faster. The problem is I need to remove the vake when it has faded out, or else it just stay in the background and fill up forever! I know there must be an easy way for this. Can some of you tell me the best way here? I have attached the fla-file and scripts. You see a comment where I try to put the code...

View 1 Replies

ActionScript 3.0 :: Objects Added To Sprite / MC Not Appearing

Jun 24, 2010

I've been working on building a game and encountered a strange problem this morning when instead of adding objects directly to the stage I needed to add them to a Sprite (I also tried this with a MovieClip) which was on the stage instead and they did not appear. And yes, before anyone says it, the MC/Sprite that I'm adding the objects to has definitely been added to the stage, I've made that mistake before and don't plan on making it again

Essentially I have been building the game's levels using various different objects (rectangles, circles etc) built in the Box2D physics engine and with attached sprites to represent them to the user. When creating each of these object I supply a DisplayObjectContainer in which the sprite representing the object should be placed. Up until now I have been simply been supplying my core game class as the DisplayObjectContainer, with no problems whatsoever - everything is displaying fine.

A new level design, however, will require me to apply a mask to the entire level (but not the GUI) so I decided to place all the level objects within a MovieClip or Sprite instead. I have created the new sprite as such:

levelObjects = new Sprite();levelObjects.x = levelObjects.y = 0; //Just to make surelevelObjects.width = GameProperties.stageWidth;levelObjects.height = GameProperties.stageHeight;levelObjects.visible = true; //Just to make sureaddChild(levelObjects)

And have been supplying this sprite to the level objects as a DisplayObjectContainer instead of the core game class. Everything is getting added to the stage as I can click on things and the sounds associated with the game objects are playing correctly, but nothing is actually visible! As I mentioned above I tried this using a MovieClip instead but got the same result.

View 5 Replies

ActionScript 3.0 :: Limit To How Many Sprite Objects Can Be Displayed?

May 2, 2010

Okay I have this little script Simple script, parses xml file and creates instances of custom class Tile derived from Sprite, in "Tile" I draw Shapes (lines) depending on what wall is set the shapes are drawn and added to the sprite "canvas". Now I can get 7 sprites aka Tiles to show, but no 8, 9 or more. Is this intended? Did I make a mistake/ need to take a different approach? btw I'm using FlashDevelop (haxe.org) with flex_sdk_4.0.0.14159_mpl but created an as3 project

[Code]...

View 3 Replies

ActionScript 3.0 :: Create Nested Sprite Objects?

Jul 30, 2009

I have tried to create nested Sprite objects. But I see only the bigger square.

var square:Sprite = new Sprite();
square.graphics.beginFill(0xFFCC00);
square.graphics.drawRect(0, 0, 100, 100);

[Code].....

View 1 Replies

ActionScript 3.0 :: Create Arrays Of Bitmap And Sprite Objects?

Aug 9, 2009

can you create arrays of Bitmap and Sprite Objects? or Custom Objects?

if not, how would you typically create multiple Objects of the same type? just a loop with

var enemy:Sprite = new Sprite();
for(var count:int=0; count<10; count++)
{
enemy = new Sprite();

[Code].....

That way could be fine for many things, but theres other things I want to do.. such as, create an array of wav sounds.... and my program could pick and choose them, so they wouldnt need to load them on demand.. midi files too.

View 5 Replies

Flash :: IDE - Gradiant Fill Direction In One Of Sprite Objects

Oct 27, 2009

I can't say that I have played with it much, but I was looking to use a gradiant fill in one of my Sprite objects I created in flash. Seems that the gradiant fill always goes left to right... how can I make it go up and down? I know I can rotate the object, but then I would mess with the x and y scales that would mess me up later down the road. is there a way to change it to vertical fill?

View 2 Replies

Flex :: Flash - Using Sprite Objects In A MXML-based Application?

Oct 25, 2010

Canvas.addChild() insists any DisplayObject added implements IUIComponent. But I don't want my core graphics engine dependent on Flex. Is there an obvious/common way around this, to have simple graphical objects like Sprites & Shapes in a Flex application? The individual DisplayObject children I want to add as children represent objects in a game world, like a spaceship or a missile or a horse...

Not sure if Canvas is the most appropriate container, perhaps Group or another class is optimal for a game-engine... example MXML & AS3 code showing a skeleton setup is most welcome. I'm targeting Flex4 & Flash 10, but Flex3/Flash9 solutions are still of interest.

View 1 Replies

Actionscript :: How Much Faster Is Blitting Than Using Vector Sprite Objects In Flash

Feb 18, 2011

I know there are different situations where one would be better than the other, but I'm comortable with a generalized statistic of... How much faster is blitting than using vector Sprite objects in Flash?

View 2 Replies

Tracking An Objects Y Position?

Jan 23, 2010

I did have previous help with screen movement from Vincent, unfortunately how to get a Variable that tracks an objects Y position on movemnt is eluding me

View 7 Replies

ActionScript 3.0 :: Using For Loop To Get Objects X Position?

Nov 5, 2009

I have 4 objects that I all want to have their own velocities. I have a bunch of variables (each one has a different value):
PHP Code:
public var vx1:Number;public var vx2:Number;public var vx3:Number;public var vx4:Number;

Rather than having a function for each object to say:
PHP Code:
function1 { this.x = vx1}function2 { this.x = vx2}function3 { this.x = vx3}function4 { this.x = vx4}

I'd like to have a for loop to have my objects x position to += vx(1 through 4):
PHP Code:
for (var i:Number=0; i<5; i++) {
this.x += (vx+[i]);
}

So I tried the above with a combination of " " around different parts of (vx+[i]) but I realized that turning any of it into a string means 'this.x' cannot read it because x has to be a number not a string. So how can I make this.x = vx1 then vx2 and so on with a for loop?

View 2 Replies

ActionScript 3.0 :: Position Objects By Percent?

Jul 14, 2009

The buttons are all set up in Action Script and not placed on the timeline at all.Here is the code for postion on the buttons.I do not want to move the buttons by PixelsI would like to move the buttons by Perectage so it will look the same on all computer monitors.The person that I am editing the file for would like them in the bottom left of the screen.Here I have moved them by Pixels but these buttons do not appear in the same place on all monitors.

///////let's set the position of
the buttons across the bottom of the screen
b1.move(-350,150);

[code]......

View 5 Replies

Flex :: Position Objects On Different Resolutions

Feb 17, 2010

A Flex project exported as a Projector, showing fullscreen. The project has a background and several dots which each represent a "Location". These locations are fetched from an XML file and have their position set in percentages. The location in pixels is calculated (this works as it should) by the width and height of the Application. The dots are placed correctly. The background is a JPG with a resolution of 1280*1024. At this moment, the background is set on a Canvas with backgroundSize = auto. This places the image in the center without stretching it. Stretching results in ugly, pixelated images and tears the proportions apart.

Problem When we view the project on 2 different resolutions (1 = 1280*1024; 2 = 1024*768), the dots are in the good position, the background image is sharp. But - because of the background having the same resolution as 1, the background isn't fully shown in resolution 2 (because it isn't stretched. A logic result. That's why I tried stretching the background. The results:

[Code]...

View 2 Replies

ActionScript 3.0 :: Ease Objects From One Position To Another?

Jun 24, 2009

I know how to ease objects from one position to another etc, but how do you make it ease position as well as transparency? so it fades in while moving to it's new position?

Code:
var WelTween:Tween = new Tween(welcome, "x", Strong.easeOut, CurMarkXPosWel, 277, 2, true)

is there a way to add like 0% opacity to 100% opacity in the same line of code or do you do seperate?

View 2 Replies

ActionScript 2.0 :: Position Objects In Browser?

Aug 5, 2004

how do you position objects in browser using flash?

View 10 Replies

ActionScript 3.0 :: CSS To Determine Position Of Objects?

Sep 7, 2010

Is it possible to place object on stage with positions read from a CSS file?Basically what I want is to create themes for the application. As and when a different theme is selected, xy position, skins and colors of objects should get applied accordingly.How far its practical? If this is not practical could any one suggest a better way of applying theme

View 1 Replies

ActionScript 3.0 :: Change Objects X , Y Position On Each Frame?

Feb 26, 2010

I have a script where i need an objects X and Y Position to change when you enter a certain frame.

On layer 1 i have an input text field with the instance of "message_txt" that runs along all 5 frames in the timeline.

On layer 2 i have 5 frames each with its own actionscript on. The user navigates between frames with simple 'gotoAndStop(4)' etc... on each next or back button.[code]...

View 2 Replies

Professional :: As Objects Change Position On Several Key Layers?

Feb 18, 2011

I have several objects, moveclip, graphics and shapes in several layers keys and want to change position, for example, a moveclip is in the position X: 218 Y:45 and so in other key layers,To change it to X: 240 Y: 50, I go to keyframe for keyframe touch the object and go to properties and change one by one is annoying.Is there any way to do this more quickly at one time in all key frames?

View 1 Replies

ActionScript 2.0 :: Dynamically Create And Position Objects?

Mar 3, 2006

I'm trying to create 49 total objects, each 50x50 px. And position them in 7 rows and 7 columns. I think I must use nested for loops but this is all Ive come up with.

[AS]for(i=1;i<=7;i++) {
for(i2=1;i2<=7;i2++) {
duplicateMovieClip(_root.tMain,"targ"+i+i2,i+i2);

[Code]....

View 5 Replies

ActionScript 3.0 :: Tweening Objects To Specific Position?

May 10, 2011

Right now I'm working on a website that has movie clips that I want to tween back and forth across the stage when a button is pressed.

Here's the idea:

When 2_btn is pressed, I want 1_mc, 2_mc, and 3_mc to move from right to left and then stop when 2_mc is positioned on the stage, stop moving and play

Then if 3_btn is pressed I want all three to be animated from right to left until 3_mc is positioned on the stage, stop moving and play

Then if 1_btn is pressed I want all three to move from right to left until 1_mc is positioned on the stage, then stop moving and play

Basically I have no idea how to accomplish this, or how to word it into Google.

What I have right now, which obviously isn't accomplishing what I want is:

Tween from left to right across the timeline, and then using a gotoAndPlay, and then stop(); on the frame..

View 2 Replies

ActionScript 3.0 :: Sending Position Of Objects To External Script

Oct 7, 2009

I have a flash script which creates instances of movie clips and stores them in an array. What I want the script to perform next, is when clicking a "save" button the position and the movieclip class name of each created instance will be sent to an external script to store.

View 6 Replies

ActionScript 3.0 :: Change Y Position Of Objects Added With A For Loop?

Oct 29, 2009

here's my code:

ActionScript Code:
for (var i:int = 1; i < 10; i++) {
var symbols = new targetTester();

[code]......

View 2 Replies







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