A Flash Developer Resource Site

Results 1 to 10 of 10

Thread: adding clickevent to MovieClip in library in as3

  1. #1
    Junior Member
    Join Date
    Oct 2011
    Posts
    8

    adding clickevent to MovieClip in library in as3

    hii frndss!! am n a gr8 confusion..., would u pls clear tat.. In actionscript3.0 how to make an movieclip in library clickable?? i have intially a button on the stage when i click tis button, then the movieclip should appear and then when i click the movieclip a new bitmap should appear.. my problem is when i click the button, then the MovieClip from library gets loaded. But "WHEN I CLCIK THE MOVIECLIP ITS NOT LOADING THE BITMAP DATA FROM THE URL I HAVE GIVEN..." pls spare sometime to help me out... it would b really helpfull if u tell me how to solve tis..
    my coding are lik tis
    var s : s1 = new s1();// s is the instance name given to movieclip whose
    class is s1
    function dsip(event:MouseEvent):void{
    var loader1:Loader= new Loader();
    loader1.load(new URLRequest("thumb.jpg");
    addChild(loader1);
    }
    s.addEventListener(MouseEvent.CLICK,disp);// s is the instance name of the MovieClip and i am trying to add click event.
    any help is appreciated... thanks in advance frnds...
    Last edited by pinkslove; 10-12-2011 at 11:07 AM.

  2. #2
    Junior Member
    Join Date
    Oct 2011
    Posts
    8
    sry frnds... in the above the i have enterd the spelling for function call in addEVnetListener wrongly... both function name and function call are dsip only........

    pls see if u can help me frndss... thanks in advance....

  3. #3
    Will moderate for beer
    Join Date
    Apr 2007
    Location
    Austin, TX
    Posts
    6,801
    Are you drunk, dyslexic, or disabled? Please write in proper English. Post your code in [code] tags.

    Not only did you misspell "dsip" in the addEventListener call, your dsip function has invalid lines. You must include "var" when declaring a variable. The line immediately after that is missing a closing ")". Did you get an error message?

    s is not an instance name. s is a variable of type s1 which refers to an instance of s1.

    Where do you put s on the display? I do not see an addChild(s) line.

  4. #4
    Junior Member
    Join Date
    Oct 2011
    Posts
    8
    hiii,thank you for your kind help... nice to meet you.... and very sorry for troubling you with my english.. thanks for bearing that.....

    actually i left the var here.. in my original code i have declared loader lik tis

    var loader1:Loader = new Loader();
    here.. i bymistake left it...

    actually my entire code is like this..

    var s : s1 = new s1();
    function imp (event:MouseEvent):void{
    addChild(s);// displaying MovieClip in library
    }
    m.addEventListener(MouseEvent.CLICK,imp);
    where m is the instance name of the button i have in stage...
    and one more thing... if s is not the instance name of s1 then please tell me how can we create the instance name in actionscript3....... thanks in advance friend....

  5. #5
    Will moderate for beer
    Join Date
    Apr 2007
    Location
    Austin, TX
    Posts
    6,801
    Again, please use [code] tags to post your code.

    You could set s's instance name by assigning a value to its name property, but there's no reason to do so.
    Code:
    s.name = "someName";
    So, what ARE you seeing when you click on the movieclip? Do you get an error message?
    If you put a trace statement in dsip, do you see it when you click?

  6. #6
    Junior Member
    Join Date
    Oct 2011
    Posts
    8
    hiii,
    thanks for the help,

    when i wrote those codings i did not get any error message.... when i clicked the button the MovieClip did not appear..
    how can i make my MovieClip clickable now? so that when i click themovieclip the bitmap will appear on stage... pls help me out with this friend.... thanks in advance friend...

  7. #7
    Will moderate for beer
    Join Date
    Apr 2007
    Location
    Austin, TX
    Posts
    6,801
    Please do not send me a private message each time you reply. I already get notified of the reply in the thread.

    You've changed your story again. Earlier you said the MovieClip did appear, but clicking it did nothing. Now you say it didn't appear. But you're still asking how to make it clickable. How do you know it's not, if it doesn't appear?

    Put traces in your functions so you can tell if they're being called.

  8. #8
    Junior Member
    Join Date
    Oct 2011
    Posts
    8
    hii ,sorry for disturbing you..actually i was a bit confused the thing is that i have the button displayed if i clcik the button the movieclip appears and if i click the movieclip nothing appears on screen.... sry by the time i was replying you i was like very tensed and typed the reply wrongly... i dont get any sort of errors..
    wat shall i do now?? sry for disturbing you friend....
    thanks in advance...

  9. #9
    Will moderate for beer
    Join Date
    Apr 2007
    Location
    Austin, TX
    Posts
    6,801
    For the third time: put a trace statement in your dsip function. That will tell you if it's being called. It probably is. So the problem is probably that you are loading the wrong thing. You can put listeners for all the events that loaderinfos throw to see what's going wrong with the load.
    Last edited by 5TonsOfFlax; 10-12-2011 at 02:22 PM. Reason: "For" is not "Fire", swype.

  10. #10
    Junior Member
    Join Date
    Oct 2011
    Posts
    8
    I did like how you said now its working!! thanks friend....

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