ActionScript 3.0 :: Referencing An Object's Stage Position?
Dec 11, 2010
i'd trying to build an interactive tree that allows the user to move the tree's branches and nodes. the lines (branches) of the tree are drawn programmatically between points (nodes and tips). i'd like for the user to click on points to drag them while having connected lines and points move correspondingly. i've gotten this to work to some extent using the code below:
ActionScript Code:
function startMoveOa(evt:MouseEvent):void {
thisPtOa = Sprite(evt.currentTarget);
[code].....
View 2 Replies
Similar Posts:
Sep 6, 2011
I have a media player that I am codging together, one that will play either videos or MP3s depending on the variables it is passed. The video player part works fine. The MP3 player controls are all actual physical MCs on the stage; each one has its own AS class file as part of the package, but there is also a lot of AS that is happening in the main FLA as well. Messy, I know, but it mostly works great.
The MC on the stage in the main FLA is properly linked to the class file via Actionscript linkage, and the control itself works. However, I am trying to make some aspects of the control respond to variables that are set within the AS on the timeline of the main FLA, and I cannot seem to pass values to the control no matter what I do.
[Code]....
View 2 Replies
Sep 6, 2011
I have a media player that I am codging together, one that will play either videos or MP3s depending on the variables it is passed. The video player part works fine. The MP3 player controls are all actual physical MCs on the stage; each one has its own AS class file as part of the package, but there is also a lot of AS that is happening in the main FLA as well. Messy, I know, but it mostly works great.The MC on the stage in the main FLA is properly linked to the class file via Actionscript linkage, and the control itself worksHowever, I am trying to make some aspects of the control respond to variables that are set within the AS on the timeline of the main FLA, and I cannot seem to pass values to the control no matter what I do.The following variable is set in the main AS:Code:var notPlayedYet:Boolean = true;I also have some flashVars being passed in from the html, and these I can reference with no trouble from the main AS - the relevant one is:
View 1 Replies
Apr 23, 2010
I have a stage bigger than the size of a browser, and I have a camera to navigate around the area.Now when I click on a button, I will have something pop up blocking the whole browser, like a lightbox effect with another box on top of the blocker.The problem now is, when the blocker pops up, its position is not on the TOP LEFT corner of the browser. I've tried stage.align, but it would makes the camera or other object on stage position run.So is there any other way I could get the blocker to position according to the browser, not the stage?[code]
View 1 Replies
Feb 4, 2012
I think my issue is to do with referencing the stage, but not to sure. When I try
[CODE]...
View 3 Replies
Aug 29, 2010
I have built a site in AS2 and would like to know the position of a ball so that I can move a sign to it always.The whole website is in AS2, but I think I have written an incomplete code below for AS3. I need it for AS2 because the whole site is in AS2. The get position of ball is wrong, but I just wanted to throw in some ideas eg.
Code:
// get position of ball
ball_mc.addEventListener(<what goes here?>, ball_pos);
function signMove(Event:MouseEvent):void{[code]..........
View 3 Replies
Jul 16, 2009
How can I get the absolute stage position of an object within a custom flex component that I exported from flash? In my Flex application I'm using the component and resizing it by setting its height and width properties. I want to place another component on the stage but I want it to appear at the same x and y coordinates of a text field in my custom component.
newComponent.x = customComponent.myTextField.x
newComponent.y = customComponent.myTextField.y
Because the customComponent is resized, the coordinates don't match up.
View 1 Replies
Nov 4, 2010
im trying to keep a object in a certain position in the screen, without resizing it too (with the stage)
function Resize(e:Event = null):void
{
if ((stage.stageWidth)/(stage.stageHeight) > fundos.width/fundos.height)
{
[Code]....
my stage is resizing all ok (keeping the aspect ratio) and im trying to add a nav img that would stay in the same position as i resize the browser screen
View 3 Replies
May 17, 2011
If I have a rectangle on the stage, how do I find its top left tip (x,y) and the bottom right tip (x,y) in relation to the stage?
View 2 Replies
Oct 25, 2006
I'm using the stage object to align multiple MC's. My question is how do I affect a MC's position if I want to have it be centered on both axis but 100px away from the bottom margin instead of the top relative to the size of the window?here's my positioning code:
[AS]
navBar._y = Stage.height;
navBar._x = Stage.width/2;
tpShadow._x = Stage.width/2;
[code].....
Also if i'm using an empty MC to load external swf's, do the external swf's have to have AS for positioning as well or do I position the empty MC in the base movie?
View 1 Replies
Feb 14, 2011
I'm trying to read an XML file with actionscript 2.0
The problem is I can only make my code to read a value of a tag by referencing their position.
e.g.
var currentIcon = myXML.firstChild.firstChild.childNodes[0].firstChild;
How do I retrieve a value from an XMl file by referencing their tag name?
e.g.
var currentIcon = myXML.firstChild.firstChild.childNodes['icon'].firstChild;
Here is my XML file...
<weather>
<current>
<icon>Partly cloudy</icon>
[Code]....
View 1 Replies
Feb 9, 2011
i want to take btn1 position half wwidth of own x position on stage
View 1 Replies
Jan 13, 2011
I have a sprite that I zoom out using the sprite.z property. Once the z property has been modified the sprite x and Y values do not match the stage x and y real value. So far so good and what I was expecting!
What I want to accomplish is that when the user clicks the stage the sprite tweens to where the mouse was clicked but I don't know what x and y position to send to the sprite. ( since stage 200,200 is something like 400,400 for the sprite depending on z value)
I tried Utils3D.projectVector using Matrix3D of the perspectiveProjection of the stage without success. (i.e. I get Vector3D(Infinity, Infinity, NaN))
I could fallback to scalex/scaley but sprites.z gives me the correct scale, perspective projection, paralax scrolling since I have sprites on different z level all for free. I would have to recode all that.
View 5 Replies
Nov 3, 2009
lets say i have a sprite on the stage and one movieclip inside it. now i want to tween or just set that movieclip x and/or y position according to stage position. so for example i want to set mc.y = - 100; (by which i mean -100 to stage, not sprite which mc is in.)
View 2 Replies
Feb 2, 2011
I'm trying to reference the stage from my view class(AsteroidSuppyView). The view is a child of the document class. I'm tryng diffferent ways to do this but i'm getting the error:Code:1152: A conflict exists with inherited definition flash.display:DisplayObject.stage in namespace public.my view class is:
Code:
package
{
[code].....
View 2 Replies
Jun 19, 2003
Say I have an object MyObject which hasan XMLSocket defined in it, how I can access the Parent object from the onConnect function:
function MyObject()
{
this.ConnectionState = false;
[code].....
View 6 Replies
Sep 27, 2011
I use this sample code taken from the docs: all the code is contained inside SocketExample.as, that is the DocumentClass too.
package {
import flash.display.Sprite;
public class SocketExample extends Sprite {
public function SocketExample() {
var socket:CustomSocket = new CustomSocket("127.0.0.1", 5000);
[Code]...
View 1 Replies
Sep 3, 2009
How to access stage elements from within a class.
buttonControls.as
Code:
package {
import flash.display.Sprite;
public class buttonControls extends Sprite {
// Navigation Hover Color
var hover = "0xF1E960";
var normal = "0xFFFFFF";
public function changeColor(object, color){
[Code] .....
View 2 Replies
May 9, 2010
I am trying to reference a movieclip from the stage which is nested. I really have no idea how to do that.
View 5 Replies
Sep 2, 2010
In a new document when I create a movie clip on the stage and reference it in a script in the first keyframe, like aaa.scaleX = 0.2;, everything works fine.
But when I try this in the game I'm making, I get this error "1120: Access of undefined property aaa.". Why?
In my game I use a document class, here is the code that is executed at the beggining.
[Code]....
View 7 Replies
Jan 7, 2009
I created a custom class in a .as file. I then linked this custom class with a symbol from the library in my .fla file. However, I can't reference stage.stageWidth in my custom class file. I get a null object error.
I think this happens because the custom class file is associated with a symbol on the stage and not the stage itself. For example, if I set the fla file's Document Class to the name of my custom class I can reference stage.stageWidth in the custom class. But I don't do this because I am creating multiple instances of the symbol on the stage. In order to do that properly i found I have to set the class in the properties panel of the symbol to the underlying class which then defines how each symbol behaves.
Under this type of linkage, is there a way to reference the stage width from the class? I've tried root.stage.stageWidth and parent.stage.stageWidth to no avail. I also made sure to import flash.display.* in my custom class. Below is the code for my .fla file and my .as file. In the .as file you'll see the line "x = Math.random() * stage.stageWidth;". This is the line giving me problems. I could hard code it, as I do for the y variable on the next line, but I'd prefer not to in order to keep the code flexible.
[Code]....
View 3 Replies
Feb 14, 2009
I'm having problems referencing the stage from an external class. I've tried :
Code:
stage.addEventListener(MouseEvent.MOUSE_UP, onUp, false,0,true);
And also
Code:
MovieClip(parent).addEventListener(MouseEvent.MOUSE_DOWN, onDown, false,0,true);
But no luck. Can I not do this? I'm making a pencil class that I want to be able to reuse. I also tried "this" and while it didn't throw and error, it didn't work either.
View 9 Replies
Jun 18, 2009
I have a movieclip "submenu" that is on the main timeline, and inside this movieclip, I have some ActionScript:
[Code]....
View 3 Replies
Dec 9, 2009
I'd like to know how I can reference root stage values from within a movieclip, or even worse, from a class. For example, I have a class called Bground.as. It does stuff, according to current stage size - so if someone were to resize the window/browser, Background updates in real time and does something fancy while it's at it. To do this "fancyness", I need stageheight and stagewidth. However, simply pointing to them does not work.
Here's the simplified ActionScript Code:
package klaseFP{
// imports
import flash.events.*;
import flash.display.*;
public class Bground extends MovieClip{
[Code] .....
TypeError: Error #1009: Cannot access a property or method of a null object reference.
at klaseFP::Bground()
at FullScreen_03_fla::MainTimeline/frame1()
Background works as a document class, works perfectly in fact. However, if I use it as the class of a library object, error 1009 shows up. Same thing happens if I simply put the code into the timeline of the library object - stage referencing simply causes it to break. So, how do I dynamically change the values of variables in Background, according to values in the main movie/app?
View 2 Replies
Dec 15, 2009
I feel like I should know this by now, but I'm having trouble. I want a function in one of my child functions to increment an integer in its parent function.
[Code]....
View 9 Replies
Jan 20, 2011
Just wondering, is there any way to dynamically reference movieclips on the stage, as in through a for loop like so:
for (var i = 0; i < 10; i++) {
["mc" + i].x = 10;
}
[code]........
View 3 Replies
Jul 28, 2009
in my main FLA's document class, I have this line:
Code:
addChildAt(newSlide, this.stage.getChildIndex(timelineNav.displayObject));
I'm trying to figure out why addChild() implicitly references this.stage, but
[code].....
View 14 Replies
Oct 27, 2010
I have been trying to reference to the stage from outside Document class and tried many different ways I found on google and it seems none of them works (maybe there were some changes in flash since they were posted.For example TopLevel approach by Senocular doesn't work either I do it as described in here.URL...The only way it seemed to work is by passing a stage as a variable. Has anyone any idea of a way to do it without the need of passing it by.
View 7 Replies
Nov 12, 2010
How do you reference and already existing object in as3? My below program draws 2 circles and a line to connect the two. The circles and the line are all individual objects. The line (connector class) has a function called update that should redraw the line between the two circles. It has two variables which I want to be the references to the two circles. The circles (coolcircle class) has a variable which I want to be the reference to the connector. It doesn't seem like my update() function is getting called.
ActionScript Code:
package
{
[code]......
View 3 Replies
Feb 27, 2006
i saw a thread while ago .. that always position a movieclip in the middle of the stage even if the stage or window resize any1 can point me to it
View 3 Replies