Detecting And Adjusting Textbox Height Dynamically
Is there a way to detect how many text lines are in a dynamic text box and then, once that value has been detected, is there a way to adjust the text box's height or at least determine the location (in pixels) of the bottom of the text? When dynamically changing text in the box, I need to be able to move the clips below the text so that there's no extra space between the bottom of the text and the clip below it.
I am familiar with the "scroll" and "maxscroll" properties, but am having trouble finding any way to detect the number of lines in a dynamic text box and adjust its height accordingly.
FlashKit > Flash Help > Flash ActionScript
Posted on: 12-28-2001, 03:26 PM
View Complete Forum Thread with Replies
See Related Forum Messages: Follow the Links Below to View Complete Thread
Adjusting The Height And Width Of A Mc
Ok I have a clip on the stage that when a button is pressed it's height and width are changed and it eases to the new settings. The only thing is I want my nav to move with it, like at EVB. Also when I add a stroke to my square when it enlarges the stroke gets huge. I figured that maybe the way around this is to use the drawing api actions but I'm not sure how to accomplish this effect using them. Any help would be great. I've attached my .fla so that you can see what I have so far.
Adjusting Leading/Spacing/Line Height In Components
Anyone know how to adjust the leading or spacing between lines in a combobox? I can't seem to find it in setStyle.
Example:
_global.style.setStyle("fontSize", 9);
I need something like this:
_global.style.setStyle("rowSpacing", 1);
Adjusting Position Of Dynamically Placed MC's
i'm using a component that dynamically builds a menu. but i can't control the placement of the MC's so that the text is not anti-aliased. does anyone else have any ideas about this?
check out the site http://www.primaryflow.com , the right menu uses the component. you can see it's blurred at different levels. and the one on the left (which i just created and placed manually, seeing how there were no sub-categories) is fine.
i don't know how to control the position of dynamically placed MC's.
alternatively, does anyone have a link to an .fla, tutorial, or script that accomplishes the kind of dynamic motion the menu on the right has.
any insite is much apprecitated
thanx
- evol
Detecting Browser Height ? AS2 / CS3
Hello All... here's my problem...
I've created a .swf that scrolls photos across the screen and I want the user to be able to click a button to view a single photo at full size.
All very simple... but in this case, the full size of the photo is dependent on the users available browser height...
So what I really need is help detecting the users available browser height. My research tells me this can be done with a combination of JavaScript and the Flash External API but I can't quite workout how this should be implemented.
Can anyone help ?? There's an apple and a biscuit in it for you ??
Cheers
Jimmy
Detecting The Height And Width Of An SWF?
Hi,
I've got a problem. I need to be able to detect the height and width of an SWF on a page in order to set its height and width attributes.
As you may know, if you do not set a height or width, the Flash just wont appear - but the SWF files I have come from a database, so I need to set these dynamically within my loop.
Is there any way to do this? I'm already using SWFobject so if there is a JavaScript solution then this would be fine.
I can't simply set a fixed height and width as this will throw each movie out of proportion.
Any help on this would be great!
Thanks in advance!
Mikey.
Detecting Lines Of A Textbox
OK, i have dynamic news files loaded from a text file, but dpending on the length of the message the one below will need to set it's distance. http://phildman14.homeip.net/newtral/site.html is there any way to get the exact # of lines it would take up, using word wrap and all that to either shrink the size of the box, or get a 1 or 2 or 5 line result? thanks
Detecting Click On Textbox?
Is there a way to detect if a user has clicked on a textbox or if a certain textbox is active? IM NOT USING MX 2004 COMPONENTS. Im using just MX components.
Would I need to set up a listener for this?
Thanks,
Limitlis
Dynamic Height Of Textbox
I've got a dynamic textbox, but I need the size (height) to change depending on the amount of text pulled inside of it (So I can scroll it correctly).
Any of you geniuses have ideas?
Thanks in advance!!!
Scripting The Height Of A Textbox In 5?
I am using Flash 5 to do this I have a sinking feeling this maybe a MX job.
I want to load a text file in...got that working easily enough.
The amount of text though is going to grow as it is a news text box. I have a scrollbar that detects how big the text field is and adjusts itself accordingly. However how can I get the size of the text field to adjust itself (in height only) to the amount of content it loads in?
Thanks in advance!
ss
Textbox Height Attribute
Dear all,
I have a textbox that is autosizing with the amount of text that is entered in it, ie its heigth attribute is never the same, depending always on the amount of text there is. Here is my code to give you a better understanding:-
textPlacer.autosize = "center";
and the text is entered dynamically from another movie. What i need to know is how I can retreive this heigth attribute so that I can create another movie clip that is resizing exactly the same as the textbox is.
I tried this piece of code:-
textPlacer._height = j;
trace(j);
but it returned un undefined value.
Any ideas?
Thanks for your help and time.
Johann
Getting Height Of Autosized Textbox
Hey guys,
I am using textbox.autosize = 'left' to autosize a textbox. Now I want to duplicate a MC a specified number of times. When duplicating, I give each MC a variable of num, which is equal to X in my for loop(This is for referencing the right ones)
box = reply(num-1).replies1.maxscroll*19;
this._Y = box + (num-1)*50;
Now I use this to get the height of the textbox in the duplicated mc before the one I am currently on. *19 is used for the height of the textbox.
I thought this would move my mc 50 pixels down from the textbox above it, but it is not working. I think it may be because of the autosizing.
Any ideas why this won't work?
Thanks,
Chase
How To Fix Dynamic Textbox Height ?
im loading an external txt file to a dynamic textbox. im using a scrollpane to scroll the dynamic textbox. Now my problem is, i need to change the height of the dynamic textbox each time i increase or decrease the content from the txt file.. is there a way that the dynamic texbox adjusts itself according to the content ??!!
Please HELP !!
Detecting The Height Of The Button Text
Hi All,
I'm using Flash MX 2004 and i want to make a menu with actionscript. I found a tutorial to duplicate a MC using AS, but i have some buttons that has 2 or 3 lines of text.
Can anybody help to find a code to set the height of the MC after a larger then 1 line text has been detected?
Any help will be much appreciated!
Thanx in advance,
AC
Detecting Textbox Contents Change
Im having difficulty detecting when the text in an Input textbox (drawn on stage by the Text tool) is changed in any way by the user.
What I would like is to detect what text, in its entirety, a user has entered into a textbox.
Using :
myTextBox.addEventListener(TextEvent.TEXT_INPUT, handleChange);
I can detect character additions. I can get the character added from the event data and with that and myTextBox.text I can piece together what text is in the textbox. Its cumbersome but works to a degree.
However if the user deletes any characters, the event is not triggered. In fact the user could delete the entire text string and I wouldn't know about it.
Is there a way of doing this ?
Resize Dynamic Textbox Height
Hi people,
I'm dealing with a problem here,
I need to show an external text generated by a server-side script
inside Flash.
The problem is that the text lenght is not fixed so the dynamic text box needs to resize to the apropriate height to fit all the text. Well, it seems that Flash doesn't do that automatically.
Is there any actionscript code to do that ?
Ps: I don't want to use any component , I just need a dynamic text box showing any text lenght.
Thanks.
Detecting The Height+scrollability Off A Dynamic Text Box
I have 2 questions related to dynamic text zones.
1) is it possible to expand a dynamic text box's size if all the text doesn'ty fit in it?
2) Is there actually a way to detect if all the text doesn't fit in the box??
PS (I have multiline turned on)
Thanks for anyone that can help
Auto Stretch Dynamic TextBox Height
Hi,
How can I make a dynamic test box stretch in height to the ammount of copy that gets sucked in from the database?
Currently it just cuts of at the bottom of the box that I've manually pulled down.
This is probably something stupid, but I just can't find a sollution yet.
Thanks in advance
Automatic Scrolling If Textbox Past Height
Hello,
I am looking for a way to have my content scroll vertically automatically if it is past a certain height. Can someone please point me in the right direction?
Thanks,
Saveth
Code:
var my_format1:TextFormat = new TextFormat();
my_format1.font = "EventFont";
my_format1.size = 50;
my_format1.color = 0xFFFFFF;
var my_text2:TextField = this.createTextField("my_text2", this.getNextHighestDepth(), 50, 200, 900, 30);
my_text2.variable = "sLine_02";
my_text2.antiAliasType = "normal";
my_text2.wordWrap = true;
my_text2.autoSize = true;
my_text2.embedFonts = true;
my_text2.setTextFormat(my_format1);
my_text2._x = (Stage.width/2)-(my_text2._width/2);
my_text2._y = (my_text3._y + my_text3._height)+20;
Tooltips - Detecting Width+height: Text Area
Hi Flashkit members,
I was wondering if it is possible to detect of a piece of text, the length and height in pixels it needs. And I'd like to set a maximum pixels (width), so the text will also be wrapped to fit in.
I need this because I want to make a nice design around the tooltip.
I hope you understand me and have an nice answer for me =)
thx!
Techroll
Determining Text Height Of Dynamic Textbox After Font Size Has Changed?
Hi all
I have a dynamic textbox where the font size for that box is set for 12pt
I can calculate the height of that textbox by doing the following:
myText.textHeight;
Now, on pressing a button i've created, I can change the size of the font within that textbox.
however the textHeight value for the dynamic textbox doesn't change.
Any ideas how I can get the textHeight to change when I change the size of the font within the dynamic textbox?
Cheers
Detecting Flash Movie Original Width, Height, Frame Rate, Etc. (programmatically)
Let's they you need to embed a Flash movie into your web-page, but you don't know it's width & height, then it may become kinda problematic..
To solve this problem I've made a small utility class which parses SWF-file and extracts basic movie clip parameters like width, height, fps, frames etc.
You may download it here: http://navin.biz/files/SWFParser.zip
It's a free tool written in C# (.NET Framework 2.0) and contains the source code as well.
P.S.: There is no way correctly detecting Flash movie's width & height with JavaScript, you may only do this by parsing SWF file on a server side (with PHP or Ruby or C# etc.).
Change Height Of Swf Dynamically ?
I have a problem with my main .swf file resizing the width AND height when I call the js named "flash_resize.js" when I really am only interested in changing the height attribute. Hmmmmmmm . . .
Here is my code in my HTML page for reference:
<div align="left">
<div id="flashid" style="width:800px; height:400px;">
<script type="text/javascript" language="JavaScript">
e = canResizeFlash();
document.write('<object data="#flash_choice#.swf" width="800" height="100%" type="application/x-shockwave-flash">');
document.write('<param name="movie" value="#flash_choice#.swf" />');
document.write('<param name="FlashVars" value="allowResize='+e+'" />');
document.write('Flash Movie With Resizing Content');
document.write('</object>');
</script>
<noscript>Javascript must be enabled to view Flash movie</noscript>
</div>
</div>
Here is my code in my Flash project on a button instance calling this javascript function:
on(press){
gotoAndPlay("body_ir",1);
getURL("javascript:setFlashSize('flashid', 800, 200)");
}
Here is the javascript code for "setFlashSize":
function setFlashSize(divid, newW, newH){
setFlashWidth(divid, newW);
setFlashHeight(divid, newH);
}
The problem is that when this button is pressed, by entire flash project is scaled by half (in this instance I want to reduce the height from 400px to 200px). This project has a main container movie clip holding all other movie clips. When I change the height on the main container clip, (i don't know why . . . but) the width is also change accordingly and therefore all internal sub_files are changed too for width and height. I only want to have the height changed. On the main container movie clip, in certain instances there is content filling the entire height, but there are other situations where the visible height of the clip is only about 200px high, therefore leaving a 200px white blank space underneath the visible clip and the HTML content immediately preceding the SWF file. What I am wanting to achieve is to have this HTML content below the SWF to butt up against the bottom of the SWF file when it is either at normal size or reduced in height by pressing a button. How can I achieve this? All help is appreciated. Thank you.
Dynamically Grow In Height
What I would liek to do is on clicking a + button, the box as in a box on a graph, grows by x (one click), but rather than it jumping from say 0 pixels to 10 pixels, I was wondering if there was a way that it could slide from 0 to 10 smoothly?
Cheers
lee
Dynamically Importing Jpg Via Textbox
OK I've got this text box that dynamically imports data from an external txt file. My question is, is there anyway to attach a jpg to the txt so that it imports with the data? (data scrolls if content exceeds text box length)
Using Flash MX 2004.
Thanks
Height For Graph Controlled Dynamically
Hey everyone,
I am trying to create a thermometer bar graph that consists of one bar. This bar represents the amount of money needed for a certain event (goal). I have an animation that goes from 0 - 100 and is 100 frames long. How would I code this so that the variable I load (current_amount) is represented in the bar graph.
For example if my 'current_amount' variable is equal to 54, I would want my movie clip to play frames 1 to 54 and then stop.
Any help would be huge. Peace.
The Height Of A Dynamically Created Textfield
Hi, hello and everything else...
If I'd have a variable with some html-text and I'd want to put it into a textfield created by actionscript, how can I find out what the height of the textfield should be?
I was thinking of roughly counting the text with a for-loop, like increasing some variable a lot when a "<br>" is detected and ignoring other brackets and stuff, but I figured there might be an easier way to achieve this...right??
Thanks for all your time - Ruben
LoadMovie And Dynamically Set It's Width And Height
Hi,
I want to loadMovie function to load an external SWF file into stage and set it's width and height on the fly.
Everything works, but I can't set it's height/width automatically. I can set _xscale, _yscale, _x, _y.. but not _Height and _Width.
How come?
I have attached my code to this post.
Even when I trace "_root[whichTarget]._Width" and "_root[whichTarget]._Height" it outputs 0 to me.
Please help me!
Attach Code
function startLoading(whichImage, left, top, w, h, angle, color) {
myCount++;
whichTarget = "mcNew"+myCount;
duplicateMovieClip("movieLoader", whichTarget, myCount);
loadMovie(whichImage, _root[whichTarget]);
_root[whichTarget]._rotation = angle;
_root[whichTarget]._x = left;
_root[whichTarget]._y = top;
_root[whichTarget]._xscale = w;
_root[whichTarget]._yscale = h;
myColor = new Color(_root[whichTarget]);
if (color == "green") {
myColor.setTint(0,255,0,100);
}
if (color == "red") {
myColor.setTint(255,0,0,100);
}
if (color == "blue") {
myColor.setTint(0,0,255,100);
}
}
FMX- Changing Stage Height Dynamically
Hello!
I'd like to know if anyone knows how to change the height of the stage dynamically, with ActionScript.
Is there a way to change the height of the stage with a pixel value?
I don't want to scale down the whole movie just make the stage bigger, just like when you change it manually in Modify-Document.
Thanks!
Changing Stage Height Dynamically
Hi,
I couldn't find anything in the documentation, but is it possible to dynamically change the height of the stage?
I am using 'dimensions: pixels', and 'noscale' as publish settings. What I would like to do is, when the height of a movieclip gets bigger (because of its dynamically loaded content), to make the 'stage.height' bigger too, so you can scroll more downwards.
I know stage.height is read-only, but it would be nice to have just the right amount of space at the bottom of the page, depending on how high the movieclips are. Reading back, I wonder if i state my question clear, hopefully I use the right terminology.
so if stage.height would work i would like to do something like:
ActionScript Code:
stage.height= MC._y+ MC._height +30;
thank you,
Jerryj.
Dynamically Changing Height And Width
I want to change the height and width of an object (specifically doubling it) after an interval of 2 seconds until the height and width of the object reach over 100. I've made two different scripts to try to make this possible.
Script 1
Code:
function hw2(){
this.test._height *= 2;
this.test._width *= 2;
}
this.test._height = 1;
this.test._width = 1;
while ( this.test._height <= 100 && this.test._width <= 100 ){
setInterval(hw2(), 2000);
}
Script 2
Code:
function hw2(){
if(this.test._height > 100 && this.test._width > 100){
clearInterval(myInterval);
}
else{
this.test._height *= 2;
this.test._width *= 2;
}
}
this.test._height = 1;
this.test._width = 1;
myInterval = setInterval(myObj, "hw", 2000);
The problem with the first script is that the movie will wait and then display only the final height and width. The problem with the second script is that it doesn't show any height or width from the function, it only resizes for the this.test._height = 1; and this.test._width = 1; . Thanks in advance.
EDIT:
I just read the "Read this First" sticky and now I'm going to post that I'm using Flash MX Professional 2004.
Determining The Height A Text Box Will Need To Be Dynamically
I want to populate a dynamic text box and then scroll this.
Is there anyway of determining how large the text area's height needs to be given the width and the text I want to populate it with?
Hope that makes sense. If not please shout!
Many Thanks,
Daf
Adjust Stage Height Dynamically
Hey, I'm working on this charting thing and it duplicates MCs vertically and I need to be able to adjust my stage to accomadate more or less MC's. Can somebody help me out a bit?
FMX- Changing Stage Height Dynamically
Hello!
I'd like to know if anyone knows how to change the height of the stage dynamically, with ActionScript.
Is there a way to change the height of the stage with a pixel value?
I don't want to scale down the whole movie just make the stage bigger, just like when you change it manually in Modify-Document.
Thanks!
Dynamically Change The Height Of An Element
Hi there,
I have an animated graph in flash and I would like to set the values (heights of the bars) using data imported via an XML file.
I can successfully import the data, but I have no idea how I change the height of the bars!
Can anyone point me in the right direction?
Thanks in advance!
Andy
Textbox... How To Change It's Size... Dynamically
HEEEEEEEELLLLLLLPPPP
I have a xml sending the variables to flash successfully.
I did a FOR cycle to store the values in the variables.
I can show the variables in text boxes.
My problem is:
-- How can I change the size of the textbox so when a value is too big, it can show the value completely.
Can anybody HEEELLLPP???
Thanx
Dynamically Resizing A Dynamic Textbox..
Hi. Just making a news page for my site, the contents of the news is loaded from a database. thats all easy. problem is, i want the dynamic text box (that displays the news) to change size to fit the news. i.e. at the moment, if there is a very long news item, then it just makes the text too big for the box and you have to scroll down to se it. i know this kinda sounds like a strange request but it makes sense if you could see what im doing.... i need it so that the textbox resizes itself to grow big enough to fit in all the text. any ideas?
thanks in advance
Rich
Please Help, Dynamically Attached Dynamic Textbox
Hello,
I'm creating a timeline structured site where a movie clip on the stage called 'slider' is set to slide automatically according to how far left, or right the mouse position is from the center of the stage. This works. I even have it set it up so that using two variables, i can decide how much or even which portion of the movie clip (or the timeline) the user is allowed to slide around in.
I then have a movieclip called 'yearMarker' which is attached at runtime inside the 'slider' movie clip. This is done through a While loop and PHP script which retrieves from the database the field values for "year" (just a string denoting the particular year in question), and "yearXPosition" (which is how far along on the x axis the attached movie clip should be.
the string I retreive from php looks like this:
yearOf1=1976&yearPosition1=0&yearOf2=1977&yearPosi tion2=350&yearOf3=1978&yearPosition3=1350&yearOf4= 1979&yearPosition4=1700&yearOf5=1980&yearPosition5 =2050&...ect.
(I used the variable name 'yearOf' in place of year because flash already has a class property with that name.
I managed to attach the 'yearMarker' movie clip at the right x distance from the left border of the stage, and it works well.
My problem is whith a dynamic textbox within the 'yearMarker' movieclip. The intention is that when the movieclip is attached, the dynamic textbox within, 'yearMarkerText", is given the value of the Year in question, 'yearOf'.
Not only can I not get this part to work, It also seems that the textbox disapears altogether, though if I set the textbox to be selectable and then test the movie, the mouse cursor changes to select text where the textbox should be if it was visible.
The code, on the first frame on the root of the timeline, which attaches a movie clip based on the above values goes like this:
var yearMarkersVar = new LoadVars()
yearMarkersVar.load("
Please Help Me Out With Dynamically Loaded Dyanmic Textbox
Hello,
I'm creating a timeline structured site where a movie clip on the stage called 'slider' is set to slide automatically according to how far left, or right the mouse position is from the center of the stage. This works. I even have it set it up so that using two variables, i can decide how much or even which portion of the movie clip (or the timeline) the user is allowed to slide around in.
I then have a movieclip called 'yearMarker' which is attached at runtime inside the 'slider' movie clip. This is done through a While loop and PHP script which retrieves from the database the field values for "year" (just a string denoting the particular year in question), and "yearXPosition" (which is how far along on the x axis the attached movie clip should be.
the string I retreive from php looks like this:
yearOf1=1976&yearPosition1=0&yearOf2=1977&yearPosi tion2=350&yearOf3=1978&yearPosition3=1350&yearOf4= 1979&yearPosition4=1700&yearOf5=1980&yearPosition5 =2050&...ect.
(I used the variable name 'yearOf' in place of year because flash already has a class property with that name.
I managed to attach the 'yearMarker' movie clip at the right x distance from the left border of the stage, and it works well.
My problem is whith a dynamic textbox within the 'yearMarker' movieclip. The intention is that when the movieclip is attached, the dynamic textbox within, 'yearMarkerText", is given the value of the Year in question, 'yearOf'.
Not only can I not get this part to work, It also seems that the textbox disapears altogether, though if I set the textbox to be selectable and then test the movie, the mouse cursor changes to select text where the textbox should be if it was visible.
The code, on the first frame on the root of the timeline, which attaches a movie clip based on the above values goes like this:
var yearMarkersVar = new LoadVars()
yearMarkersVar.load("http://localhost/script/yearmarker.php");
yearMarkersVar.onLoad = loadYearVariables;
function loadYearVariables(){
// For Loop that will create a "yearMarker" for each year in the list
for (i = 1; i < this.totalyears; i++) {
// Create simpler variable names to use later
yearOf = this["yearOf"+i];
yearPosition = this["yearPosition"+i];
yearMarker = "yearMarker"+i;
// attach movie clip
slider.attachMovie("yearmarker01", yearMarker, i, {_x:yearPosition, _y:273});
// THIS SHOULD PRINT THE TEXT!
slider.yearMarker.yearMarkerText.text = yearOf;
// TREID THIS TOO
level = ["_level"+i];
level.yearMarkerText.text = yearOf;
}
// set variable to be used by 'slider' as end limit
_global.mcWidthTotal = this.mcWidthTotal;
trace(_global.mcWidthTotal);
}
Flash bug? something Im completely missing? am i an ediot? does anyone know how to solve this? im desperate.
thanks
-ahmed
Dynamically Resize Letters To Textbox
I've been battling to somehow resize the letters in a dynamic textbox acording to the amount of letters given by a XML file. So that no matter how long a sentance i will fit exactly into the textbox.... alas small sentance big letters.. long sentance small letters?
Detecting Contact With Dynamically Created Clips
I'm creating a frogger like game where the player can jump on a series of dynamically created and constantly changing logs...
problem... if I have each log moving and performing a hit test on the player it will be VERY processor heavy.
question... Is there a good simple way of testing contact with all ot the log elements.
Thank you,
JH
Height And Width Of Dynamically Loaded Image
I'm dynamically loading images that are portraits and landscapes, and would like to be able to deal with them differently.
Currently, I create an empty movie clip and then dynamically load the image into it, but using _height and _width on the movie clip returns 0 for both.
Is there a way to dynamically load images and then to find the height and width of the loaded image?
Nick
Dynamically Created Circles & The .height Property
Is there some trick to finding out the height of a dynamically created circle? I just decided to make the jump to AS3 about 8 hours ago and I'm having some trouble. Basically, I made a bouncing ball, and I needed the ball to bounce up after the bottom of the ball reached the bottom of the stage. If I use stage.stageHeight - ball.height, it's way off and the ball falls off screen completely before bouncing back up. If I use (stage.stageHeight - (ball.height * 2.33)) though, it works fine. So why do I need to multiply the height by 2.33 for it to work right? I tried this with a rectangle and it worked fine without multiplying. Here's the code I'm using:
PHP Code:
stop();
var gravity:Number = new Number();
var bounce:Number = new Number(15);
var bounceCounter:int = new int(1);
var ball:Sprite = new Sprite();
ball.graphics.beginFill(0xFF0000);
ball.graphics.drawCircle(50,50,15);
ball.graphics.endFill();
var dropShadow:DropShadowFilter = new DropShadowFilter(3,90);
ball.filters = [dropShadow];
stage.addChild(ball);
stage.addEventListener(Event.ENTER_FRAME, moveBall);
function moveBall(evt:Event):void {
var fallSpeed:Number = gravity + 2;
gravity += (.25);
if (ball.y >= (stage.stageHeight - (ball.height * 2.33))) {
ball.y = (stage.stageHeight - (ball.height * 2.33));
bounceCounter++;
gravity = (bounceCounter/2)-15;
if (gravity >= 2) {
gravity = 2;
}
}
ball.y += fallSpeed;
if (bounceCounter > 30) {
stage.removeEventListener(Event.ENTER_FRAME, moveBall);
}
trace(bounceCounter);
}
I never got into physics in AS2, so I'm sure there are more than a few different ways this could be done better. I wanted to see if I could code this entirely off the top of my head, though, instead of just copying someone else's code. Also, I noticed that bounceCounter is incremented twice every time the ball hits the ground. Can someone explain to me why that's happening?
Can't Change The Height Of Dynamically Loading Image
I want to change the height and width of images which is loading from an XML file. I tried.... the images is loading and it is working fine.... All the other properties except the height and width is working.
Please help how to change the height and width of an image which is loading from the XML file
_root.createEmptyMovieClip(movieclip, levels);//working
loadMovie("images/" + filename, movieclip); //working
setProperty(movieclip, _x, posx); //working
setProperty(movieclip, _rotation, 45);//working
setProperty(movieclip, _height, 45);//not working
Seting Stage And/or Browser Height Dynamically
hi, folks,
I have this website. There are 3 pages with different heights. I am loading external swf in a main movie to save loading time.
But i ran into a issue. One page has the height of 1900px and the other 2 have 650px (give-or-take), in other words, 3 times the size of the first one.
I read in Flash/ActionScript specs that we cannot set the height of the stage thru AS or alike. So i had to set the main stage height based on the bigger which gives me a massive scroll bar on the other ones.
Does anyone know how to solve this? I heard you could do it with JavaScript, but how? Any tutorials, comments, light, insight? Anything?
thanks for your time and help,
mr_n00
Reading The Height And Width Of Dynamically Loaded .png's
hi everyone.
i'm doing an infopicture in which hotspots will react on ROLL_OVER and show a .png.
the result so far can be seen here:http://campjohn.dk/temp/infofoto/BigaInfofoto.html
data being loaded can be seen here:
http://campjohn.dk/temp/infofoto/BigaInfofoto.xml
the code so far in the frst frame can be seen here:
Code:
stop();
//CONTEXT MENU
//-----------------------------------------------------------------------
var menuData:Array = [];
menuData.push( {caption:"© 2008 Co3", url:"http://www.co3.dk"} );
//IMPORTS
//-----------------------------------------------------------------------
import caurina.transitions.Tweener;
import NewCustomContextMenu;
import PreloadProgressBar;
//VARS & INITS
//-----------------------------------------------------------------------
var ncm:NewCustomContextMenu = new NewCustomContextMenu(menuData, this);
var _preloadProgressBar:PreloadProgressBar = new PreloadProgressBar();
var _xmlfromURL:String = "BigaInfofoto.xml";
var _xml:XML;
var _xmlloader:URLLoader = new URLLoader();
_xmlloader.addEventListener(Event.COMPLETE, onXMLLoaded);
_xmlloader.load(new URLRequest(_xmlfromURL));
var _numOfLoops:Number;
var _arrayPictures:Array = new Array();
var _arrayX:Array = new Array();
var _arrayY:Array = new Array();
var _arrayP:Array = new Array();
var _arrayLoadedInfo:Array = new Array();
var _backgroundPicture:Loader = new Loader();
var _progressColor:uint;
function onXMLLoaded(e:Event):void {
_xml = new XML(e.target.data);
trace("_xml = "+_xml);
//RED DOTS AND PNG ARE GENERATED IN HOLDERS
_numOfLoops = _xml.infospecs.length();
for (var i=0; i<_numOfLoops; i++) {
_arrayP.push(_xml.infospecs[i].position);
//RED DOTS
var _reddot:RedDot = new RedDot();
addChild(_reddot);
_reddot.name = "_reddot"+i;
_reddot.x = _xml.infospecs[i].xpos;
_reddot.y = _xml.infospecs[i].ypos;
trace(_xml.infospecs[i].position);
_reddot.addEventListener(MouseEvent.ROLL_OVER, rollOverReddot, false, 0, true);
_reddot.addEventListener(MouseEvent.ROLL_OUT, rollOutReddot, false, 0, true);
_reddot.mouseChildren = false;
_reddot.buttonMode = true;
//THE .PNG'S
var pictureHolder:Sprite = new Sprite();
var pictureLoader:Loader = new Loader();
pictureLoader.name = "pictureLoader"+i;
pictureLoader.load(new URLRequest(_xml.infospecs[i].billede));
pictureLoader.x = _xml.infospecs[i].xpos;
pictureLoader.y = _xml.infospecs[i].ypos;
pictureHolder.alpha = 0;
addChild(pictureHolder);
pictureHolder.addChild(pictureLoader);
this.setChildIndex(pictureHolder, 0);
pictureLoader.contentLoaderInfo.addEventListener(Event.COMPLETE, loadedInfoPicture, false, 0, true);
_arrayLoadedInfo.push(pictureHolder);
}
//THE BIG PICTURE IN THE BACKGROUND
_backgroundPicture.load(new URLRequest(_xml.stortBillede));
_backgroundPicture.contentLoaderInfo.addEventListener(Event.OPEN, handleOpen, false, 0, true);
_backgroundPicture.contentLoaderInfo.addEventListener(ProgressEvent.PROGRESS, showProgress, false, 0, true);
_backgroundPicture.contentLoaderInfo.addEventListener(Event.COMPLETE, loadedBackgroundPicture, false, 0, true);
}
//ADD PRELOADPROGRESSBAR
//-----------------------------------------------------------------------
function handleOpen(e:Event):void {
addChild(_preloadProgressBar);
trace("loading has started");
}
//CONTROL THE PRELOADPROGRESSBAREN
//-----------------------------------------------------------------------
function showProgress(e:ProgressEvent):void {
trace("loading picture");
_preloadProgressBar.init(e.bytesTotal, e.bytesLoaded, _progressColor);
_preloadProgressBar.doTheGraphics();
}
//WHEN THE BACKGROUNDPICTURE IS LOADED
//-----------------------------------------------------------------------
function loadedBackgroundPicture(e:Event):void {
removeChild(_preloadProgressBar);
addChild(_backgroundPicture);
this.setChildIndex(_backgroundPicture, 0);
}
function loadedInfoPicture(e:Event):void {
}
//ON ROLL_OVER ON A RED DOT; SHOW THE PNG
//-----------------------------------------------------------------------
function rollOverReddot(e:Event):void {
var tempName:String = e.target.name;
trace("tempName = "+tempName);
tempName = tempName.substr(7);
trace("tempName = "+tempName);
var tempMC:Sprite = Sprite(_arrayLoadedInfo[tempName]);
Tweener.addTween(tempMC, {alpha:1, time:0.4, delay:0.2, transition:"linear"});
}
//WHEN THE RED DOT IS NO LONGER ACTIVE HIDE THE PNG
//-----------------------------------------------------------------------
function rollOutReddot(e:Event):void {
var tempName:String = e.target.name;
trace("tempName = "+tempName);
tempName = tempName.substr(7);
trace("tempName = "+tempName);
var tempMC:Sprite = Sprite(_arrayLoadedInfo[tempName]);
Tweener.addTween(tempMC, {alpha:0, time:0.4, delay:0.2, transition:"linear"});
}
in the xml each picture has a position which shall be used to place it around the red dot.
right now all pictures are placed at 0,0 which equals south east of the red dot.
but, if a red dot is placed in the lower right corner of the flash, it would be nice to be able to place its png in north west instead..
well, enough explanation, I guess
to place the pngs around the red dots I need to be able to read the height and width of each png.
can anyone help me in telling how I can read the sizes of the png, with the actionscript I have so far.. I've prepared an empty function that is ready to read the size of each png: loadedInfoPicture.
but if the function is not useable any other solution is welcome...
hope anyone can help
thanks
felisan
Is It Possible To Dynamically Set The Height Of A Textfield According To Text Amount?
is it possible to dynamically set the height of a textfield according to the amount of text that's been externally loaded?
say if I only have a line of text to load in to a textfield, then that textfield could adjust is height to only the height of a line of text.
and if it is a paragraph, then the textfield will load the text with lenthened height.
is it possible to achieve that? to have a text field adjust its height according to amount of text loaded?
|