-
Senior Member
onData, onLoad and createEmptyMovieClip actions
Hey all. Check this out:
I want to load pictures to make a gallery. I thought I could do something like:
Code:
_root.createEmptyMovieClip("x", 1);
_root.x.onData = function() {
this._width /= 2;
this._height /= 2;
}
_root.x.loadMovie('IMGP0001.JPG');
But that can't be done. I mean, if I make:
Code:
_root.createEmptyMovieClip("x", 1);
_root.x.onData = function() {
trace(this._height);
trace(this.getBytesTotal());
}
_root.x.loadMovie('IMGP0001.JPG');
I get an output like:
when the height of the pic is 960px and 150930 bytes.
Another thing, if I make:
Code:
_root.x.onData = function() {
this.stat += "ondata\n";
}
_root.x.onLoad = function() {
this.stat += "onload\n";
}
_root.x.loadMovie('IMGP0001.JPG');
and get to trace _root.x.stat, I get 'undefined'.
Also, on things like that, what performs first? onData or OnLoad?
Thanks in advance,
Leonardo Lima
-
Got the same problem. Haven't found the answer yet.
But I'm also very currious for the answer!
-
Senior Member
one way is like this;
this goes on the first frame of the main timeline.
Code:
this.createEmptyMovieClip("x",1);
x.loadMovie("IMGP0001.JPG");
this.onEnterFrame = function(){
trace(x._height);
trace(x.getBytesLoaded()/1024);
}
The output will read; the height and kbs of the loaded image.
Hope this helps
-
Senior Member
It works as told, but I only wanna set this once. I can have a 'if(!allset) { ... allset = 1 ...}' condition but imagine 40 onEnterFrames. Won't that be too much?
Thanks,
Leo
-
Senior Member
What exactly do you want to do?
The term "this.onEnterFrame" applies to the timeline in the frame that it's in.
Everything underneath the term will execute when the playhead of the timeline enters that frame.
-
Senior Member
What I wanna do:
- resize the pictures
- set X/Y coords according to some math
For that I don't need a onEnterFrame, just once is enough...
Thanks,
Leo
-
(sic)
You should just be able to do the following:
Code:
this.createEmptyMovieClip("mc", 0);
this.mc.loadMovie("myImage.jpg");
this.mc.onData = function () {
trace(this._width); // find images width
trace(this._height); // find images height
}
The obviously you can do anything from there such as resizing the mc, repositioning it etc.
-
Senior Member
I CTRL+C/V and it didn't worked... It never traced anything...
Can you make a sample?
Thanks,
Leo
-
Didn't work for me either!
Shouldn't you be tracing
Code:
this.mc._widht
this.mc._height
instead of
Code:
this._widht
this._height
-
This is my situation.
The picture is loaded without any problems, but the onData
does not work I never see the text "I'm in"!
Code:
function loadPicture(picName){
Window.Foto.jpgHolderInst.loadMovie(slidePath+picName);
Window.Foto.jpgHolderInst.onData = function() {
trace("I'm in!");
}
}
-
Ok, maybe some answers.
I searched a bit in the forums and this is what I came up with
It seems like onData and onLoad don't work with loadMovie, but only with loadVariables.
Check these out
Same problem
http://board.flashkit.com/board/show...hreadid=325958
http://board.flashkit.com/board/show...hreadid=326336
And some workaround from flashguru
http://board.flashkit.com/board/show...hreadid=340302
I also found a link to the site of flashguru with a article
about this subject but the site was down, but here is the link anyway
http://www.flashguru.co.uk/000053.php
-
Senior Member
Sure, but it isn't saying so at the AS Dictionary:
'Event handler; invoked when a movie clip receives data from a loadVariables or loadMovie call.
You must define a function that executes when the event is invoked.'
(from $flashpath\Help\Flash\html\30_asd_07_m80.html).
Did you try that workaround?
Regards,
Leo.
-
Tried the workaround, but with no success!
-
About the workaround
I tested the workaround.
The test code provided by flashguru works allright.
But my own loadMovie does not!
-
Senior Member
What do you mean by 'your own'?
And do you have ICQ or so so we can talk?
Regards,
Leo
-
With my own, i ment my own code.
When I just copy and paste it didn't work.
But I just got it all working.
The workaround works!
My appologies to flashguru for ever questioning his code!
-
Senior Member
So we must use the workaround. Ok then.
Regards,
Leo.
-
chatbugs.com *****
Perhaps this thoroughly commented example will help you guys.. I made it a couple of months ago.. it's Flash5 and MX compatible.
http://www.flashtampa.com/flashtutor...onalReSize.fla
http://www.flashtampa.com/flashtutor...onalReSize.swf
-
Jayson,
Tnx.
You've placed comment that it cannot be run in the flash environment, but I just changed your jpg for one of mine and
ran the bastard on my local machine with no probs!
It worked like a charm!
It's exactly what I needed.
I will use this in my project.
tnx again,
biker66
[Edited by biker66 on 07-22-2002 at 07:51 AM]
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|