Finding An Objects _x And _y According To Its Position On Stage
Hey I was wondering if anyone knows how to find a target objects _x and _y value according to the stage... while that object is located within another movie...
i've tried something similar to this
Code:
with(_root){trace(this._x)}
but it doesn't seem to work...
SitePoint > Design Your Site > Flash and Actionscript
Posted on: May 23, 2007, 02:02
View Complete Forum Thread with Replies
Sponsored Links:
Finding An Objects Stage
hello,
i'm trying get the stages "Document Class" (_root) of an object in its controller class with the following code:
ActionScript Code:
var targetClass:Class = Object(this.stage).constructor;
but it gives me #1023
what can i do to this?
thanks for any help
View Replies !
View Related
Finding The Frame Position
i had made a dynimic text.
on entering into the movie i want the framenumbers to be displayed in the dynimic text area.
for example
if the frame is playing the frame 5 then in the text area it should be displayed as "5/120" (120-the total number of frames.)
on every frame move the frame number should displayed dynamicaly.
help me out in this
from
aristotle
View Replies !
View Related
Finding The Array Position Of A Value
I have defined an array as follows:
listRA[0] = "first";
listRA[1] = "second";
listRA[2] = "third";
daValue = "second";
Is there any way to determine which member of listRA == daValue? Or do I have to search it out with a For loop?
I haven't found anything else, and I know other languages have functions to discover the value.
Thanks,
Paul
View Replies !
View Related
Finding Cursor Scroll Position
whats the easiest way to find the current cursor position of a text box? i know there is TextField.bottomScroll etc..
i have a text box which autosize is set to true (so it expands as more text is typed). When the user uses the arrow key to go back up the text, i'd like to find the current line number it is on.
Any ideas,
Thank you,
DD
View Replies !
View Related
Finding The Position Of An Array Index
i was wondering if you have an array value, can you find what number it is in the array's order. For example,
letters=new Array("a","b","c","d");
cnumber=letters.position["c"]
trace(cnumber);
so that cnumber=2. How would I go about doing something like this?
-Brendan
View Replies !
View Related
Help Finding Line Position Of Character
I have a flash app that cycles through different paragraphs of a text field and selects them. To find the paragraphs I find the character position of the first and last characters within the field. What I'm wondering is if there is a way to find out what line number a particular character in a text field is on so that I can adjust the text field to automatically set a scroll position to a line with that first character. Currently as I select pargraphs in my text field, the selected text goes beyond the viewable area of the text field.
If you want an example take a page or so of text with paragraph pages and paste it into the big text frame on this page. Once you hit "commit" it will find the paragraphs and you can use Next and Prev to scroll through them. (its a very rough alpha version utility to generate XML)
Any help is appreciated!
View Replies !
View Related
Help Finding Line Position Of Character
I have a flash app that cycles through different paragraphs of a text field and selects them. To find the paragraphs I find the character position of the first and last characters within the field. What I'm wondering is if there is a way to find out what line number a particular character in a text field is on so that I can adjust the text field to automatically set a scroll position to a line with that first character. Currently as I select pargraphs in my text field, the selected text goes beyond the viewable area of the text field.
If you want an example take a page or so of text with paragraph pages and paste it into the big text frame on this page. Once you hit "commit" it will find the paragraphs and you can use Next and Prev to scroll through them. (its a very rough alpha version utility to generate XML)
Any help is appreciated!
View Replies !
View Related
Exact Position Finding Method
Hmm.. ok this is pretty basic but I have bean wondering for some time and was afraid to ask...
How could I find the exact position for a attachMovie that should align with the background?
and does these positions sometime change when published? I mean I have to consider somekinda html and/or java config when publishing......right?
View Replies !
View Related
Finding Position Of Text In A Textfield
If I want to position a movieclip symbol behind a word in a textfield, how do I do it? I mean if the text in the textfield changes fonts/or sizes and the text reflows, I need the movieclip to be positioned behind the word/words regardless of where the words fall.
Is this possible?
Any advice or help would be greatly appreciated.
Jase
View Replies !
View Related
Finding POSITION In Array - Not Just Boolean
I'm trying to find the possition of an elemtent within an array.
I'm currently work around this. It a button attatched in relation to the amount of items in an xml file:
this.onRelease = function() {
for (var k=0; k<array_length; k++){
checkARRAY = (_root.Nav_array[k])
//search through the array and get the possition of the currently clicked item
if(checkARRAY=this){
number_in_array.text = k
}else {
trace("not found")
}
}
}
What i'm trying to do is tell find the position of the currently selected item in the array so i can move the _y value of the items infront of it. Its a menu - all the other items would move down once i clicked the top item. I'm trying to make it all dynamic [from XML] so i can't refer to the items in the array without looping through it [i think].
If anyones got any ideas - it would be awesome!!
View Replies !
View Related
Finding Objects In _root
Is there a way to find via Actionscript a list of objects that reside in the root timeline?
I'm think there must be a way to find out say what movieclips or textfields exist in a movie or the root timeline.
View Replies !
View Related
Finding Sound Objects
Hi,
I was wondering if anyone had any idea how to find a reference to a sound object in AS3.0.
I am loading in a swf that has a sound object embedded in the timeline. I do not have the fla for that swf. So i cannot set linkage to the library asset.
I need to read properties in that sound object once i have found it
Please, any help or direction would be great. After hours on end of attempts, I am stuck
thank you for any help or insight
devcajun
View Replies !
View Related
Finding Sound Objects
Hi,
I was wondering if anyone had any idea how to find a reference to a sound object in AS3.0.
I am loading in a swf that has a sound object embedded in the timeline. I do not have the fla for that swf. So i cannot set linkage to the library asset.
I need to read properties in that sound object once i have found it
Please, any help or direction would be great. After hours on end of attempts, I am stuck
thank you for any help or insight
devcajun
View Replies !
View Related
Finding All Channel Objects?
I am working on an audio player that will take a parameter from a web page and play the appropriate MP3 file. Each page in a series of pages calles the same movie. It works but I have a seriouis problem with the code. If the user navigates to the next page while the current page is still playing the audio, the new audio is played on top of the older clip. I suspect that each time the same movie is called, a new SoundChannel object is being created.
I'd like to come up with a function to search all current objects that are not in the display list and issue a Stop command to all existing SoundChannel objects.
Does anyone know if it is possible to write a function to do this? Have you written such a function? I can't come up with any other way to stop the currenlty playing audio automatically. I can't rely on the user to stop it manually...
The SoundMixer.stopAll(); doesn't work, I've tried it. :-(
TIA
Peter H.
View Replies !
View Related
Finding Objects Within Area
Hey guys,
I need a method of finding all the objects over the top of another object...
I realise I could use hitTest to check if something is intersecting, but I can't use it to find the names of the said objects.
I also realise I could just cycle through all the objects on the stage and calculate it that way, but considering there's over 300 objects that could 'possibly' be covering this particular object, thats a lot to calculate, and i'd like it to be snappy...
Any ideas? Is there something already avaliable that i've been missing?
Cheers in advance for your help...
View Replies !
View Related
Finding Sound Objects
Hi,
I was wondering if anyone had any idea how to find a reference to a sound object in AS3.0.
I am loading in a swf that has a sound object embedded in the timeline. I do not have the fla for that swf. So i cannot set linkage to the library asset.
I need to read properties in that sound object once i have found it
Please, any help or direction would be great. After hours on end of attempts, I am stuck
thank you for any help or insight
devcajun
View Replies !
View Related
Finding Position Of Line Wrap In TextField
I'm using Flash MX 2004 Professional.
I have a multiline word-wrapped TextField of fixed font type and size (varying BOLD/ITALICS attributes) and all other formats set to default.
I need to find out the position in the text where the lines wrap, i.e. where a long sentence goes to the next line in the display. The _width and _height of this TextField is dynamic, so I require a fast and efficient method to doing this.
Currently, I precalculate the width of each character (bold and not bold) for the font and size I use. Then accumulate the width of the string til the width of the TextField is reached, then assume the line wraps at the start of the current word.
This method isn't very accurate somehow... my calculations tend to be different by one or two characters sometimes. I know its the rules of line wrapping that I'm guessing at, thats causing the discrepencies... wonder how we can very accurately determine how the lines wrap? (many special cases like "-", spaces, super long words etc...)
Anyone knows of better ways to do this? Very much appreciated.
View Replies !
View Related
Finding A Random Position Outside Of An Defined Area?
Hey guys, I could use a little help with some math.
Basically I am trying to find a random position to place a movieclip outside of my stage, but within a certain bounds.
I want it to be so the position is completely random and can have either a positive or negative value, and of course it must be a position with either the x or y out side of the stage, so that the movieclip is completely off stage, but inside the outter bounds.
I've tried to hack around, but could not think of a very clean solution that retained complete randomness within the defined area.
I also do not want to have to run a loop until I randomly come up with a set of points where atleast one of the dimension is outside the stage.
any help is much appreciated.
View Replies !
View Related
Finding Index Or Position Of Certain Attributes In Xml File?
Hi,
I've been getting to grips with xml and as3 but cant figure this out....
If I retrieve the value in a node from the number of the node, how do i then find the number of the node from the value. (confused?)
this is my code:
Code:
var hx:XML =
<hmv>
<level> <area> Music </area>
<subject> <area> Radio </area>
<content>Live Stream </content>
<content>Archive</content>
</subject>
<subject> <area> Library </area>
<content>Brian Ferry</content>
<content>Harvey GoldSmith</content>
<content>The Levellers</content>
<content>The Kooks</content>
<content>SugaBabes</content>
<content>Take That</content>
</subject>
</level>
</hmv>
trace(hx.level[0].child("area"));
var neededVal:String = hx.level[0].child("area");
///// this gives me the result "Music"
How do i then get the number 0 back from putting in the name Music?
should be relatively simple, i'm sure i just haven't been able to find this explained in any tutorials and its quite a difficult subject to search for.
any help greatly appreciated,
thanks
View Replies !
View Related
Finding Y Position Of Dynamic Text Field...
Hi all,
I need some help with my flash, i'm making a simple movie that display testimonial quotes randomly into a dynamic text field.
basically each quote is place into an array, the dynamic text field then reads a random quote each time it it loaded.
I have a separate MC, bottom_mc, that i need to be placed below the last line of text(loaded from array), if i could find out the Y position for the last line (make sense)
is it possible to find out the Y position of the text field (bottom corner), then i can simple put
onClipEnterFrame {
bottom_mc._y = position of last line/bottom corner
}
I've attached my flash file to take a look. is it possible to count the number of characters in a dynamic text field? then i could roughly work out how many line the quote would be on...??
cheers, any help or point in right direction is cool. sorry if it don't make much sense, but if you take a look at the zip it may help explain.
will
View Replies !
View Related
Finding Numerical Position Of Items In An Array
What i want to do is to populate a text field with the numerical position of an item in an array. Here's what I've got so far:
an array- call it bArray - which holds references to three button mc's:
ActionScript Code:
bArray=new Array[btn1, btn2, btn3]
Then I have a for loop which feeds a variable that numbers each button, and includes rollOver and rollOff functions:
ActionScript Code:
for(var i=0; i<bArray.length; i++){
pos=i+1;
//numberText is a text field in the btn movie clip.
bArray[i].numberText.text=pos;
[i]//bPos=bArray
bArray[i].onRollOver=rollOverButton;
bArray[i].onRollOut=rollOutButton;
}
Okay, not a problem. But now what I want is this- when you click a button, a text field in another movie clip displays the number of the button just clicked. And I can't figure out how to derive that value from the array.
Anyone have any helpful clues?
View Replies !
View Related
Finding An Objects Center Point
How do I find an objects centerpoint to make it's _xscale & _yscale change from the center instead of from the upper-left side?
So far I've gotten this far, I'm not a math whiz, that's for sure:
halfX = this._width / 2
halfY = this._height / 2
this._xscale = (this._width + _xmouse) - halfX;
this._yscale = (this._height + _ymouse) - halfY;
View Replies !
View Related
Finding The Stage's Width
I don't know what to do. I want to figure out the stages width. I know of two ways: Stage.width or _root._width. What exactly do these do? Why do they change? Shouldn't the movies width stay static? I'm confused...
View Replies !
View Related
Finding Out If Any Movieclip Are On The Stage?
Hello everyone,
I would appreciate it if someone can help me out with this. I would like to write a function that would return the names of the all the movieclips that are on the stage. I have written an function but it only return true or false whereas I would like the function to return the name(s).
Attach Code
function checkClip()
{
var j:Boolean;
j = typeof(movieclip) ? true : false;
trace(j);
}
checkClip();
View Replies !
View Related
Finding Centre Of Stage
My code:
_root.centerXPoint = Stage.width/2;
trace("center of stage x" + _root.centerXPoint);
My problem:
When I test my movie using ctrl + return, I first get the right value, but when I hit ctrl + enter again, I get a different one. Can someone tell me why?
View Replies !
View Related
Finding Centre Of Stage
My code:
_root.centerXPoint = Stage.width/2;
trace("center of stage x" + _root.centerXPoint);
My problem:
When I test my movie using ctrl + return, I first get the right value, but when I hit ctrl + enter again, I get a different one. Can someone tell me why?
View Replies !
View Related
Finding Stage Scale
or something close to it.
I was called in to work on a project for a company, as they project has got5ten beyond the skill level of their in house developers.
This thing is Huge, and in its final stages. They want users to be able to resize the flash player window (projector) using the windows (and mac) controls outside of the move (like the maximize button) They want the scale mode to be "showall" and they want everything to scale up and dwon *except for an videos that play.
So I need a way to detect the flash player window size or the % scale of the stage as it scales with the resize.
Help!!!
View Replies !
View Related
Problems Finding The Stage
Hello, I am just starting out in Flash so I am sure this is something simple but it is driving me crazy. I am trying my first FMA following the tutorial in the help of Flash 8 but using my own pictures and measurements, etc. Everything goes fine until I drag the slideshow (creating the third symbol) onto the stage after creating a new symbol. The stage disappears under the slideshow which makes sense, but selecting the border layer doesn’t show the stage. When I create a new symbol for the blue area, the stage (white part) is huge, even when the properties show the proper size. I have redone everything up to this point four times, thinking I screwed something up, but the same thing happens every time. Also, I have googled but cannot find tutorials for FMA’s, any links will be a help. Thanks in advance.
View Replies !
View Related
Create Array On Stage, Mathematically Referring To Objects On The Stage
Ok what I want to do is create a set of small images on the stage and name them sequentially like you would an array, then refer to them mathematically in actionscript. I tried naming them as an array but it says that the name is reserved for the system or something. Does anyone know how to get an array of objects onto the stage, or have an idea of something else I could do to get the same effect?
View Replies !
View Related
Create Array On Stage, Mathematically Referring To Objects On The Stage
Ok what I want to do is create a set of small images on the stage and name them sequentially like you would an array, then refer to them mathematically in actionscript. I tried naming them as an array but it says that the name is reserved for the system or something. Does anyone know how to get an array of objects onto the stage, or have an idea of something else I could do to get the same effect?
View Replies !
View Related
Finding Absolute Stage Dimensions
In a sample app, I'm using a [SWF] meta tag to hardcode the dimensions as 520x630. However, depending on the graphics I draw in my main sprite, main.height or main.stage.height (is there a difference?) can be 900+ pixels. How can a sprite have dimensions larger than the visible area of the SWF? Is there anyway to dynamically determine the size of the visible stage? I want to avoid hardcoding the WxH everywhere when I layout sprites.
View Replies !
View Related
Finding Stage Width From A Class
I know this should be straightforward, but for some reason it's not working ...
I want to create a 'Square' class that will automatically bounce off the "walls" (edge of the stage) so it needs to know the dimensions of the stage to do this. But using Stage.stageWidth or any of a dozen other things I've tried just doesn't work.
The error I get is:
TypeError: Error #1009: Cannot access a property or method of a null object reference.
at Square()
at SquareTest()
My code is below - if someone can help, that would be very much appreciated!
Attach Code
package {
import flash.display.MovieClip;
import flash.display.Graphics;
import flash.display.Shape;
import flash.display.Sprite;
public class Square extends Sprite {
private var side:uint;
private var colour:uint;
private var hspeed:Number;
private var vspeed:Number;
private var moving:Boolean;
private var bounceable:Boolean;
public function Square (sideLength:uint, col:uint=0x00000,
myX:Number=0.0, myY:Number=0.0):void {
if (sideLength < 1) {
trace("side length must be at least 1 pixel");
return;
} else {
side = sideLength;
}
if (col < 0) {
trace("not a valid colour!");
return;
} else {
colour = col;
}
this.x = myX;
this.y = myY;
// decisions about other properties' initial values
hspeed = 0.0;
vspeed = 0.0;
moving = false;
bounceable = false;
// actual code to draw the Square
var square:Shape = new Shape();
square.graphics.beginFill(colour);
square.graphics.lineStyle(0,colour); // no border
square.graphics.drawRect(0,0,side,side);
square.graphics.endFill();
addChild(square);
}
public function showWidthOfStage() {
trace("stagewidth is " + Stage.stageWidth);
// have tried MovieClip(parent).stage.stageWidth and other options as well
}
// other functions
}
}
View Replies !
View Related
Help Needed Finding Tutorial In Making Stationary Objects Look 3d
as said in the subject line, I'm looking for a tutorial in making a stationary object look relatively 3d
I'm not talking about moving the camera around the screen or any action scripting special effects
I'm talking about a tutorial that shows me some tips and tricks into creating an object that looks relatively 3d
for example, the 3 in the attached .fla file
I have tried looking on the internet and forums and stuff but either i'm blind or stupid cause all i could find was stuff to do with moving the camera around the screen or using actionscript to do special looking things.
ur help will be greatly appreciated
View Replies !
View Related
Help: Stage Objects Get In Front Of Script Objects?
This is getting me mad...
addChild(my_script_object);
I can't see it...
If I try trace(numChildren) I get 10, so then I try addChildAt(my_script_object,9) and still cant' see it.
If I delete all the objects in stage then I finally see it.... If I delete one by one I find my_script_objects gets beneath a bitmap placed by hand by the designer.
Any ideas?
TIA
View Replies !
View Related
Finding Stage Size Of Swf Loaded Into A Movie
Hi,
Does anyone know how I can find the original stage size of an SWF that has been loaded into a parent clip via MovieClipLoader? In the child clip, there are a number of elements that extend beyond its stage, so when I check the _width and _height properties, then they include the stage overlap.
I tried using mc.getBounds(), but it doesn't seem to give me what I'm after.
thanks
Marcus.
View Replies !
View Related
Finding Stage Size Of Swf Loaded Into A Movie
Hi,
Does anyone know how I can find the original stage size of an SWF that has been loaded into a parent clip via MovieClipLoader? In the child clip, there are a number of elements that extend beyond its stage, so when I check the _width and _height properties, then they include the stage overlap.
I tried using mc.getBounds(), but it doesn't seem to give me what I'm after.
thanks
Marcus.
View Replies !
View Related
Position Objects
Hi there,
Anybody can help with the following? I would like that an mc form my main movie keeps the same x position when the site is rescaled and is 30px from the bottom. My logo to keep the same x an y position. Same form my nav and textframes. For my backgroundpic I'd like it to keep alligned right and take the hight of the stage and rescale proportional to that. Anybody can help me out on that.
Big thx in advance
View Replies !
View Related
Finding The "coords" (x,y) Position Of An Item In A Multidimensional Array
Is there a relatively easy way of finding the x,y position of an item in a multidimensional grid array?
I have this grid structure for drawing a map for a game. Number 2 is going to be the starting point of the player. How would i find the x,y position of that number in the array?
It's currently at 2,2 within the array.. but i want it to be dynamic.
ActionScript Code:
map[0] = new Array(1,1,1,1,1,1,1,1,1,1) map[1] = new Array(1,0,0,0,0,1,0,0,0,1) map[2] = new Array(1,0,2,0,1,0,0,0,1,1) map[3] = new Array(1,0,0,1,1,1,0,1,1,1) map[4] = new Array(1,0,0,0,1,0,0,0,1,1) map[5] = new Array(1,0,0,0,0,0,0,0,0,1) map[6] = new Array(1,1,1,1,0,1,1,1,1,1) map[7] = new Array(1,0,0,0,0,0,0,0,0,1) map[8] = new Array(1,0,0,0,0,0,0,0,0,1) map[9] = new Array(1,1,1,1,1,1,1,1,0,1)
This is the code i have to draw the map.
ActionScript Code:
function drawIt(theMap) { var pos = 0; diameter = 72; xOffset = 20; yOffset = 15; for (var y = 0; y<diameter; y++) { for (var x = 0; x<diameter; x++) { pos = x+(y*diameter); if (theMap[y][x] == 0) { _root.attachMovie("myTile2", "tile_"+pos, pos, {_x:x*diameter+xOffset, _y:y*diameter+yOffset}); } else if (theMap[y][x] == 1) { _root.attachMovie("myTile", "tile_"+pos, pos, {_x:x*diameter+xOffset, _y:y*diameter+yOffset}); } else if (theMap[y][x] == 2) { _root.attachMovie("sprite", "sprite", 2, {_x:x*diameter+xOffset+35, _y:y*diameter+yOffset+35}); } } }}
View Replies !
View Related
How Do You Check Position Of Objects?
I'm working on a puzzle game using Flash 5. The puzzle is a 4 x 4 grid of square symbols. I need to know how to use actionscript to check when each symbol is in its correct x,y position, then have the movie advance to a new scene. Anyone know how to do this?
Thanks
View Replies !
View Related
[F8] Check To See If There Is Any Objects At Position (x,y)?
Ok, basically, what I have is...
A playing field, which is just a rectangle, and a small white cursor that is 40x20. You move the cursor around with the arrow keys (I managed that :P) and switch colored squares around that are within the cursor. (2 Squares in the cursor at once, and they swap places)
It's basically a flash version of tetris attack. Or ho yo ping or something in Japan... lol.
Anyway, is it possible to have like, a hittest, but for an unknown object?
Like, I want to switch the blocks, but you can never tell which blocks are going to be where and when, so I need to ask flash if there is anything at position... wherever... under the cursor I expect, without actually knowing if there is anything there, or what is there.
Just need to know how to do that. Thanks
View Replies !
View Related
Align 2 Objects One In Same Position
Hi all,
i am facing a problem while aligning the two objects on the stage.
while aligning two objects vertically & horizontally on the state, both objects will jump to different position....
i don't want this thing to happen. i wanted one object should be in same position and other object should move and align vertically & horizontally.
can some one help me...
thanks
View Replies !
View Related
Z-position Of Shape Objects
Hi there,
i'm working on a mp3 player that has an extended interface additionally to the regular play/pause/title etc interface elements.
The extended interface is below the regular one and should be hideable. The hide/show process should be animated.
My problem is that the regular interface buttons are statically created on the main stage, whereas the extended interface is drawn dynamically using the actionscript drawing api.
When i move the dynamically created shapes up, it completely covers the static objects of the regular interface.
I thought of using some background, on which the regular interface is drawn and where i can move the extended interface below to hide it.
I couldn't find any method or property to tell a sprite to draw itself below any other sprites.
Anyone has a hint how i could accomplish this ?
View Replies !
View Related
|