LoadMovie _width Problem
Can someone explain why this is happening:When the "About" button is pressed, "about_image.png" is loaded into image_holder.image_holder previously had "main_image.png" loaded into it."main_image.png" is not as high as "about_image.png"I then set image_holder to the centre of the stage (Sw and Sh)However - it is taking the dimensions of image_holder when "main_image.png" is loaded rather than "about_image.png" which means that it isn't sitting in the centre of the stage.Why would this happen when I am asking for it to get the image_holder _height after "about_image.png" is loaded?Just a side note - when I click About for a second time in a row, it centers it on stage, because "about_image.png" is already loaded.CheersBAttach CodeloadMovie("about_image.png", _root.content.image_holder);loadMovie("about_section.png", _root.content.section_holder);var Sw = (Stage.width/2) - (_root.content.image_holder._width/2);var Sh = (Stage.height/2) - (_root.content.image_holder._height/2);var moveOnImageX:Tween = new Tween(_root.content.image_holder, "_x", Strong.easeOut, Stage.width, Sw, 3, true);var moveOnImageY:Tween = new Tween(_root.content.image_holder, "_y", Strong.easeOut, 630, Sh, 3, true);
Adobe > ActionScript 1 and 2
Posted on: 02/11/2008 04:58:31 AM
View Complete Forum Thread with Replies
See Related Forum Messages: Follow the Links Below to View Complete Thread
LoadMovie _width Property..
I`ve done a createEmptyMovieClip and used loadMovie to load a jpeg into it but it won`t give me the ._length or ._width value for the clip. _scale seems to work ok so why not length/width?
Code:
answerThis = this.main["a"+(i+1)];
trace("answerThis._width = "+answerThis._width);
This outputs: 0
This code is part of a for loop which (should!) go on to insert the width value of each clip into an array. Why`s this not working?
LoadMovie _width And _height Problems
Been struggling with this for too long now...
I have newmovie.swf (1438px x 975px) that I loadMovie in to a target (mcTarget) that is 555px x 400px.
I use the code below in an attempt to resize newmovie.swf so all it's contents are visible and contained in mcTarget (555px x 400px).
wInit = mcTarget._width; // 555
hInit = mcTarget._height; // 400
xInit = mcTarget._x - (mcTarget._width / 2);
yInit = mcTarget._y - (mcTarget._height / 2);
/****
tried putting loadMovie in it's own statement block (if (true)) so it's width and height properties are accesible directly below - this doesn't seem to help however
****/
if (true) {
mcTarget.loadMovie("newmovie.swf");
// loadMovie("newmovie.swf", "mcTarget"); <-- same results
}
/****
I also tried putting the code below in the next frame with the same results
****/
mcTarget._x = xInit; // this works
mcTarget._y = yInit; // this works
mcTarget._width = wInit; // this does not
mcTarget._height = hInit; // this does not
What I end up with is newmovie.swf being loaded in to mcTarget, but it's width and height retain their original values (in that their width and height appear on-screen to be 1438x975). However, if I trace _width and _height, Flash tells me they're 555 and 440 respectively.
I hope I explained this enough.
Anyone have any ideas on this?
Thanks
LoadMovie Not Working With Setting _width
hi,
I'm using load movie to load in a .jpg and in the next line i'm trying to set the _width value of the loaded in movie clip with the .jpg in it. Problem is it doesn't work!, the .jpg doesn't appear, but when I don't set the ._width value it does, any ideas?!?
thanks for any help
boombanguk
_width And _height Not Working After LoadMovie Command
i'm working on a map file and i have several different maps that can be loaded into my file by clicking tabs
they're loaded as external .swf files via the loadMovie command
when i have a static map as a part of my .fla the controls work fine ... pan, zoom etc.
when i perform the loadMovie and the map changes ... suddenly my bounds are no longer respected by the pan function's limits
it's like it removes the width and height ... but if the w and h were 0 i would think the pan functions would not work at all so it must be something else
anyone have any ideas?
MovieClip._width After MovieClip.loadMovie();
Hey there,
I have some ActionScript that creates a new MovieClip instance inside of an existent MovieClip on my stage. Once created, it loads an image into this new MovieClip.
Problem is...I need to give this image a fixed width and height. I tried using MovieClip._width and MovieClip._height, but then the image completely disappears.
Here is my current code :
HTML Code:
_root.vidlinks_mc.vid1_mc.createEmptyMovieClip("vid1thumb_mc", _root.getNextHighestDepth());
_root.vidlinks_mc.vid1_mc.vid1thumb_mc.loadMovie("images/imageName.jpg");
_root.vidlinks_mc.vid1_mc.vid1thumb_mc._x = 10;
_root.vidlinks_mc.vid1_mc.vid1thumb_mc._y = 10;
_root.vidlinks_mc.vid1_mc.vid1thumb_mc._height = 60;
_root.vidlinks_mc.vid1_mc.vid1thumb_mc._width = 60;
If someone could help me with this, it will be greatly appreciated.
All the best,
Antonie
_x = _width
hi
i am trying to load a number of external swf's into a parent movie the tricky bit is I want them to line up on the x axis regardless of width (height is the same on all)
so if movie 1 is 300px wide i want movie 2 to be placed at _x=300 the movies loaded in will vary in size so if i can get it to read the ._width of the previous movie, i will only have to update the child swf's
at the moment i have them loading into empty mc's on the stage, but when i set the _x of the clip to the_width of the previous movie it returns 0 (zero)
is it because the script is called before the external movie is loaded, they are only small. if so how do i get round that?
thanks
Can You Specify A Max _width For An Mc?
ok.. here's the situation.. i have a menu that expands and contracts to display each section of the menu (the array goes from 00 - 06) there is a minWidth, maxWidth, and space for the mc's set, at 40, 200, and 4 respectively. Another mc is added to the menu for each menu item. The mc's are set up to expand (maxWidth) on rollover, and return to original (minWidth) on rollOut. There is even a "totalWidth" calculation done to try to control the scale, but it's not working. Problem is sometimes it will work out right, other times, maybe one mc won't reduce all the way to it's minWidth (40) and when you rollover the next the menu pops out further from the original width of the entire menu. it will be easier to understand looking at this:
Code:
| A | B | C | D | E | F | // A selected
| A | B | C | D | E | F | // D selected
| A | B | C | D | E | F | // problem with A returning to orig size when D is selected
So, can i set some sort of MAX TOTAL WIDTH for this that will force it to stay within those bounds? it currently is written like this, but then redefined later in another function:
Code:
function init() {
space = 4;
easingSpeed = 3.2;
minWidth = 40;
maxWidth = 200;
totalWidth = ((items_arr.length-1)*minWidth)+maxWidth+(items_arr.length-1)*space;
}
// more code etc etc
// then later in the script to control the mc growing on rollOver it's this:
totalWidth = maxWidth+(items_arr.length)*(minWidth+space)-space;
can i somehow force them to ALWAYS return to the min width size? (i can post more code if you need it.. i just figured if i could define some sort of ABSOLUTE width of the whole menu, i could constrain it into a "box" and force the values to return to set values. i tried moving
space = 4;
easingSpeed = 3.2; etc
out of init() and used var space = 4, var easingSpeed - 3.2 etc but hthat didn't work either.
any thoughts?
_width Help
I'm using the following code to loop through images in an xml file fading one image in as the other is fading out. This is only a portion of the code. But basically if the user wants there to be a description of the image, then it should be displayed below the image. From the code I am able to trace out the height of the loaded image and hold it in the var imgHeight, but when I place that var as my "Y" value of the createTextField, it doesn't recognize it. Why?
Code:
min = 0;
max = 100;
fadeAmount = fade;
img1Container = true;
function updateImage(newImage) {
_root.textDrag.removeMovieClip();
if(hasLinks){
linkLayer.onRelease = function(){
linkLayer.getURL(newImage.attributes.link, "");
}
}
imagePath = newImage.attributes.jpgURL;
description.text = newImage.attributes.desc;
if(img1Container){
holder = img1;
img1Container = false;
}else{
holder = img2;
img1Container = true;
}
loadMovie(imagePath, holder);
if(hasDesc){
var imgHeight:Number = holder._height;
trace(imgHeight);
//define the format of the text
var descFormat = new TextFormat();
descFormat.color = 0x000000;
descFormat.font = "Trebuchet MS";
descFormat.size = 14;
//create the text field
_root.createTextField("description", this.getNextHighestDepth(), 0, imgHeight, 300, 25);
//apply the text format to the textfield
description.setNewTextFormat(descFormat);
description.selectable = false;
}
holder._alpha = min;
fadeInInt = setInterval(fadeIn, 25, holder);
nextImage = currentImage.nextSibling;
//trace(nextImage);
if(nextImage == null){
currentImage = firstImage;
}else{
currentImage = nextImage;
}
}
Also, the first image being loaded always displays 0 as the height, but then the next time the same first image is loaded, it displays the correct height. Why is this?
Thanks for any help.
_width?
If I made a library instance of a straight line and put it on the stage and set the width in the properties box to be 100 -- why does Flash display the _width to be a different value when I trace the width in actionscript -- 110.8 in this example???? Furthermore when i go about rotating the line in its onClipEvent(enterFrame), it's _width is constantly changing going from 0 back to 110.8?? I'm not doing any kind of transformation other than incrementing the _rotational value of the line. Does anyone know what's going on here?
Please someone help me -- it's driving me crazy..
_height & _width
Hi all
I am trying to return the size of my movie using _height and _width properties, but this returns the size of the MC I have placed on the stage. Does anyone know how I can return the actual movie size?
Cheers
Mark
_width Of A Mask
Dear all
I wonder if anybody can tell me if there is anyway I can retrieve the _width and _height of a mask? I thought movie clips which were masks still behave in the same way as a standard movie clip? I just cant seem to retrieve the _width and _height. Any clues?
Thanks in advance
Steven
_x, _y, And _width, _height
Hey guys please explain something to me:
this code works perfectly:
on (release) {
createEmptyMovieClip("holder", 1);
holder.loadMovie("muestra.jpg");
holder._x=200
holder._y=100
}
BUT THIS ONES DOES NOT WORKS:
on (release) {
createEmptyMovieClip("holder", 1);
holder.loadMovie("my_image.jpg");
holder._x=200
holder._y=100
holder._height=100
holder._width=50
}
please why? when i only position my .JPG with the _x and _y, it works perfectly, but if i what to change it dimensions too it does not work. Please why is this, and how do i do it? I´m pulling hair here.
_width Just Not Happening
Can anyone think of a circumstance when _width will not return a value for a dynamically loaded jpg?
I have a shell_mc that is told to load a jpg with
Code:
shell_mc.loadMovie("picture.jpg");
then on that same shell_mc i have it constantly update a clipSize variable, which is updating a Dynamic text box.
Code:
onClipEvent(enterFrame){
_parent.clipSize = "Width: " add this._width;
}
I've fiddled with it for some time, and I can't figure out why the _width isn't showing up. it's not like it hasn't loaded yet, I see the picture just fine
anything?
Cakk
_width Problem
hi everybody
i need some help please
i wanna to develop a dynamic menu which will read the links from .txt file, i have a movie clip i wanna to increase its width depend upon link length. when i change its width setproperty("instancename","_x",80); check this statement .. it works fine but it increase the width of movie clip by center i don't wanna to increase it by center i don't wanna to change its x position. mean x position will change automatically
Thanks
Naeem
_width And _height
I have a problem with the _width and _height property. I have a menu that contain a mask (to hide the 3D effect). My problem is that the _width and _height property give me the size of the Mask and not the actual visible size. Is there a way to specify a layer or something on which I want the _witdh and _height property to have those of the visible part only?
I want to use this to hide my sub menu like that
if (((_parent._ymouse < 0) or (_parent._ymouse > _parent._height))
or ((_parent._xmouse < 0) or (_parent._xmouse > _parent._width))){
HideSubMenu();
}
MX| Why Cant I Get The _width Of MovieClips
I am trying to get the width of theses jpgs that I load, but it says they are all undefined. The last two lines where I trace the width, dont work. Please Help.
code:
createEmptyMovieClip("thumbMC", -100);
for(i=0;i<10;i++)
{
tn = "tn" + i;
duplicateMovieClip(thumbMC, tn, i);
this[tn].loadMovie(photoArray[i].thumb);
photoArray[i].thumb = this[tn];
trace(this[tn]._width);
trace(photoArray[i].thumb._width);
}
THanks alot.
Resetting MC _width ?
I'm trying to change an MC's _width with the following code:
Code:
mcpreload.loadBar._width = 1;
But I'm not having any luck. This code works on a previous line on my script:
Code:
mcpreload.loadBar._width = per * 2;
Is there another way to write this code? Or to 'reset' the loadBar mc's width back to it's original width size (1).
Thanks
Foochuck
_root._width
how do you automatically detect the size of the _root movie, the actual swf pixel size. i tried _root._width but that just shows the size of the movies contents.
_width For CreateEmptyMovieClip
I got problem getting the _width for the emptymovieclip i create, code as below:
onClipEvent (load) {
//total number of showcase picture?
totolShow = 4;
//
for (var i = 1; i<=totolShow; i++) {
createEmptyMovieClip("showHolder"+i, i);
loadMovie("../lala/show"+i+".jpg", "showHolder"+i);
trace(this["showHolder"+i]._width);
}
}
The output i got is 0, isn't it suppose to get the _width of the jpg loaded inside?
??
chup
Getting _width Of Loaded SWF?
_root.dummy.loadMovie("test.swf");
trace(_root.dummy._width);
// returns: 0
This script returns the width of the dummy MC before it contained the "test.swf". How can I trace the width or height of a loaded SWF??
MC _width From 1 Edge Only?
I'm having a bit of trouble using actionscript to animate the width of a MC. I need its width to decrease/increase but only from 1 edge. Anyone know if there are parameters in actionscript for this? by default it scales from the center. I have tried setting the center point of the clip to 1 edge but it seems to ignore it??
This is what I have on the clip at the moment.
onClipEvent (load) {
target = 40
}
onClipEvent (enterFrame) {
this._width += (target - _width)/20;
}
Any thoughts would be appreciated.
_root._width
I am creating an object that I want to dynamically scale to the size of the main movie.
I have set my movies document size to 760 wide. This movie has an object on it that is 780 wide.
When I use something like:
myScaledObject._width = _root._width;
myScaledObject becomes 780 wide, when I would like it to be 760 or the width of the document.
My question is how can I set the width to the width of the document not the initial greatest width on the document?
Thanks.
_t
Clips._x, By Its Own._width
Hi all, I'm have a bit of a problem with this bit of AS 2.0 code.
What I'm trying to do is build a time line. I want this bit of code to take a clip called "segmentMonth+m" and move it right its own width. But I think I need some one smarter than me to fugue it out Ive tried many different ways to do this but its driving me crazy...
code:
eval("timeLine.segmentYear" + n + ".segmentMonth" + m)._x += (eval("timeLine.segmentYear" + n + ".segmentMonth" + m)._width+eval("timeLine.segmentYear" + n + ".segmentMonth" +(m-1))._x);
I'm including the code for making the time line and the file I'm using.
code:
this.timeLine.segmentYear.yearTxt._alpha = Number(20);
/*****Ok lets create our timeline.*****/
function createYears() {
yearArray = new Array("1900", "1901", "1902", "1903", "1904", "1905", "1906", "1907", "1908", "1809", "1910");
monthArray = new Array("Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec");
for (n=1; n<5; n++) {
duplicateMovieClip("timeLine.segmentYear", "segmentYear"+n, n);
//timeLine.attachMovie("year", "segmentYear"+n, n);
eval("timeLine.segmentYear"+n)._x += (timeLine.segmentYear._width+eval("timeLine.segmen tYear"+(n-1))._x);
eval("timeLine.segmentYear"+n).yearTxt = yearArray[n-1];
eval("timeLine.segmentYear"+n)._alpha = Number(100);
eval("timeLine.segmentYear"+n).ender._alpha = Number(0);
trace(eval("timeLine.segmentYear"+n));
//
for (m=1; m<4; m++) {
//duplicateMovieClip("timeLine.segmentYear.segmentMo nth", "segmentMonth"+m, m);
eval("timeLine.segmentYear"+n).attachMovie("month" , "segmentMonth"+m, m);
//
//eval("timeLine.segmentYear" + n + ".segmentMonth" + m)._x += (timeLine.segmentYear.segmentMonth._width+eval("ti meLine.segmentYear.segmentMonth" +(m-1))._x);
//eval("timeLine.segmentYear.segmentMonth"+m)._x += (timeLine.segmentYear.segmentMonth._width+eval("ti meLine.segmentYear.segmentMonth"+(m-1))._x);
// I think this is the bit of code the is causing me problems
eval("timeLine.segmentYear" + n + ".segmentMonth" + m)._x += (eval("timeLine.segmentYear" + n + ".segmentMonth" + m)._width+eval("timeLine.segmentYear" + n + ".segmentMonth" +(m-1))._x);
//eval("timeLine.segmentYear" + n + ".segmentMonth" + m)._x += (timeLine.segmentYear.segmentMonth._width+eval("ti meLine.segmentYear" + n + ".segmentMonth" +(m-1))._x);
//
eval("timeLine.segmentYear" + n + ".segmentMonth" + m).monthTxt = monthArray[m-1];
eval("timeLine.segmentYear" + n + ".segmentMonth" + m)._alpha = Number(100);
eval("timeLine.segmentYear" + n + ".segmentMonth" + m).ender._alpha = Number(30);
eval("timeLine.segmentYear" + n + ".segmentMonth" + m).monthLine._width = Number(100);
trace(eval("timeLine.segmentYear" + n + ".segmentMonth" + m));
}
}
}
createYears();
//
Any help would be greatly appreciated...
Thanks
Scott
AttachMovie And _width Bug, Help
When I use attachMovie and set the width of that MC, it scales to a completely different width. It doesn't happen at low numbers like 100 or 200, but when I input 500, it scales to 1242 px. I have no idea what to do
Strokes In ._width?
So if I recall correctly, it used to be that Flash did not account for strokes when measuring the ._width or ._height of something.
Now, in Flash 8 it does measure those strokes, and it seems to do a pretty ****ty job of it. Especially if you have the stroke's scale set to 'none' and scale your MC up a bunch, it wont align things proper like.
Is there a way to tell ._width not to think about strokes?
Clips._x, By Its Own._width
Hi all, I'm have a bit of a problem with this bit of code.
What I'm trying to do is build a time line. I want this bit of code to take a clip called "segmentMonth+m" and move it right its own width. But I think I need some one smarter than me to fugue it out Ive tried many different ways to do this but its driving me crazy...
Code:
eval("timeLine.segmentYear" + n + ".segmentMonth" + m)._x += (eval("timeLine.segmentYear" + n + ".segmentMonth" + m)._width+eval("timeLine.segmentYear" + n + ".segmentMonth" +(m-1))._x);
I'm including the code for making the time line and the file I'm using.
Code:
this.timeLine.segmentYear.yearTxt._alpha = Number(20);
/*****Ok lets create our timeline.*****/
function createYears() {
yearArray = new Array("1900", "1901", "1902", "1903", "1904", "1905", "1906", "1907", "1908", "1809", "1910");
monthArray = new Array("Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec");
for (n=1; n<5; n++) {
duplicateMovieClip("timeLine.segmentYear", "segmentYear"+n, n);
//timeLine.attachMovie("year", "segmentYear"+n, n);
eval("timeLine.segmentYear"+n)._x += (timeLine.segmentYear._width+eval("timeLine.segmentYear"+(n-1))._x);
eval("timeLine.segmentYear"+n).yearTxt = yearArray[n-1];
eval("timeLine.segmentYear"+n)._alpha = Number(100);
eval("timeLine.segmentYear"+n).ender._alpha = Number(0);
trace(eval("timeLine.segmentYear"+n));
//
for (m=1; m<4; m++) {
//duplicateMovieClip("timeLine.segmentYear.segmentMonth", "segmentMonth"+m, m);
eval("timeLine.segmentYear"+n).attachMovie("month", "segmentMonth"+m, m);
//
//eval("timeLine.segmentYear" + n + ".segmentMonth" + m)._x += (timeLine.segmentYear.segmentMonth._width+eval("timeLine.segmentYear.segmentMonth" +(m-1))._x);
//eval("timeLine.segmentYear.segmentMonth"+m)._x += (timeLine.segmentYear.segmentMonth._width+eval("timeLine.segmentYear.segmentMonth"+(m-1))._x);
// I think this is the bit of code the is causing me problems
eval("timeLine.segmentYear" + n + ".segmentMonth" + m)._x += (eval("timeLine.segmentYear" + n + ".segmentMonth" + m)._width+eval("timeLine.segmentYear" + n + ".segmentMonth" +(m-1))._x);
//eval("timeLine.segmentYear" + n + ".segmentMonth" + m)._x += (timeLine.segmentYear.segmentMonth._width+eval("timeLine.segmentYear" + n + ".segmentMonth" +(m-1))._x);
//
eval("timeLine.segmentYear" + n + ".segmentMonth" + m).monthTxt = monthArray[m-1];
eval("timeLine.segmentYear" + n + ".segmentMonth" + m)._alpha = Number(100);
eval("timeLine.segmentYear" + n + ".segmentMonth" + m).ender._alpha = Number(30);
eval("timeLine.segmentYear" + n + ".segmentMonth" + m).monthLine._width = Number(100);
trace(eval("timeLine.segmentYear" + n + ".segmentMonth" + m));
}
}
}
createYears();
//
Any help would be greatly appreciated...
Thanks
Scott
_width Vs _xscale
hello!
i'm dynamically loading a bunch of jpg images, and i display them next to each other in a "stripContainer" MC.
Say, each image is 266px width.
i would like to display each image shrinked horizontally to 5px (Don't ask why) .
i tried setting the width of the movieClip in which the image is loaded to 5px, but it seems it then only displays the 5 first pixels of the image it contains (thus cropping) instead of compressing its width.
_xscale is more like what i need, but it does not allow to fix the width to 5px since it is a percentage.
Anyone has an idea on how to solve this?
thank you,
Alex
How Can I Get The Mc With The Higher _width
Hi!
Im doing a poll system in flash... I have 6 movie clip simply called:
mc_bar01
mc_bar02
mc_bar03
mc_bar04
mc_bar05
mc_bar06
(I know I could use For function).but I wanted to keep it simple)...
each of this mc have a different _width
I need a function that found the movieclip that have the higher width value...
any help will be much apreciated!!
thanks a lot
Pat
Box._width & LoadMove(.jpg)
Hi there,
I'm making some sort of a slideshow, if I load a jpg into a "box", with createEmptyMovieClip, the width of this box is 0.
How do I get the width of this box (= width of the picture) and how to resize it with box._width & height.
_hieght _width Tut
Here is a tut that can be useful..
Useful for what?
Well Zoom in magnify,Thumbnails.
Is the code hard?
Hell No
Its very simple 3 lines of code
What's the code look like?
Code:
onClipEvent (mouseDown) {
_width = 200;
_height = 200;
}
Teach Me?
Well make a square and put it on stage.
Convert it to a MC(MovieClip)
Add the code above.
Explaination.
Code:
onClipEvent (mouseDown) {
The Event When you click the mouse down it will do the following.
Code:
_width = 200;
Simple enough the width of your Square will change in to the width of 200 on the stage.
Code:
_height = 200;
Same thing but chnage the square so it is 200 in hieght
This tut was just o give an example of some Zomming in and simple code.
_xscale Vs _width
Whats the difference between _xscale and _width? Explain please? Thanks.
Box._width & LoadMove(.jpg)
Hi there,
I'm making some sort of a slideshow, if I load a jpg into a "box", with createEmptyMovieClip, the width of this box is 0.
How do I get the width of this box (= width of the picture) and how to resize it with box._width & height.
MC Disapearing After _width Set
What's going on??
In Flash, my stage is set to 64 x 90 pixels. I'm setting the background movie clips' _width and _height to that of the stage on Stage resize. It works fine in the swf viewer, but when I embed it into an html page, the image doesn't display (it shifts offscreen).
I'm sure most Flash developers have come across this as it seems to be a pretty basic problem. Any suggestions?
Thanks.
-----------------------------------------------
www.liquidfuzion.com
"The night sky over the planet Krikkit is the least interesting sight in the entire universe."
-Hitch Hiker's Guide To The Galaxy
_height & _width
i have following code
this.createEmptyMovieClip("img",1);
img.loadMovie("M-1.jpg");
trace(img._width);
trace(img._height);
and this both trace give output 0.
so how can i know the height n width of movieclip after loading jpg.
_width And Then A Tween
To give you a basic idea of what I'm doing, I'm loading in a menu from XML and then creating new buttons with the data. What I want is to have a box tween from 0 alpha to 100 in the background behind the box.
I have it all working, except when I change the _width property of the boxMC so it scales to the length of the XML menu, the tween no longer works. It appears the right length, but it will no longether tween.
//eval(strName).behindNavMC._width = lastStrLength + 5;
When I remove that line the tween works, but the box is a fixed size. When I add the line, the box won't tween, but it's the right size.
I tried searching for a solution because I imagine it's been encountered before, but I had no luck.
Content._width = 0 ?
From the code I hope I'm duplicating the filler movie clip and loading it with images from my XML file. That part works, how ever the filler movie clip is inside the "content" movie clip but when i try to get content._width it come up as zero consequently screwing with the scrolling code. Anybody have any idea why?
Code:
xmlData = new XML();
xmlData.ignoreWhite = true;
xmlData.onLoad = loadXML;
xmlData.load("content.xml");
function loadXML(loaded) {
if (loaded) {
root_node = this.firstChild;
total = root_node.childNodes.length;
image = [];
title = [];
spacing = 5;
for (i=0; i<total; i++) {
image[i] = root_node.childNodes[i].childNodes[1].firstChild.nodeValue;
title[i] = root_node.childNodes[i].childNodes[0].firstChild.nodeValue;
tempVar = content.filler;
tempVar.duplicateMovieClip("image"+i,i,{_x:(582+spacing)*i});
content["image"+i].loadMovie(image[i]);
}
} else {
content = "File not loaded!";
}
}
var scroll_root:MovieClip = this;
var mouseMoveDrag:Object = new Object();
var mouseUpDrag:Object = new Object();
var bar_limitLeft:Number = scrollGutter._x - 18;
var bar_limitRight:Number = scrollGutter._x + scrollGutter._width - scrollBar._width + 18;
var content_limitRight:Number = mask._x;
var content_limitLeft:Number = mask._x + mask._width - content._width;
content.setMask(mask);
trace(content_limitLeft);
scrollBar.onPress = function()
{
scrollBar.startDrag(false, bar_limitLeft, scrollBar._y, bar_limitRight, scrollBar._y);
Mouse.addListener(mouseMoveDrag);
Mouse.addListener(mouseUpDrag);
scroll_root.onEnterFrame = function (){
var scrollMovement = (bar_limitRight - bar_limitLeft);
contentMovement = Math.abs(content_limitRight - content_limitLeft);
percentageMovement =Math.abs(scrollBar._x - bar_limitLeft)/scrollMovement;
var finale = content_limitRight - contentMovement*percentageMovement;
content._x = content._x - (content._x - finale)/3;
}
}
mouseMoveDrag.onMouseMove = function()
{
}
mouseUpDrag.onMouseUp = function ()
{
scrollBar.stopDrag();
Mouse.removeListener(mouseMoveDrag);
Mouse.removeListener(mouseUpDrag);
}
MovieClip _width
When I create an empty movieclip and load it with an external swf, how do I then find the width of that movieclip? I'm always getting a value 0!?! My code looks something like this:
var depth:Number = this.getNextHighestDepth() ;
var newMC:MovieClip = this.createEmptyMovieClip("mc_" + depth, depth)) ;
loadMovie(" . . .", newMC) ;
trace(newMC._width) ;
One thought I had was that maybe I was asking for the width before the external file had been loaded. So I put together a listener and tried to trace the width in the onLoadComplete function, but it still gave me 0.
How do I find the width of this thing? Any ideas?
thanks...
Cant Change Mc _width
Hi, I haven't played with Flash for almost a year and I am having a problem changing the width of a movie clip... what am I doing wrong?? Heres what I did
1) I created a new symbol in the library called image
2) added a instance of image to the stage and named it "product_thumb"
3) in the very first frame of the root movie clip I added the following actions:
product_thumb._width = 20;
product_thumb.loadMovie("http://localhost/cell.jpg", image);
If I remove the first line the image loads fine, but it is to wide... but when I try to set the _width to 20 the image doesn't load... if I put
trace(this._width);
In the first frame within the product_thumb clip it echos off "0"... even if I set the _width to 20 in the root movieclip. what am I doing wrong?? No errors are returned by the debugger
Does _width Always Remain Relative?
hi there, I hope someone will be able to help me,
This should be a fairly easy question but I can't even get my head round asking it!!
I have an object in a maze and am moving it by checking if it can move there and moving -
this is done by if (path.hitTest(object._x, object._y-_width, true)){
move;
}
ok so I now have both path and object embeded within MC so that the true path of path becomes _root.head.inner.one.path I have changed the hitTest paths and everything accordingly and everything works fine - until I change the size of _root.head - now nothing works. - I have tried localToGlobal and globalToLocal variables as well as _width - the results of all of these always gives the width of object as 5 (its original width) - does this sound right ??
are widths always the same size??
-- I would actually imagine that they would be!
anyway so object checks the position that you want to go into i.e. _x+_width and moves but not if I change the size of the movie that it is embedded within -
-- what with this and my cgi problems the weekend is just getting better all the time.
cheers for any help.
beezer
_width Property Problem
I have a big problem (I think :-) Here is the situation:
In the main timeline I have a button called "Image". This button contains 2 movieclips called "1" and "2" on separate layers. MC "1" loads an image from an URL and MC "2" is just a square. I want to set the 2._width-property (the square) to the width of the image that is loaded in Mc "1". Is that possible?
Sorry about my poor English.
Happy Flashing
Metaman
_width And _height, How It Works?
Why when i execute this script :
if (_root.mcPict._width<400){
_root.mcPict._width=_root.mcPict._width+5;
}
When i execute this, the height of my movie clip is changing too, is somebody can explain me what is appening.
---
thanks
merci
Load Jpeg, _width, _x
Can I load four different-sized jpeg's into one movieclip and place the second one's _x where the first one's end. And so on.
As I see it there could be problems with not loading the jpeg in the correct order and so placing them on the wrong _x values.
Am I thinking right here.
Is this however possible to do?
Conflicts With _xscale And _width
I set the height and width of an mc with
code:
map._width = (Math.ceil(stageW-100));
map._height = (Math.ceil(stageH-100));
stageW and stageW are set by
code:
stageW = Stage.width;
stageH = Stage.height;
this is fine since i am using _width and _height to set the mc size this should mean the _xscale and _yscale should remain 100%. This does not seem to be the case and is causing headaches for me.
--
Here's were am @:
I have a global map that loads into my website, stageW and stageH are set in the main movie.
Once the map starts to load it checks the height and width of the mina maovie and then sets it's size with that. this is all fine and all starts to bugger up once i try to use _xscale and _yscale of the map.
Anyone any ideas to a solution.
cheers
Paul
--------------
senocular:
Quote:
_width and _height are related to _xscale and _yscale. When _width changes, _xscale reflects that change; when _height changes, _yscale reflects that change. The same applies the other way around.
If you need to be in a situation where you need to change the width/height without changing the _xscale or _yscale properties, then put that movieclip within a containing movieclip and scale change the original movieclips size within. Then you can use the container movieclip as "the" movieclip as its _xscale and _yscale will have remained 100% despite the change of size within.
Movieclip._width Gives Wrong Value
Hey there,
I've got a short question, but it frustrates like hell!
when I use the option Movieclip._width for measuring purposes,
it returns te wrong values!
I made a piece of txt (static) and converted it into a movieclip.
Then I picked an instance name (for this example I use 'test').
Now I made a easy little script like this:
testWidth = test._width;
When I publish this flash movie, the 'List of Variables' returns a higher value for the width then it in reality is.
How is this possible???
Please help me out!!
Movieclip._width Gives Wrong Value
Hey there,
I've got a short question, but it frustrates like hell!
when I use the option Movieclip._width for measuring purposes,
it returns te wrong values!
I made a piece of txt (static) and converted it into a movieclip.
Then I picked an instance name (for this example I use 'test').
Now I made a easy little script like this:
testWidth = test._width;
When I publish this flash movie, the 'List of Variables' returns a higher value for the width then it in reality is.
How is this possible???
Please help me out!!
_width Property Of New Movieclip - MX BUG?
Hi,
I am using FlashMX 2004 Professional version 7.2. I have the following code which fails to work consistantly:
code:
// identifies problem with mc._width
var thisCatCount:Number = 0;
var row:Number = 0;
var col:Number = 0;
var shopIterator:Number = 0;
var baseURL:String = "http://myserver.com/images/";
var shop:Array = new Array();
shop[0]="LeatherJacket.jpg";
shop[1]="FemaleBarTshirt.jpg";
shop[2]="MaleBarTshirt.jpg";
shop[3]="ShirtFront.jpg";
shop[4]="ShirtBack.jpg";
shop[5]="SportShirt.jpg";
shop[6]="WhiteTshirt.jpg";
var shopSize:Number = _root.shop.length;
function loadNext()
{
// load the next item in shop
shopIterator++;
trace(shopIterator);
if (shopIterator == _root.shop.length)
{
trace("Loaded whole shop OK");
} else {
loadImage(shop[shopIterator]);
}
}
//load a single image
function loadImage(ImgUrlLarge:String)
{
trace("called loadImage" + ImgUrlLarge);
// create clip to load image
var newClip:MovieClip = this.createEmptyMovieClip("item" + shopIterator, thisCatCount + 20);
// load the external movie into the new movieclip
newClip.loadMovie(_root.baseURL + ImgUrlLarge);
// check to see if image is loaded
this.onEnterFrame=function(){
//trace the percentage of the movie that has loaded
percent=(newClip.getBytesLoaded()/newClip.getBytesTotal())*100;
if(!isNaN(percent)){
trace(percent+"% loaded (image " + shopIterator + " of " + shopSize + ")");
} else {
percent = 0;
trace("0% loaded");
}
if(percent == 100){
// remove status thing and load the next item in the shop
delete this.onEnterFrame;
// copy the movie clip into the correct position on stage, with constrained aspect ratio
newClip._x = 20 + (row * 100);
newClip._y = 60 + (col * 120);
col++;
if (col == 2) {
col = 0;
row++
}
thisCatCount++;
trace ("Image size");
trace(newClip._width);
trace(newClip._height);
// now scale the new clip - THIS IS MY PROBLEM!
var scale:Number = getOptimumScale(newClip._width, newClip._height, 90, 90);
// var scale:Number = 10;
trace("Scale: " + scale);
newClip._yscale = newClip._xscale = scale;
loadNext();
}
}
}
// fit an image to given area with contrained aspect ratio
function getOptimumScale(ox, oy, fx, fy)
{
var xscale:Number = 0;
var yscale:Number = 0;
xscale = fx/ox;
yscale = fy/oy;
return Math.min(xscale, yscale) * 100;
}
loadNext();
stop();
If you want to test this code just paste into frame 1 of a new movie, and update the shop[] array and baseUrl to something you have access to.
The code loads a set of images from an array (called shop[]). It creates a new movieclip for each image. It waits until each image is completely loaded, then positions the new clip in rows and columns. This all works fine.
My problem occurs when I try to scale the image. The newClip._width and newClip._height properties give me values of 0 (therfore my scale ratio evaluates to Infinity!!). This problem is not consistant - ie. sometimes the code works perfectly for all images, sometimes not - this is why I feel the problem is with Flash MX2004 itself as opposed to my code. I could be wrong.
When I uncomment the line:
// var scale:Number = 10;
everything works 100% of the time - apart from the dynamic scaling of course.
I'm tearing out my hair - Any feedback will be *greatly* appreciated.
TIA,
GW
MovieClip _width Is Ignored For Images
Hi,
I'm very new to Flash...what a learning curve!!!! ;-)
However, I've a simple problem, I'm dynamically loading images into a movie clip created using createEmptyMovieClip().
When I reference the newly created movie clip I set its width and height using _width and _height, in an attempt to stop big images exploding out of these constraints.
They seem to be simply ignored, any ideas why? Or do I have to resize my images to fit these constraints which would be rubbish
Any help greatly appreciated,
B
_width & _height Detection
I have written this to resize an mc:
code: mc.onEnterFrame = function() {
speed = 5;
endW = 200;
endH = 200;
w = endW - this._width;
h = endH - this._height;
this._width += w/speed;
this._height += h/speed;
if (this._width >= endW && this._height >= endH) {
trace("trace");
delete this.onEnterFrame;
}
}
I need to have the width and height detected then have an action to occur.
It's odd because if i change it to <= instead of >=, the trace occurs.
Thanks for any help.
Can't Read ._width? But It's Loaded?
Here's my code. Everything seems to work fine except it won't read the width of the placed image. I can only guess it's not loaded when the width is being asked for. But I put it in onLoadComplete, what am I doing wrong?
Thank you.
Code:
full_mcl = new MovieClipLoader();
fullListener = new Object();
fullListener.onLoadComplete = function(){
trace("Function hit");
fullContainer._x = 35;
trace(fullContainer._width); //<------------NOT WORKING
fullContainer._y = 100;
};
full_mcl.addListener(fullListener);
full_mcl.loadClip("entries/chartingDiagram/ch" + i + ".jpg", fullContainer, 200);
|