whats the problem with my script? :h: /// action goes inside the movieclip “piltpilt”. i need to load a .jpg file to the MC “pilt2”(it’s inside “piltpilt”) and if the width of the .jpg loaded to “pilt2” is over 201 px, then the width of MC “piltpilt” must be 274 and height must be 200.
But there appears no change in width.
my script:
algus = _root[“t”+_parent._parent._currentframe];
[COLOR=DarkRed]this.createEmptyMovieClip(“pilt2”, 1);
this.pilt2.loadMovie(“valmis/”+algus+".jpg");
if (pilt2._width>200) {
_parent.piltpilt._width = 274;
_parent.piltpilt._height = 200;
}[/COLOR]_root.kell = valma;
you have to wait until its loaded before you can check its width. Jpeg loading isnt immediate. It takes time. set an interval with setInterval or use onEnterFrame to check to see when its loaded and then check the width
whats wrong with this??
it SHOULD wait until the picture is loaded, and then take it’s width, height and reseize the “piltpilt” movieclip
(i DO have to use the instance names to identidy movieclips? cause’ i have used only instance names)
HELP ME
algus = _root[“t”+_parent._parent._currentframe];
piltpilt.createEmptyMovieClip(“pilt2”, 1);
piltpilt.pilt2.onLoad = function() {
do {
loadMovie(“valmis/”+algus+".jpg", 2);
l = this.getBytesLoaded();
t = this.getBytesTotal();
} while (t != 0 && Math.round(l/t) == 1);
if (l == t) {
w = this._width;
h = this._height;
_parent._parent.piltpilt._width = w;
_parent._parent.piltpilt._height = h;
}
};
_root.kell = valma;
I said setinterval or enterframe, NOT while of for loops. while and for loops are for “immediate” looping. You need something that happens over time.
If you’re using MX04, try using the moviecliploader
i’m using regular Flash MX
setintervals - with that i’m not familliar
enterframe?
now…
if i put the next script to the 1. frame of the movieclip “piltpilt” (there is 2 frames… the 2. is empty), it shows the loaded .jpg(w = 200, h = 274) when i test the movie.(but when it loads a .jpg that has… _width = 274 and _height = 200, then i need that “piltpilt” resizes to w = 274 and h = 200 and goes to new _x and _y)
[COLOR=Navy]algus = _root[“t”+_parent._parent._currentframe];
this.createEmptyMovieClip(“pilt2”, 1);
loadMovie(“valmis/”+algus+".jpg", _pilt2);[/COLOR]
and do i put the next script to the movie clip “piltpilt” (_parent to pilt2)…?
[COLOR=Navy] onClipEvent (enterFrame) {
t = pilt2.getBytesTotal();
l = pilt2.getBytesLoaded();
if (t != 0 && Math.ceil(t/l) == 1) {
this._width = 274
this._height = 200;
this._x = -94.0;
this._y = -112.0;
}
}[/COLOR]
but anyways… it does’nt work and i’m PRETTTYY confused with that thing for now…have been doing the game pretty much 24h in a row and it pisses of if something just does not want to work.
could You PLEASE help me to fix the script or fix the mistakes and explain me, what where goes
PLEASE PLEASE
PLEASE
PLEASE
PLEASE
hm… is this better? i’ve put this into the first frame of MC “piltpilt”. The picture appears, but there is still no resizing…
this.onEnterFrame = function() {
algus = _root[“t”+_parent._parent._currentframe];
this.createEmptyMovieClip(“pilt2”, 1);
this.loadMovie(“valmis/”+algus+".jpg", _pilt2);
t = this.getBytesTotal();
l = this.getBytesLoaded();
if (t != 0 && Math.ceil(t/l) == 1 && pilt2._width>200) {
this._width = 274;
this._height = 200;
this._x = -94.0;
this._y = -112.0;
}
};
OK!
i have made a .fla, that contains pretty much the same situation as in my original .fla
i have tried to use setInterval, but things just wount work for me.
just in case i’d like to mention that the goal with that .fla is to get the dynamic textbox in _root to say “correct!” and the width of the shape on _root must be 500.
conditions are, that script must check if the picture is loaded and picture’s height is greater then 200.
[COLOR=DarkRed]i’d be really thankful if someone could make this .fla work[/COLOR]
Are your pictures progressive jpeg’s? If so you have to edit them and remove that option, else they simply won’t load in flash…
they are not progressive… and the DO load in flash, but this script does’nt work a needed ( _root.asd does’nt get “Correct” and _root.line does’nt get _width = 500;
this.createEmptyMovieClip(“pilt2”, 1);
this.loadMovie(“http://www.hot.ee/murka390/egeria.jpg”, _pilt2);
checkLoaded = function () {
var t = pilt2.getBytesTotal(), l = pilt2.getBytesLoaded();
if (t != 0 && (l/t) == 1 && pilt2.height>200) {
var w = pilt2._width, h = pilt2._height;
_parent.asd = “Correct!”;
_parent.line._width += 500;
clearInterval(intervalID);
}
intervalID = setInterval(checkLoaded, 50);
};