ActionScript 3.0 :: Getting Coordinates From A Dragged Class

Jul 7, 2009

I have a simple game that allows the player to drag counters around a board (just a background image).There are 23 counters created in the main .as class by calling another class, called "Units.as". The counters are added into an array in the main class like this:counterarray[0] = new Units("1",2);(where "1" and 2 define the label and colour of the counter)I do this for all 23 counters.[code]The class Units.as defines the counters as rectangles and places mouse listeners so they can be dragged around.My problem: I want to save the information about the counters to a shared object, but if you move a counter around, the counterarray[0].x and .y remain stubbornly where I originally set them - as 100 and 50.

I tried passing the x and y co-ordinates to Units (e.g. counterarray[0] = new Units("1",2,100,50); ) but while this works for placing the units, the value of counterarray[0].x is now zero and doesn't change when the counter is dragged around.I've only been using AS3 for a couple of weeks so suspect I am missing something obvious, but I've spent the last couple of days searching the internet & can't find it.

View 5 Replies


Similar Posts:


ActionScript 2.0 :: Flash8 - Passing MC Coordinates To A Function Within A Class

Jul 21, 2009

I have a class named Test in Test.as file :

Code:
class Test{
public function set movePlayer(_Playah:MovieClip):Void {
trace(_Playah._x);

[Code]....

and when I "run" this function in my .fla file, its says "undefined" (for this position) how to "pass" MC informations to a function inside a class (x,y coordinates, rotation..) although when I trace only "_Playah" it shows the correct name of MC i've passed to it.

View 2 Replies

Actionscript 3 :: Convert Global Coordinates To Local Coordinates Of A UIComplenent In Flex Project?

Dec 19, 2011

I was trying to convert global coordinates to local coordinates of a UIComplenent in my flex project using below code using below code

var gp:Point = new Point(e.stageX,e.stageY); //global point
var lp:Point = uic.globalToLocal(gp); //local point

uic is UIComponent in which I have subclass of Sprite for drawing something I have set the sprite's mouseEnabled and mouseChildren to false to not interrupt the mouse event. above code is within uic's mousemove event where I was tracing the gp and lp gp was giving correct value and suprisingly lp was giving negetive values. when I move the move to the top left corner of uic i expect lp to be 0,0 but it is giving the -width of of uic. I broke my head for hours and ended up finding an alternate by using offsets. Infact my original code was much simpler like this which was same issue

var lp:Point = new Point(e.localX,e.localY);

I am not sure what exactly is causing this problem. the workaround had lot of issues and it creating a mess in my rest of the algorithms.Just now I found even more interesting thing (which is actually weird). for some reason I went and create a new lp2

var lp2:Point = new Point(e.localX,e.localY);

now surprisingly it was giving correct values as expected and I went back and changed the code as

var gp:Point = new Point(e.stageX,e.stageY); //global point
var lp:Point = uic.globalToLocal(gp); //local point
var lp2:Point = new Point(e.localX,e.localY);
var lp2:Point = uic.globalToLocal(gp);

now it is expected to have all the lp, lp2 and lp3 variables to be same but weiredly lp two is giving wrong value and lp2 and lp3 were giving correct. I am suspecting using the variable lp has something to do. I am not sure about that but above proves it so right now I am using lp2.

View 1 Replies

ActionScript 2.0 :: Converts 3d Coordinates To 2d Coordinates - Difference Between MoveTo And LineTo?

May 21, 2007

I was reading the 'Isometric Transformations' tutorial by Danko Kozar and I have a few questions. I understand what all the code does, but not how it does it. First of all, how does the following code work:

transforms x,y,z coordinates into Flash x coordinate
xFla = function (x, y, z) {
// cartesian coordinates[code].....

I understand that it converts 3d coordinates to 2d coordinates, but I don't understand how. What numbers whould be punched into x, y, and z to acquire certain desired effects?Also, what's the difference between moveTo and lineTo:

red line
style(1, "0xFF0000", 100);
plot(0, 0, 0);
draw(200, 0, 0);

View 4 Replies

ActionScript 3.0 :: Converting Papervision Coordinates Into Cartesian 2D Coordinates?

May 3, 2010

Im making a little app in flash using papervision I want to make a regular movieClip show up in the same place as a papervision object. The coordinates seem like perspective is affecting the number displayed.

View 2 Replies

MC's Animation - Dragged Horizontal Motion

May 10, 2009

I need help with MC's animation causing a weird conflict. I have a movie clip come out and appear to drag another to the side of the stage. I get a weird wobble and dither from the mc that is dragged in horizontal motion. I have included a simple example, the original has complex motion on the "arms: so I used a simple box to demonstrate problem. I am at a loss as to what is causing this. This is a flash cs4 file.

View 2 Replies

ActionScript 3.0 :: Mc Mirrors Position Of Mc Being Dragged?

Nov 14, 2009

I have 2 mc's which can be dragged. When one is dragged I want the other to mirror the position of the dragged one.

say they are mcA and mcB
if mcA is dragged,
mcB's x should = mcA's x and
mcB'sY should = mcA's Y * -1

same for when B is being dragged but reverse obviously

I want this to execute continuously while one of the mc's is being dragged. I tried using while with a boolean, maybe you can't? here is what I tried to simply get one to work, just B to follow A when A is dragged.

PHP Code:

var dragging:Boolean = false;
main_mc.mcA.addEventListener(MouseEvent.MOUSE_DOWN, startDraggingAB);
main_mc.mcB.addEventListener(MouseEvent.MOUSE_DOWN, startDraggingAB);

[Code].....

View 2 Replies

Dragged And Dropped Into An Area(suitcase)

Nov 28, 2009

I have set up some objects so that they can be dragged and dropped into an area(suitcase). This works fine but the thing is that when I move to another part of the timeline the object is put back in the same position it was in before being dropped in the suitcase. I need to be pointed in the right direction with this:

a) If an item is dropped into the suitcase then a message is displayed saying for example "you packed the socks"( I think I can handle this).

b) The object should stay in the case and be displayed there until the interaction moves on(I need this to happen).

c) The user must pack all objects before moving, so I need a way of recognising all objects are packed so that the user can move on..(I need this to happen).

