I need to load a jpg into a button. After that I want to be able to drag the button (and subsequently the loaded jpg). Currently I am able to load a jpg into levels but I can’t seem to get it to properly load into a button and then be draggable. And ideas?
Why load into a button when you can make the container you load to a button?
Confused?
Try this…
_root.createEmptyMovieClip("container",1);
container.loadMovie("photo.jpg");
container._x = container._y = 50 ;
_root.onMouseDown = function () {
startDrag ("container",false) ;
}
_root.onMouseUp = function () {
stopDrag () ;
}
First it creates an empty movie clip on the stage with the instance name “container”. This is all done dynamically through AS.
Next is uses loadMovie on that clip to load in an image called photo.jpg. Now Flash can only load in Non-Progressive .jpg images mind you, so be aware of this in the future if your images don’t load.
It then moves the container the _x and _y 50 ((x,y) coords)
After that it uses dynamic event handlers to detect wheter the container clip has the mouse pressed down on it. If so, it drags the clip, and if not, it stops dragging the clip.
If you have any questions or I am misunderstanding what you want, please let me know.
What I think he’s saying is that he wants to be able to drag the button around on the scene - not in the main .swf but rather to be able to place it where he wants instead of having to adjust it accordingly through code. >But could be wrong<
lost,
let’s say you had a folder of images - 1.jpg, 2.jpg, … 10.jpg and you wanted to load them all as separate draggable (and resizable!) files. How would you adjust the code to create an EmptyMovieClip for each that was draggable, resizable?
curious,
JCS
(-:
Well it would pretty much be the same, except for resizeability you would need to set something else up.
Usually components are used for that kind of thing, which I don’t think you can attach to a dynamically created clip.
Thanks for the quick replies. I don’t care whether I use buttons or a component. In the end I want to be able to do the following:
(1) In the params/embed section pass in a jpeg filename
FlashVars=“imageFile=someimage.jpg”
(2) Using _root.imageFile I want to then attach the image located in the same directory as my .swf to something - a button, component, mov clip.
(3) So far I’ve tried to attach to buttons and mov clips without any great luck. I can get the image to load in the external jpg but I can’t make it draggable.
(4) So the tricky part for me is in attaching it to something that will allow me to manipulate and drag the image around. For example, I would like to drap and drop the image, be able to scale the image using _xscale and _yscale, and also align the image using _x and _y.
I hope that’s a better description of the problem and I’ll try your ideas tonight. Thanks!!
It sounds like you are trying to do something like this…
http://www.flashcomponents.net/component.cfm?nav=2&id=103
I don’t know if you will be able to use something like that for a dynamically loaded image.
What you can try is to create an empty movie clip on the stage, attach the component to that, and load your .jpg to that clip.
Or you could can put another empty movie clip inside that empty movie clip and load the .jpg to that and see if it will work.
IF these don’t work, then I don’t think you can do it.
There is also this…