Use movie clip event handler function, but not via an event

Let's say I have the following code:
var initObj = new Object();
initObj.mood = "happy";
mc = attachMovie("mcBox","instBox",100,initObj);
mc.onPress = boxPress;
function boxPress() {
trace("Box mood: " + this.mood);
Now, let's say there are times that I want to call boxPress()
other than when the onPress event happens. In other words, I want
to call boxPress() for a movie clip via my AS code, but not when an
onPress event has occurred for that movie clip. Is this possible?
Or is it possible to simulate or force an onPress event for a movie
clip so that the handler function gets called for that movie clip?

addEventListener only works with components in ActionScript 2
"workingonasite" <[email protected]> wrote
in message
news:f1vu8r$92i$[email protected]..
> So I am trying to get my head around event Listeners.
When I use this
> example
> on a button it works fine:
>
> but when I add the same listener to a movie Clip on the
stage with an
> instance
> name of "box", it does not work. Is there something
basic I am missing?
>
>
>
> var buttonListener:Object = new Object();
> buttonListener.click = function(eventObj:Object) {
> trace("click");
> };
> mybutton.addEventListener("click", buttonListener);
>

Similar Messages

  • Passing data to event handler function

    I am trying to pass value to the event handler function but I
    am getting the following error. Can someone please tell me what I
    am doing wrong?
    1067: Implicit coercion of a value of type void to an
    unrelated type function
    here is the code
    private function myClickListener(myid:int):void{
    Alert.show("The button was clicked");
    public function handleStringResult(event:ResultEvent):void{
    catInfo = event.result as ArrayCollection;
    for each(var o:Object in catInfo){
    var b:Button = new Button();
    b.label = o.FILLCOLOR;
    b.id=o.CATID;
    b.setStyle("fillColors",['#'+o.FILLCOLOR,'#'+o.FILLCOLOR]);
    b.setStyle("color","#FFFFFF");
    b.setStyle("fontFamily","Arial");
    b.setStyle("fontSize",8);
    b.setStyle("textRollOverColor", "red");
    b.addEventListener(MouseEvent.CLICK,
    myClickListener(o.CATID));
    myvbox.addChild(b);
    ]]>

    "Merlyn MM" <[email protected]> wrote in
    message
    news:[email protected]...
    > Sure, Here is the code. I am very new to flex and if my
    code doesn't make
    > sense
    > then please let me know the correct way to do this. I
    really appreciate
    > you
    > taking time!
    >
    > <?xml version="1.0" encoding="utf-8"?>
    > <mx:Application xmlns:mx="
    http://www.adobe.com/2006/mxml"
    > layout="absolute"
    > backgroundColor="#FFFFFF"
    > initialize="myService.getcategories.send()">
    > <mx:WebService id="myService"
    > useProxy="false"
    > wsdl="
    http://devsite/rc/category.cfc?wsdl"
    > showBusyCursor="true">
    > <mx:operation name="getcategories"
    > result="handleStringResult(event)"
    > fault="Alert.show(event.fault.message)"/>
    > <mx:operation name="getsubcounties"
    result="handleStringResult(event)"
    > fault="Alert.show(event.fault.message)"/>
    > <mx:request>CATID</mx:request> //need to
    pass category ID here
    > </mx:operation>
    > </mx:WebService>
    >
    > <mx:Script>
    > <![CDATA[
    > import mx.collections.ArrayCollection;
    > import mx.rpc.events.ResultEvent;
    > import mx.rpc.events.FaultEvent;
    > import mx.controls.Alert;
    > import mx.controls.Button;
    >
    > [Bindable]
    > private var catInfo:ArrayCollection;
    >
    > private function myClickListener(myId:String):void{
    >
    > myService.getcounties.send() // I need to send catid
    here to the
    > webservice
    > }
    >
    >
    > public function
    handleStringResult(event:ResultEvent):void{
    > catInfo = event.result as ArrayCollection;
    > for each(var o:Object in catInfo){
    > var b:Button = new Button();
    > b.label = o.FILLCOLOR;
    > b.id='btn'+o.CATID;
    >
    >
    b.setStyle("fillColors",['#'+o.FILLCOLOR,'#'+o.FILLCOLOR]);
    > b.setStyle("color","#FFFFFF");
    > b.setStyle("fontFamily","Arial");
    > b.setStyle("fontSize",8);
    > b.setStyle("textRollOverColor", "red");
    > b.addEventListener("click", myClickListener);
    > myvbox.addChild(b);
    > }
    > }
    > ]]>
    > </mx:Script>
    I'd change it to this:
    private function myClickListener(e:Event):void{
    //I don't see where you're using the ID, but to get it,
    //use this code:
    var myID = e.currentTarget.data;
    myService.getcounties.send() // I need to send catid here to
    the
    webservice
    public function handleStringResult(event:ResultEvent):void{
    catInfo = event.result as ArrayCollection;
    for each(var o:Object in catInfo){
    var b:Button = new Button();
    b.label = o.FILLCOLOR;
    //note that you couldn't have used your ID
    //as a "handle" to anything, so I replaced
    //that logic with something you _could_ use
    b.data=o.CATID;
    b.setStyle("fillColors",['#'+o.FILLCOLOR,'#'+o.FILLCOLOR]);
    b.setStyle("color","#FFFFFF");
    b.setStyle("fontFamily","Arial");
    b.setStyle("fontSize",8);
    b.setStyle("textRollOverColor", "red");
    b.addEventListener("click", myClickListener);
    myvbox.addChild(b);
    You could also use a Repeater and set this up in MXML.
    HTH;
    Amy

  • I am using version iPhoto'11. Since I installed this version I experience some difficulties. After importation of pictures I can see the pictures under Library/Pictures but not under Library/Events. However I can see the event and the number of pictures.

    Hello,
    I am using version iPhoto'11. Since I installed this version I experience some difficulties. After importation of pictures I can see the pictures under Library/Pictures but not under Library/Events. However I can see the event with the event title, the number of pictures and the pictures itselve as small thumbnails. BUt ounce I want to open the event to see the pictures in full screen the event title annouces 0 pictures and no pictures are visble anymore to mee. I have checked if the pictures are marked as hidden and this is not the case. What's going wrong. All the other events are visible in a normal way.
    The albums with the same pictures into them are visible.
    Thanks for your help,
    Raf

    Make a temporary, duplicate copy of the library and try the two fixes below in order as needed:
    Fix #1
    1 - delete  the iPhoto preference file, com.apple.iPhoto.plist, that resides in your Home/Library/Preferences folder. 
    2 - delete iPhoto's cache files that are located in your Home/Library/Caches/com.apple.iPhoto folder. 
    3 - reboot, launch iPhoto and try again.
    NOTE: If you're moved your library from its default location in your Home/Pictures folder you will have to point iPhoto to its new location when you next open iPhoto by holding the the Option key.  You'll also have to reset the iPhoto's various preferences.
    Fix #2
    Launch iPhoto with the Command+Option keys depressed and follow the instructions to rebuild the library. Select options #1, #2 and #6.
    Click to view image full size
    OT

  • I can't remove event handler functions

    Hi guys!
    Please help to remove event handler functions of a
    FLVPlaback. I add some functions for an FLVPlaback instance and
    that's why doesn't work the control panel (play button, pause
    button and so on) Here is a link:
    http://sexaid.fw.hu/vg/vg.html
    to understand simply the problem. thx every ideas!

    I would prefer not to announce the URL to the world on this forum, but I can say the old website still starts with the standard .Mac URL http://web.mac.com/username/iWeb and the new one until I set up to use my own domain was the same I believe.
    Empty the Cache has no effect I can still go to the URL and explore the various pages.
    I do not think that the .Mac websites are hosted from the iDisk location as I have defiantly deleted them from my iDisk and I have rechecked every file in the iDisk for any sign of them also my new iWeb '08 website never appeared in the iDisk. I would presume that the .Mac websites are hosted from a particular location on the Apple servers and I need to some how pull them off separately because publishing another new site with iWeb '08 has just left me with two sites and the old one remains and does not exist in iWeb '08 so I can unpublish it.

  • Movie Clips as buttons – ignoring my stop actions and event listeners

    Ok, so I think I am hear with the proper linked files to show you guys! Pretty much learning everything, so forgive my ignorance thus far!
    Anyway, I am just trying to figure out movie clips as buttons, and have been following along on Lynda.com – however, I seem to be doing these things right, but when i test my movie, the button just loops regardless of rollovers or stop actions.
    You can check this address www.midnyc.com to see the failed anim, and you should be able to import it as well. Here is my coding:
    function rollover (e:EVENT){
        myBtn.gotoAndPlay ("in");
    myBtn.addEventListener (MouseEvent.MOUSE_OVER, rollover);
    function rollout (e:EVENT){
        myBtn.gotoAndPlay ("out");
    myBtn.addEventListener (MouseEvent.MOUSE_OUT, rollout);
    thank you in advance for your help. And to KGLAD, thanks for recommending how to post a bit better! Since I never had links etc... sorry about that.

    Do you get any kind of error messages?  Normally if there's a coding error, movieclips and other things go haywire.
    For you event handler functions, try specifying the event that matches the listener event...
    function rollout (e:MouseEvent){
    I think "EVENT" would be wrong anyways... "Event" would be correct

  • Pause & Play Animation When i'm using movie clips- filters

    Pause & Play Animation When i am using movie clips-
    filters
    Graphic and movieclips are using for my animation
    When i Press the pause the movieclip animation not stopped.
    Any way to apply the filters on graphic
    I want to apply the filters for particular graphics or movie
    clips. with navigational button working.
    Please help me.
    Thanks
    S.Satheesh Kumar

    Audio on the timeline, especially stream, tends to play very reliably. Is this project under any NDA or can you provide a FLA to examine? Let me know if you want to private message it and I'll shoot you a message.
    What version of Flash Player are you targeting and is this AS2 or AS3?

  • What type of movie clips are handled by the ipad? I have shot a movie clip with my canon camera and the file is .AVI.  will this load onto ipad?

    what type of movie clips are handled by the ipad? I have shot a movie clip with my canon camera and the file is .AVI.  will this load onto ipad?

    Per http://www.apple.com/ipad/specs/
    AirPlay Mirroring to Apple TV (2nd and 3rd generation) at 720p
    AirPlay video streaming to Apple TV (3rd generation) at up to 1080p and Apple TV (2nd generation) at up to 720p
    Video mirroring and video out support: Up to 1080p with Apple Digital AV Adapter or Apple VGA Adapter (adapters sold separately)
    Video out support at 576i and 480i with Apple Composite AV Cable (cable sold separately)
    Video formats supported: H.264 video up to 1080p, 30 frames per second, High Profile level 4.1 with AAC-LC audio up to 160 Kbps, 48kHz, stereo audio in .m4v, .mp4, and .mov file formats; MPEG-4 video up to 2.5 Mbps, 640 by 480 pixels, 30 frames per second, Simple Profile with AAC-LC audio up to 160 Kbps per channel, 48kHz, stereo audio in .m4v, .mp4, and .mov file formats; Motion JPEG (M-JPEG) up to 35 Mbps, 1280 by 720 pixels, 30 frames per second, audio in ulaw, PCM stereo audio in .avi file format

  • How to use the dll  created by c++ but not write a jni wrapper around

    how to use the dll created by c++ but not write a jni wrapper around through a java program. now I can't access that dll like this directly from java.

    Your question is unclear. (You haven't said what dll you are talking about.)
    But:
    If you are talking about an existing dll, then the only alternative to writing a wrapper is to use one of the wrapper generators floating around. Do a search on JACE.
    If you are talking about a dll you are writing, then run jah and get the interface to match java right away; then you won't have to write a wrapper.

  • [svn:osmf:] 17548: Remove left-over event handler, which could trigger an unnecessary event if a player loaded plugins through the config XML file and manually  (e.g.

    Revision: 17548
    Revision: 17548
    Author:   [email protected]
    Date:     2010-09-01 14:09:14 -0700 (Wed, 01 Sep 2010)
    Log Message:
    Remove left-over event handler, which could trigger an unnecessary event if a player loaded plugins through the config XML file and manually (e.g. for static plugins).
    Modified Paths:
        osmf/trunk/libs/samples/ChromeLibrary/org/osmf/chrome/configuration/PluginsParser.as

    Remember that Arch Arm is a different distribution, but we try to bend the rules and provide limited support for them.  This may or may not be unique to Arch Arm, so you might try asking on their forums as well.

  • My mac mini will connect via airport but not via ethernet.

    I have had a mac mini for several months which I connect via ethernet because it is in a part of my house where the wireless signal is poor. I changed ISP and now I can connect to the router wirelessly but not via ethernet. This doesn't seem to be a problem with the network as the connection works when I connect it to my mac book. Firewall is turned off. There were no major changes to the router settings other than changing the ISP login codes.
    Any ideas? Is this a configuration issue or a hardware problem?

    Hi Mick,
    If your router only supports 10/100 ethernet then it is possible that the auto-detect feature is not working properly to adjust to that speed. The mini has a Gigabit ethernet port. The OS by default sets the port to automatically negotiate the rate but it does not always work and the result is the problem you are having.
    To fix it you wlll have to manually set the rate to 100.
    To do this, open your system preferences, Select Network. Highlight the ethernet port on the sidebar, click the advanced button. Click on the Ethernet Tab, set the configure pop-up menu item to 100baseTX and click the ok button. If all works out you should see that the Ethernet port icon should turn green.
    Hope this helps.

  • A website will open via wifi but not via 3G. Is this a setting on the iPad?

    A website will open via wifi but not via 3G. Is this a setting on the iPad?

    Probably not.  How's your 3G connection?  I ask because I've had issues when the 3G connection isn't strong.  Same with WiFi too, actually.

  • Using iMessage is it for free if not via wifi?

    Using iMessage is it for free if not via wifi?

    There is no specific charge for using iMessage. However, if you are using via 3g4g connection, then yes, it will count towards your data plan limits.

  • Need FB app, but not via the cloud

    Hi. I recently upgraded to the iPhone 6 and I am having trouble loading the Facebook app onto it. I had the app on my previous iPhone, so it is stored in my cloud. I no longer have the old email address to access the version on Facebook that is in my cloud, so I am needing to load the app from someplace other than my cloud. I am not given the option to do this when I go in and try to load the app. I have temporarily worked around this issue by accessing Facebook from the web, but it is not the same as logging in through the app itself, and does not offer any sort of notification feature when doing it this way. Does anyone know how I can upload Facebook onto my new phone but NOT via the cloud?

    I am not able to download it by just going to the app store. It indicates it is in my cloud, and that is where it is pulling it from. Specifically, the issue I run into when I download it is that when it asks me to enter my password, it is asking for it under my previous account, which I no  longer have an email address for since the account has been deleted. Since the old data in the cloud has my old email address, it will not allow me to access it.

  • Why do headings turn Chinese when I access my email via Firefox but not via Internet Explorer?

    Why do headings turn Chinese when I access my email via Firefox but not via Internet Explorer?

    hello, this is a displaying flaw caused the mcafee site advisor extension - please try to disable or remove that in case you have it present until there is an update by mcafee that can fix the problem.
    http://service.mcafee.com/faqdocument.aspx?id=TS100162
    https://community.mcafee.com/thread/76071

  • Help with some movie clips and an function...

    Hi all..
    I`m having trouble with an function used to animate two movie
    clips....
    I want to use the function like this " fSwitch("movie1",
    "movie2"); "
    I`ve checked to see if I had typoes but I don`t and the
    scripting looks good to me...
    In spite of this fact , when I test the code or movie i get
    this erros :
    **Error** Scene=Scene 1, layer=Layer 1, frame=1:Line 32:
    There is no property with the name '_x'.
    sItem2._x = 10;
    **Error** Scene=Scene 1, layer=Layer 1, frame=1:Line 33:
    There is no property with the name '_y'.
    sItem2._y = 10;
    **Error** Scene=Scene 1, layer=Layer 1, frame=1:Line 34:
    There is no property with the name '_xscale'.
    sItem2._xscale = 10;
    **Error** Scene=Scene 1, layer=Layer 1, frame=1:Line 35:
    There is no property with the name '_yscale'.
    sItem2._yscale = 10;
    **Error** Scene=Scene 1, layer=Layer 1, frame=1:Line 36:
    There is no property with the name '_alpha'.
    sItem2._alpha = 0;
    **Error** Scene=Scene 1, layer=Layer 1, frame=1:Line 37:
    There is no property with the name '_y'.
    while(sItem2._y <= Stage.height/2 -1) {
    **Error** Scene=Scene 1, layer=Layer 1, frame=1:Line 38:
    There is no property with the name '_alpha'.
    if(sItem2._alpha <= 97) {
    **Error** Scene=Scene 1, layer=Layer 1, frame=1:Line 39:
    There is no property with the name '_alpha'.
    sItem2._alpha += 3;
    **Error** Scene=Scene 1, layer=Layer 1, frame=1:Line 40:
    There is no property with the name '_alpha'.
    sItem1._alpha -= 3;
    **Error** Scene=Scene 1, layer=Layer 1, frame=1:Line 42:
    There is no property with the name '_x'.
    sItem2._x +=2;
    **Error** Scene=Scene 1, layer=Layer 1, frame=1:Line 43:
    There is no property with the name '_y'.
    sItem2._y +=1;
    **Error** Scene=Scene 1, layer=Layer 1, frame=1:Line 44:
    There is no property with the name '_x'.
    sItem1._x +=2;
    **Error** Scene=Scene 1, layer=Layer 1, frame=1:Line 45:
    There is no property with the name '_y'.
    sItem1._y +=1;
    **Error** Scene=Scene 1, layer=Layer 1, frame=1:Line 48:
    There is no property with the name '_y'.
    if(sItem2._y >=98) {
    **Error** Scene=Scene 1, layer=Layer 1, frame=1:Line 50:
    There is no property with the name '_xscale'.
    sItem2._xscale +=1;
    **Error** Scene=Scene 1, layer=Layer 1, frame=1:Line 51:
    There is no property with the name '_yscale'.
    sItem2._yscale +=1;
    **Error** Scene=Scene 1, layer=Layer 1, frame=1:Line 53:
    There is no property with the name '_xscale'.
    if(sItem2._xscale >= 100) {
    **Error** Scene=Scene 1, layer=Layer 1, frame=1:Line 58:
    There is no property with the name '_xscale'.
    sItem1._xscale -=1;
    **Error** Scene=Scene 1, layer=Layer 1, frame=1:Line 59:
    There is no property with the name '_yscale'.
    sItem1._yscale -=1;
    **Error** Scene=Scene 1, layer=Layer 1, frame=1:Line 61:
    There is no property with the name '_xscale'.
    if(sItem1._xscale <=10) {
    Total ActionScript Errors: 20 Reported Errors: 20
    Please help me out :-<
    The code :

    sItem2 is a string and strings don't have _x etc properties.
    "movie1" should be a movieclip, not a string when passed to
    fSwitch() and fSwtich parameter typing should be changed. or
    convert "movie1" into a movieclip in fSwitch()
    to remedy the issue with sItem2, use a reference to your
    movieclip created by attachMovie().
    for example:

Maybe you are looking for

  • Where do i put movies on my mac so i can watch them on AppleTV

    I have uploaded some movies onto my Mac.  I'd like to watch them on my large screen TV via AppleTV.   Where on my Mac should I put the movies so that I can access them using AppleTV?

  • Crashing on mac os x

    whenever i try to add a effect to the audio, the program freezes then crashes.

  • Loading program for pricing conditions

    Hi, Can anyone guide me in writing the code for Loading Condition records in Vk11, either BAPI or BDC. <<removed by moderator>> Thank you

  • Title/description/keywords

    i keep on having problems with my title, description & keyword. this is the beginning of my html code (generated with dreamweaver8): <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" " http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.

  • Kodak Zi8 pocket videocamera

    I recently purchased a Kodak Zi8 pocket videocamera.  The videocamera can record in 1080 p; 720p at 60fps; 720p; and WVGA.  I was trying the camcorder out and took some short videos at 1080p.  The videocamera comes with some basic software to create