View 3 Replies

Movie Clip Used In One Fla Be Dragged And Dropped Into Another?

Apr 21, 2010

Can i create a custom text animation or something. Ofcourse without involving variables. And can i use this Movie clip in various projects. What am i supposed to do, save it and keep it as a .fla or can the movie clip alone be saved and imported into various projects ?

View 5 Replies

Text Appears As Mouse Is Dragged Around?

Jul 2, 2009

I'm just wondering if it's possible to have a page of text that is 'invisible' (for want of a better word) and when you move your mouse over the page, the text appears in a circle (of whatever radius) around the mouse point.The text would be clearest and darkest at the mouse point, and fade out towards the outer circle, and 'appear' smoothly as the mouse is dragged around the white page.

View 3 Replies

ActionScript 3.0 :: Determine If There's A Dragged Object.

Jun 4, 2010

how to determine if there's a dragged object. Is there a way to do this?
 
I know if you start another drag on the other object it will stop the current dragged object. Maybe there's a public function that will query about this?

View 5 Replies

Flex :: Dragged TitleWindow Within App Boundary?

Mar 7, 2010

I am using PopupManager in FB4 to display a custom dialog.

popwin = new TitleWindow();
popwin.addElement(myCustomDialog);
PopUpManager.addPopUp(popwin,this,false);
PopUpManager.centerPopUp(popwin);

It's possible to drag the popped up TitleWindow and let go of it when its gray title bar lies outside the bounds of the Flex app rectangle,and then the popup cannot be grabbed again.It's also possible to drag the TitleWindow downwards so it becomes completely invisible below the bottom edge of the Flex app rectangle.When the Flex app bounds are less than the full browser window,and the user is working quickly, this chances of this happening increase.Is there a simple setting that will keep this from happening, or must the programmer intercept the behavior during the drag operation?

View 2 Replies

ActionScript 2.0 :: Make A Map That Can Be Dragged Within An Area?

Apr 19, 2010

