;

PDA

Click to See Complete Forum and Search --> : [F8] need help with loading external images and interacting with them


delfick
07-08-2007, 12:15 PM
hello :D

currently i'm trying to something (more complex than the little example given below) where i need to attach an externally loaded image (that can't be kept in the fla file) and then be able to do stuff when that image is rolled over, rolled out of, or clicked on.

I'm able to get the image there using loadMovie but then when i apply mouse events to the movieclip the image is loaded to, then they don't seem to do anything.....

here is a small example of how i used loadMovie

class test extends MovieClip
{
private var container:MovieClip;
public function test()
{
_root.createEmptyMovieClip("test", 1);
container = _root.test;
//assuming there is a bob.png file in the same directory as the swf
//for example delfick755.googlepages.com/bob.png
container.loadMovie("bob.png");
container.onRollOver = function()
{
trace("hello");
};
}
}

so i was wondering if someone could help me please ??

thankyou :D

a_modified_dog
07-08-2007, 01:44 PM
create a nested clip - outer.inner
load to the inner clip, interact with the outer clip

outer.inner.loadMovie("a.jpg");
outer.onRelease = function(){..code..}

panchoskywalker
07-08-2007, 07:55 PM
This looks interesting could you post an example of what you're doing please? I'm trying to load an external movie with a picture inside and a close button for a gallery and I have no idea of how to do that....please.

delfick
07-08-2007, 09:22 PM
create a nested clip - outer.inner
load to the inner clip, interact with the outer clip

outer.inner.loadMovie("a.jpg");
outer.onRelease = function(){..code..}


awsome :D

that works :D

thankyou very much :D

delfick
07-08-2007, 09:31 PM
This looks interesting could you post an example of what you're doing please? I'm trying to load an external movie with a picture inside and a close button for a gallery and I have no idea of how to do that....please.

unlike pretty much every other thread on loading externel images in this forum (i did look before posting this, but they were all about bitmapData and i couldn't get it working) I'm not creating a gallery :D

i'm actually trying to create this http://forum.compiz.org/viewtopic.php?t=832 using actionscript classes (more for the point of learning actionscript classes than anything else, i think i'm starting to get used to them :p)

this is what i have so far (don't mind the dodgy checkboxs, that's the point of this thread :D) http://delfick.storage.googlepages.com/flashbsm.zip

....

delfick
07-09-2007, 08:39 AM
hmmm, there's only one problem with this, everytime the picture is changed there is a second where there is nothing as the image is loading.....

is there a way to make it so that there isn't that gap where it has to load the image ?? :D

thnx

a_modified_dog
07-09-2007, 08:47 AM
preload all of the images, they will sit in the cache ready for instant load

delfick
07-09-2007, 09:19 AM
k then...

how do i do that ?? :D

thnx

a_modified_dog
07-09-2007, 09:29 AM
modify one of bokels multiple preloaders

http://www.bokelberg.de/actionscript/

or Google - multiple preload images *flash

delfick
07-09-2007, 09:47 AM
cool thnx :D

i'll have a look at that...

also, incase it makes a difference, the way i'm doing this is calling a function in the shapes class called createCheckBox and pass into it the movieclip i'm creating the checkbox in, the size of the checkbox (because i was using the drawing API before) and the state of the checkbox

shapes.createCheckBox(thePlugin.container.checkBox , 15, "off");

and then that function is

public static function createCheckBox(mc:MovieClip, sideLength:Number, type:String)
{
if (mc.pic == undefined)
{
mc.createEmptyMovieClip("pic", 200);
}
mc.clear();
switch (type)
{
case "on" :
mc.pic.loadMovie("images/checkbox/on.png");
//createStaticRectangle(mc, 0, 0, sideLength, sideLength, 1, 0, black, white, 0);
//createCircle(mc, sideLength / 2.5, 1, white, green, 50, sideLength / 2., sideLength / 2, false);
break;
case "off" :
mc.pic.loadMovie("images/checkbox/off.png");
//createStaticRectangle(mc, 0, 0, sideLength, sideLength, 1, 0, black, white, 0);
break;
case "inactive" :
mc.pic.loadMovie("images/checkbox/inactive.png");
//createStaticRectangle(mc, 0, 0, sideLength, sideLength, 1, 0, black, grey, 0);
break;
}
}

(unfortunately has to be static because when i do mc.onRollOver = function() { createCheckBox(<etc, etc) } it doesn't get called)

.....

a_modified_dog
07-09-2007, 09:52 AM
or search my Code Bank (link in my sig.) for - preload

you'll find - LoadVars preload multiple images

delfick
07-09-2007, 09:57 AM
i edited the last post after you posted again, does it make a difference to my problem ??

a_modified_dog
07-09-2007, 10:48 AM
does it make a difference to my problem ??

only you will know that when you have modified and tested :D

delfick
07-09-2007, 12:12 PM
dodgy solutions FTW :D

i managed to find this http://labs.bigspaceship.com/blog/?p=8 which looks very useful, but right now it looks confusing (will look at it another day :D)

but for now what i've done is i've created three movieclips for the three states of the checkbox and then got a function that switches the visibility of each so that the correct state of the checkbox is shown which works very well :D

:D

again, thnx for the help :D

a_modified_dog
07-09-2007, 12:21 PM
FTW was originally a tattoo, sported by prisoners which meant -
f*ck the world.

i s'pose you mean - For the win?

Who would use "for the win" in a conversation?

Fair dinkum you'd sound like a right d*ckhead, mate.

delfick
07-09-2007, 08:32 PM
Fair dinkum you'd sound like a right d*ckhead, mate.

lol

yeah i meant for the win....

(and i don't use it in normal conversation, just the internet....)