A Flash Developer Resource Site

Results 1 to 16 of 16

Thread: [F8] need help with loading external images and interacting with them

  1. #1
    Crazy Guy delfick's Avatar
    Join Date
    Feb 2004
    Location
    Best side of the best country (Western Australia)
    Posts
    165

    [F8] need help with loading external images and interacting with them

    hello

    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

    code:
    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
    if you find some of my ideas weird, look at my avatar for the reason

  2. #2
    FK'n_dog a_modified_dog's Avatar
    Join Date
    Apr 2003
    Location
    "aaarf"
    Posts
    9,176
    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..}

  3. #3
    Senior Member
    Join Date
    Oct 2006
    Posts
    193
    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.

  4. #4
    Crazy Guy delfick's Avatar
    Join Date
    Feb 2004
    Location
    Best side of the best country (Western Australia)
    Posts
    165
    Quote Originally Posted by a_modified_dog
    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

    that works

    thankyou very much
    if you find some of my ideas weird, look at my avatar for the reason

  5. #5
    Crazy Guy delfick's Avatar
    Join Date
    Feb 2004
    Location
    Best side of the best country (Western Australia)
    Posts
    165
    Quote Originally Posted by panchoskywalker
    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

    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 )

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

    ....
    if you find some of my ideas weird, look at my avatar for the reason

  6. #6
    Crazy Guy delfick's Avatar
    Join Date
    Feb 2004
    Location
    Best side of the best country (Western Australia)
    Posts
    165
    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 ??

    thnx
    if you find some of my ideas weird, look at my avatar for the reason

  7. #7
    FK'n_dog a_modified_dog's Avatar
    Join Date
    Apr 2003
    Location
    "aaarf"
    Posts
    9,176
    preload all of the images, they will sit in the cache ready for instant load

  8. #8
    Crazy Guy delfick's Avatar
    Join Date
    Feb 2004
    Location
    Best side of the best country (Western Australia)
    Posts
    165
    k then...

    how do i do that ??

    thnx
    if you find some of my ideas weird, look at my avatar for the reason

  9. #9
    FK'n_dog a_modified_dog's Avatar
    Join Date
    Apr 2003
    Location
    "aaarf"
    Posts
    9,176
    modify one of bokels multiple preloaders

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

    or Google - multiple preload images *flash

  10. #10
    Crazy Guy delfick's Avatar
    Join Date
    Feb 2004
    Location
    Best side of the best country (Western Australia)
    Posts
    165
    cool thnx

    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

    code:
    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)

    .....
    Last edited by delfick; 07-09-2007 at 09:53 AM.
    if you find some of my ideas weird, look at my avatar for the reason

  11. #11
    FK'n_dog a_modified_dog's Avatar
    Join Date
    Apr 2003
    Location
    "aaarf"
    Posts
    9,176
    or search my Code Bank (link in my sig.) for - preload

    you'll find - LoadVars preload multiple images

  12. #12
    Crazy Guy delfick's Avatar
    Join Date
    Feb 2004
    Location
    Best side of the best country (Western Australia)
    Posts
    165
    i edited the last post after you posted again, does it make a difference to my problem ??
    if you find some of my ideas weird, look at my avatar for the reason

  13. #13
    FK'n_dog a_modified_dog's Avatar
    Join Date
    Apr 2003
    Location
    "aaarf"
    Posts
    9,176
    does it make a difference to my problem ??

    only you will know that when you have modified and tested

  14. #14
    Crazy Guy delfick's Avatar
    Join Date
    Feb 2004
    Location
    Best side of the best country (Western Australia)
    Posts
    165
    dodgy solutions FTW

    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 )

    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



    again, thnx for the help
    Last edited by delfick; 07-09-2007 at 12:16 PM.
    if you find some of my ideas weird, look at my avatar for the reason

  15. #15
    FK'n_dog a_modified_dog's Avatar
    Join Date
    Apr 2003
    Location
    "aaarf"
    Posts
    9,176
    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.

  16. #16
    Crazy Guy delfick's Avatar
    Join Date
    Feb 2004
    Location
    Best side of the best country (Western Australia)
    Posts
    165
    Quote Originally Posted by a_modified_dog
    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....)
    if you find some of my ideas weird, look at my avatar for the reason

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  




Click Here to Expand Forum to Full Width

HTML5 Development Center