how to make a draggable map but the map can only be dragged in an area. let say if i did a rectangle as the limit,so the map can only be dragged within the rectangle... outside of the rectangle cant be dragged and cant be seen...

View 9 Replies

ActionScript 2.0 :: Get Rid Of The Hand On Rollover And When Being Dragged?

Jun 22, 2011

I have attached a flash file with an audio slider component within it. how to get rid of the hand on rollover and when being dragged.

View 7 Replies

ActionScript 3.0 :: How To Generate Image That Will Be Dragged

Jan 29, 2012

So I am using actionscript 3.0, not FLEX so I had to make my own drag and drop code. The only thing I now need is a way to create a copy of the datagrid row that follows the mouse when dragging. How would I make a 'semi-transparent image' of the row to drag along with the mouse when I drag? It would seem like there would be some way to render a row as an image, but as of now its unknown to me. I would use a MOUSE_MOVE event in combination with knowing that the drag is initiated, but how to I generate the image itself that will be dragged?

View 0 Replies

ActionScript 3.0 :: Duplicating Movieclips When Dragged

Feb 20, 2012

I have 26 letters(english alphabet) into a linkage movieclip(var let:Letter = new Letter() ) and I put a drag and drop function into the mc. My goal is to drag the movieclip leaving the original on its position. The reason why I want to duplicate is that when I spell a word with single vowels on it ex. "word" with single "o" that would have no problem. But when I spell a word ex. "banana" with 3 "a"`s there is where my problem is.

View 1 Replies

ActionScript 2.0 :: Dragged An Mp3 Onto The Time Line ?

Jun 7, 2004

i dragged an mp3 onto the time line and i want to be able to make it stop with the click of a button,

Code:
on (release) {
Sound.stop(["stap-1.mp3"]);
}

View 3 Replies

ActionScript 2.0 :: Want The Tooltip To Be Dragged By The Mousepointer Movements?

Mar 11, 2009

i already made a working tooltip.now i want the tooltip to be dragged by the mousepointer movements....but the tooltip should always keep the same y-axis position....something like maybe:

Code:
startDrag("_root.tooltip", true);
y_mouse = 20;

View 1 Replies

ActionScript 2.0 :: Need Movieclip To Lock Into Place Once Dragged?

Aug 20, 2009

what I have are pieces of a truck and the user needs to be able to drag and drop the pieces to the correct locations. I can get the pieces to drag, but I need help locking them into place once they get within a certain area. So for example if they drag and drop the wheels of the truck towards the back, but not in the exact location, then the movieclip will move and lock into place and then the movieclip becomes disabled.

var dragMC = finalMC.graphicMC;
///////////////////////////////////////
onMouseMove = function () {
updateAfterEvent();

[code]....

View 1 Replies

ActionScript 3.0 :: Bitmap Screenshot Of Dragged Image?

Nov 17, 2010

I have an masked image that is externally loaded onto my stage that the user can drag and position.I then need to be able to record or save where and how the user has positioned the image by either -taking a bitmap copy of where the user has positioned the image (my first and easiest thought of how to do this) -or is it possible to get X and Y co ordinates of where they have positioned it I have a movie currently set up but when the user clicks 'save and continue' it takes a copy of the original position of the image - not from where you have last dragged it to?Full code and attached fla file below

Code:

stop();
//--------------
// Loader
//--------------
var imageP1:Loader = new Loader();

[code]....

View 1 Replies

ActionScript 3.0 :: Change Size Of Mc When Dragged Over An Object?

Jul 21, 2011

I'm doing a little drag and drop work and I'm wondering if it's possible to change the size of an object when it is dragged over another object on the stage..

For example I would like to drag a square movieclip around, but when it is dragged over a certain object it either play the movieclip and 'morph' into a rectangle or simply become rectangular (using a frame label or something) !

Is it possible to do this sort of thing with hitTestObject or hitTestPoint or dropTarget without contiuously checking if the objects are in contact ?

View 3 Replies

Flex :: Prevent A Component From Being Dragged Out Of The Stage I?

Oct 16, 2009

I think there is a simple solution to this question, just not simple enough for me to find it.Question:How do you constrain a TitleWindow in Flex 3 from being dragged off the screen/stage? Is there a way to restrict the TitleWindow to the viewing area? Example: Let's say I have an application that take 100% of the screen. Next, I create a TitleWindow via the PopUpManager. I can then proceed to click and hold (drag) that window off the screen, then release the mouse button. That window is now lost off-screen somewhere. Is there a way to keep the window from being dragged beyond the viewing area?

View 6 Replies

Flex :: Prevent Tree Items From Being Dragged Into Themselves?

Jan 14, 2010

I have a flex tree with dragMoveEnabled = true. I want to find out, when an item is dragged into itself or it's children. I'd like to use DragManager.showFeedback(DragManager.NONE) in the tree's onDragOver handler, but can't find out how get this to work. I'm using an ArrayCollection of nested objects as dataSource for the tree.

View 2 Replies

AS2 :: Flash - Name All Instances Of A Movieclip Dragged On To The Stage?

Jul 4, 2011

I have a number of instances of a MovieClip on stage. These are dragged onto the stage and arranged manually. Now, I would like to alter the instances during run time, using as2 code.

how can I name all the instances of the same MovieClip dragged onto the stage, using as2 code? (specify if the solution involves exporting the library MovieClip with an identifier name)

View 1 Replies

Flex :: List - Detecting Dragged Data

Aug 5, 2011

I have a list that accepts drops. When an item is dropped (DragEvent.DRAG_DROP) I need to collect the data that is dropped, however I have found nothing in the event thatdo so, event.dragInitiator.selectedItems would work but gives me an error.

View 1 Replies

ActionScript 3.0 :: Set Stage Boundaries To Dragged Items?

Sep 9, 2009

I have the AS to move pictures around (like a jigsaw puzzle i guess), im just struggling with setting boundaries so that the pieces cannot be dragged off the stage...

Im presuming setting the boundaries is a matter of adding X and Y values or similar.

View 1 Replies

ActionScript 2.0 :: Click Mc To Change Color But Not When Dragged?

Dec 27, 2009

I am trying to simulate onpress and onrelease functions but using onMouseDown and onMouseUp.squareContainer can be dragged around but squareBack, which is inside squareContainer changes colour when clicked. These both work.But.. when I drag squareContainer around, if the mouse is on squareBack (back) it changes colour as it sees it as onMouseDown. In the mouseUp, if squareContainer has changed position then it has been dragged. Then, using this I somehow want to say in mouseDown that if squareContainer is being dragged then dont change colour.. but it doesnt work!!![code]

View 1 Replies

ActionScript 3.0 :: Get Rid Of The Dragged Object That Isn't Dropped When The Time Is Over?

Jan 21, 2010

I'm using AS3. I have a timeline with 12 labeled frames (page 1...page12). On frames 1 to 10, I have 3 objects that users can drag and drop onto matching places. There is a timer (60 seconds) and a counter. Users should match 15 objects correctly. If so, they go to frame 12 (congratulations!). If not, they go to frame 11 (Sorry, try again), which returns them to frame 1 (page 1).

ISSUE When users drag an object (mouseDown) and don't release it when time is over, the dragged object remains on the screen. When users go to frame 11 and game starts over, the object remains throughout the entire game.

How can I get rid of the dragged object that isn't dropped when the time is over?

ActionScript Code:
//
// TIMER
var time1:int=60;
var myTimer1:Timer = new Timer(1000, time1);

[code]....

View 1 Replies

ActionScript 3.0 :: MovieClip Continues To Be Dragged And Not Dropped?

May 11, 2010

ActionScript Code:
public function Inventory(arrayOfItems:Array, stageRef, invSprite)
{

[code]......

View 1 Replies

ActionScript 3.0 :: Check When ObjA Is Dragged Onto The ObjB

Aug 20, 2010

I have 2 custom class objects (both MC). I want to check when objA is dragged onto the objB. Each class constructor defines it name value, so on creation in my document class, if I trace thier names they come out as objA and objB. In the code for objA, I manage the startDrag and stopDrag:

[Code]....

View 6 Replies







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