ActionScript 3.0 :: Detect Width At Specific Y Value?
Apr 28, 2009
I have a MovieClip that has a bunch of MovieClips inside it. I am trying to figure out how wide the MC is at a specific y value. Not sure if there is an easy way to do this.
For an example.
Code:
OOOOOOOO
O O
O O
[code]....
This is the shape of the MC. It is not solid all the way through, it has MCs strewn about inside this outline. I am trying to figure out how wide it is from, say the second 'O' from the bottom. Left to right. The actual MC.width would be 12 'O's wide. But at that bottom portion, it would be 10 'O's wide. I'm not sure how I can do this.
The problem that I'm facing is in regards to the width of a sliding menu that I've created. The menu slides based on mouse x position and width of the movie. I would like the menu to fit to the entire screen regardless of the users resolution. I wanted to know if there's a way to detect a users screen width and then adjust the variable for screen width within my actionscript.
I'm setting up a menu system powered by an XML feed that will have everything created dynamically (graphics, textFields, etc), and I've started pondering something...Since the menu will essentially be in list form, with each button stacked on top of the other, and since the titles will be passed as strings out of attribs in the XML, I was wondering if there was a way (there has to be) to essentially define a width of the text box, but leave the height open, allowing for multiline = true;, and then to dynamically draw the button graphic based off of either the height of the textField or the number of lines the textField uses.
Will this just be a matter of ordering, in that I won't actually draw the box until the textField has been set up, and the title passed to it? That way, the get height method would return the height of the box with the text in it, and I can adjust accordingly? Or should I try to base it off of the number of characters that will be passed to the box, and just set a limit via modulo or something else to "catch" when it goes to the next line (The problem I see with this is that not all characters are == when it comes to width. "i" < "e" in terms of character width, but they are both just single characters).
I would prefer to set something up that auto adjusts, as this list will be changed in the future, and I have no way of knowing if the titles will be a uniform/won't exceed a certain length. I could try to just "go big" to make room, but then you end up with boxes that look empty, and if I undershoot, I've got to go back to code.
ive used this code to detect a hit between a specific object and a certain MC
Code: if(this.hitTest(_root.ufo)){
now i want to know if its possible to detect collisions with everything except (ignore) certain MCs because i only have 3 MCS i dont want it to care about , but there will be about 200 or more i want it to care for.
I am loading an external swf file using the following code: //add close button var reqButton:URLRequest = new URLRequest(btn_close); var loader2:Loader = new Loader(); loader2.load(reqButton); addChild(loader2); [Code] .....
Once the loader loads my image, and I click on it, nothing is happening. Am I supposed to be adding the EventListener to the loader or something else? How can I detect the height and width of the swf file in the loader?
I have objects placed on the screen using x/y coordinates. I want a way to update that based on changes in Screen Width/Height. So if used re-sized browser window x/y should change. How do I cick off a function every time the screen is re-sized.
i already finish my memory game. now i am working on this fish...i have a fish movieclip. i use actionscript to make it move.here is the code Movement Actionscript Tutorial
[code]...
this fish is inside the aquarium, so how can i make the fish detect the width of the aquarium so it won't go outside of the aquarium.
I am loading jpgs into an MC. I make sure I wait to run and modification to the MC by confirming the image is loaded first.If I comment out the IF statements within the function "RW_pic_modifications()" and I trace the width and height of the MC AFTER each photo is loaded, I successfully trace the correct W and H.
My issue, however is when I DO RUN IT THROUGH the conditions within the "RW_pic_modifications()" function. Then any modifications to the MC W and H seem to compound and apply it to each iteration of the next MCs.I confirmed that my code and logic is correct. I just dont understand why performing a resize to the MC with one jpg loaded into it is not reset to the NEW JPG loaded into it, after the new JPG is loaded.
NOTE - I have an MC that stops on a frame until all the code here is executed. Once complete, then this MC plays to allow the pic to stay on screen for a given amount of time THEN it calls on the RW_Pauser() function.I am way over deadline.
In my Timeline I have 4 layers, each with labels on different keyframes. I have the following code, which obeys to my first layer:[code]How can I make AS3 to detect the specific "currentFrameLabel" of a named layer?
Is it possible to detect (dynamically) the white pixels of an image and delete them? Actually i have some images that i load on stage but they are square without the actual image be a square sized. So i want to make the hit area exactly the shape of the image and not the whit border they have.
i'm using loadmovie() to load a youtube video player inside my flash website but i want to specify the width and height so it can fit my box.This is my code:
On my website, I display uploaded PDF files in a flash player for my users to read. I already use various tools to extract the text and produce a serious of high quality images from the file and the system works well. The last piece of the puzzle is to be able to highlight specific parts of the document to help users with accessibility issues.
However I cannot figure out how to calculate where the specific text is positioned on the page? Notes: The documents uploaded to the system are from 3rd parties, so fonts may be embedded. Meaning that I cannot be sure of the width of specific letters. The text to be highlighted may not be unique, the same text may be repeated How can I calculate the coordinates, height and width of a specific piece of text on a PDF, so that I can then draw a box around it?
It's probably a no brainer, but I've spent the last 40 minutes or so looking for it to no avial.
I have a Canvas control with a fixed width and a horizontal scrollbar.I'm trying to find the actual width of the control.The .width (fixed width) + the part being revealed by the scrollbar.I tried explicitWidth, width + maxHorizontalScrollPosition, and some other combos but non of them hit the spot.
I am looking at the SimpleButton entirely wrong. Here's what I'm doing (inside of a MovieClip):
[Code]...
the close_btn.width and height remain 0. Am I supposed to just rely on the DisplayObject members of the SimpleButton completely and ignore width/height/x/y or what?
is there a way to make a minimum width and stop resize? I have a menu I am building that is locked to the bottom of the browser and 3 buttons on the left and a movieClip on the right. When you resize the browser window - currently - you can make the button on the right sink under the three on the left.
how to get a movieclip named "topnav" to resize it's width to match that of the stage. I am trying to resize the width of a top nav bar across a resizable RIA. I have started with the following code but with only partial success:
Code: stage.addEventListener(Event.RESIZE, resizeListener); function resizeListener (e:Event):void { var reg2 = stage.stageWidth / 100;
I am creating a nav in flex that pulls in buttons dynamically from xml. THe problem i am having is setting the button width to the text width. currently the buttons are all the same width and if the text is larger then it just cuts off. I've tried a few ways of doing this:Setting button width to 100%On creation of the button try to set the width of the button to the text programmatically. Something like evt.target.width = evt.target.textWidth;
trace ("The Width is: " + stage.width + "."); trace ("The Height is: " + stage.height + "."); The Width is: 0. The Height is: 0. Why is it Zero instead of the document's size ?
What I want is a hint how to make a specific thing happen while clicking a specific button. Like "if I click button 1, do this". Would like to use this script though I'm gonna add buttons over time and this is an easy way to have the functionality working.
Here's the code:
Attach Code
function hitButton(btn) { btn.onRollOver = function() { this.colorTo (0xC4006A);
i need to change the colour of a graphic in a specific movie in a specific frame. if i have a movie clip instance-named "sidetext" thats 15 frames long, and i want a graphic in the movie, called "letterp" to change to one of four colours that i want it to randomly at frame 10 and stay that colour uintil frame 15, how can i do this?
how do i export specific frames not all frame. ex: if flash has 1 to 200 frames. here i want to export 51 to 150 frames as a movie. if there is any command or plugin to export movie like this.