Converting AS3 to AS2, mouse event

Does anyone know how to convert this code to AS2, I need it to work with my AS2 component:
button_instance.addEventListener(MouseEvent.CLICK,loadNewXML)
button_instance2.addEventListener(MouseEvent.CLICK,loadNewXML)
function loadNewXML(e:MouseEvent):void{
switch(e.target)
case button_instance:
  myGallery.contentXML = "content.xml";
break;
case button_instance2:
  myGallery.contentXML = "yourNewXmlLocation2.xml";
break;
The error that I'm getting is The class or interface 'MouseEvent'could not be loaded (line 4)
and '{' expected (line 6)

kglad wrote:
try:
button_instance.onRelease = loadNewXML;
button_instance2.onRelease = loadNewXML;
function loadNewXML():Void{
switch(this._name){
case "button_instance":
  myGallery.contentXML = "content.xml";
break;
case "button_instance2":
  myGallery.contentXML = "yourNewXmlLocation2.xml";
break;

Similar Messages

  • Converting AS3 to AS2

    Does anyone know how to translate this code into AS2? My client can't support AS3.
    var exitTimer:Timer = new Timer(15000, 1);
    exitTimer.addListener(TimerEvent.TIMER, jump);
    function jump(event:TimerEvent):void {
        gotoAndStop("Scene 1")
    exitTimer.start();
    Thank you!

    I put the wrong script in. This is the one I'm trying to convert from AS3 to AS2. Do I still use the setTimeout function or is the getTimer function more appropriate?
    var exitTimer:Timer = new Timer(15000, 1);
    exitTimer.addListener(TimerEvent.TIMER, jump);
    function jump(event:TimerEvent):void {
        navigateToURL(new URLRequest("http://www.url.com"));
    exitTimer.start();

  • AS3 code for Mouse Event

    Hi,
    I had uploaded jpeg file onto the stage using
    File->Import.
    Now, how to access the mouse-events using AS3.0?
    i.e., when we click with mouse on the stage
    it should display the x and y co-ordinates of the point
    being clicked.
    These x and y coordinates must be displayed in text-boxes
    provided down on the same stage.
    Please reply me

    You can do show/hide movieclip on mouseover. get your box
    position and assign to the popup (tooltip movieclip).
    see this...
    not tested. but it should work.
    import flash.events.MouseEvent;
    function showClip(evt:MouseEvent) {
    tooltips.x = evt.target.x + evt.target.width;;
    tooltips.y = evt.target.y - evt.target.height;
    tooltips.visible = true
    function hideClip(evt:MouseEvent) {
    tooltips.visible = false;
    box.addEventListener(MouseEvent.MOUSE_OVER, showClip);
    box.addEventListener(MouseEvent.MOUSE_OUT, hideClip);
    I assume you'll create two movieclips named: box and tooltips

  • How Can I convert AS3 in AS2?

    Hi,
    I have following script in AS3 & I want it in AS2... is it possible?
    Pls help.....
    package
        import flash.events.Event;
        import flash.events.MouseEvent;
        import flash.display.MovieClip;
        import gs.TweenLite;
        public class Accordion extends MovieClip
            var speed:Number = 1;
            public function Accordion()
                tour_mc.addEventListener(MouseEvent.MOUSE_OVER, overHandler, false, 0, true);   
                front_mc.addEventListener(MouseEvent.MOUSE_OVER, overHandler, false, 0, true);
                resta_mc.addEventListener(MouseEvent.MOUSE_OVER, overHandler, false, 0, true);
                inv_mc.addEventListener(MouseEvent.MOUSE_OVER, overHandler, false, 0, true);           
                wd_mc.addEventListener(MouseEvent.MOUSE_OVER, overHandler, false, 0, true);
                fd_mc.addEventListener(MouseEvent.MOUSE_OVER, overHandler, false, 0, true);
            protected function overHandler(event:MouseEvent):void
                if(event.target == tour_mc)
                    TweenLite.to(tour_mc, speed, { x:0, y:0 } );
                    TweenLite.to(front_mc, speed, { x:610, y:0 } );
                    TweenLite.to(resta_mc, speed, { x:640, y:0 } );
                    TweenLite.to(inv_mc, speed, { x:670, y:0 } );
                    TweenLite.to(wd_mc, speed, { x:700, y:0 } );
                    TweenLite.to(fd_mc, speed, { x:730, y:0 } );
                else if(event.target == front_mc)
                    TweenLite.to(tour_mc, speed, { x:0, y:0 } );
                    TweenLite.to(front_mc, speed, { x:30, y:0 } );
                    TweenLite.to(resta_mc, speed, { x:640, y:0 } );
                    TweenLite.to(inv_mc, speed, { x:670, y:0 } );
                    TweenLite.to(wd_mc, speed, { x:700, y:0 } );
                    TweenLite.to(fd_mc, speed, { x:730, y:0 } );
                else if(event.target == resta_mc)
                    TweenLite.to(tour_mc, speed, { x:0, y:0 } );
                    TweenLite.to(front_mc, speed, { x:30, y:0 } );
                    TweenLite.to(resta_mc, speed, { x:60, y:0 } );
                    TweenLite.to(inv_mc, speed, { x:670, y:0 } );
                    TweenLite.to(wd_mc, speed, { x:700, y:0 } );
                    TweenLite.to(fd_mc, speed, { x:730, y:0 } );
                else if(event.target == inv_mc)
                    TweenLite.to(tour_mc, speed, { x:0, y:0 } );
                    TweenLite.to(front_mc, speed, { x:30, y:0 } );
                    TweenLite.to(resta_mc, speed, { x:60, y:0 } );
                    TweenLite.to(inv_mc, speed, { x:90, y:0 } );
                    TweenLite.to(wd_mc, speed, { x:700, y:0 } );
                    TweenLite.to(fd_mc, speed, { x:730, y:0 } );
                else if(event.target == wd_mc)
                    TweenLite.to(tour_mc, speed, { x:0, y:0 } );
                    TweenLite.to(front_mc, speed, { x:30, y:0 } );
                    TweenLite.to(resta_mc, speed, { x:60, y:0 } );
                    TweenLite.to(inv_mc, speed, { x:90, y:0 } );
                    TweenLite.to(wd_mc, speed, { x:120, y:0 } );
                    TweenLite.to(fd_mc, speed, { x:730, y:0 } );
                else if(event.target == fd_mc)
                    TweenLite.to(tour_mc, speed, { x:0, y:0 } );
                    TweenLite.to(front_mc, speed, { x:30, y:0 } );
                    TweenLite.to(resta_mc, speed, { x:60, y:0 } );
                    TweenLite.to(inv_mc, speed, { x:90, y:0 } );
                    TweenLite.to(wd_mc, speed, { x:120, y:0 } );
                    TweenLite.to(fd_mc, speed, { x:150, y:0 } );
    Thanks in advance

    Here is a basic outline of how you could proceed.  I do not include the class nomenclature nor all of the buttons.
    tour_mc.onRollOver = front_mc.onRollOver = overHandler; // add in the rest of the mc's
    function overHandler(){
       if(this == tour_mc){
           trace("do tweens for tour_mc");
       } else if(this == front_mc){
           trace("do tweens for front_mc");
       } // and so on for the rest of the mc's

  • AS3 Tween on mouse event

    Someone in another forum posted some code samples
    demonstrating their use of tweens in AS3, which I had been having a
    lot of trouble figuring out. The way it worked originally was a
    little different -- I've tinkered a bit by putting the tween
    functions in a separate Tweener class and made it so it accepts
    whatever display object is passed to it. I confess I wasn't
    completely sure of what I was doing, but it basically works.
    The only problem is that I would like the circle and
    textfield to tween only when clicked on. I don't know how to do
    this. I figure it boils down to writing
    _circle.addEventListener(MouseEvent.MOUSE_DOWN,....) and
    _text.addEventListener(MouseEvent.MOUSE_DOWN, tweenerIt) in such a
    way that they are the triggers, but it's beyond me.
    It must be very simple, but I don't get it. Could someone
    please explain? Just so you will have an idea of what I'm talking
    about I've set it up so that the tweens occur as soon as the circle
    and textfield are created.
    package
    import mx.effects.*;
    import flash.display.*;
    import flash.events.*;
    import mx.effects.easing.*;
    import flash.text.TextField;
    import com.Tweener;
    public class TweenTest extends Sprite {
    private var _circle:Sprite;
    private var _text:TextField;
    function TweenTest() {
    stage.frameRate = 31;
    init();
    private function init():void {
    _circle = makeCircle();
    _text = makeTextField();
    var myTween:Tweener = new Tweener(_text, 40, 300, 150, 100,
    4000);
    var myTween2:Tweener = new Tweener(_circle, 0, 60, 300, 200,
    8000);
    // don't know what to put here...
    //_circle.addEventListener(MouseEvent.MOUSE_DOWN,
    tweenerIt);
    //_text.addEventListener(MouseEvent.MOUSE_DOWN, tweenerIt);
    private function tweenerIt():void {
    // don't know what to put here...
    private function makeCircle():Sprite {
    var s:Sprite = new Sprite();
    s.graphics.beginFill(0x660000);
    s.graphics.drawCircle(20, 20, 20);
    addChild(s);
    return s;
    private function makeTextField():TextField {
    var t:TextField = new TextField();
    t = new TextField();
    t.text = "Hello";
    t.x = 20;
    t.y = 60;
    addChild(t);
    return t;
    package com
    import mx.effects.*;
    import flash.display.*;
    import flash.events.*;
    import mx.effects.easing.*;
    public class Tweener extends Sprite {
    private var _target:DisplayObject;
    private var _target_dest_x:Number;
    private var _target_dest_y:Number;
    private var _target_start_x:Number;
    private var _target_start_y:Number;
    private var _duration:Number;
    public function Tweener(target:DisplayObject,
    target_start_x:Number, target_start_y:Number, target_dest_x:Number,
    target_dest_y:Number, duration:Number) {
    _target = target;
    _target_dest_x = target_dest_x;
    _target_dest_y = target_dest_y;
    _target_start_x = target_start_x;
    _target_start_y = target_start_y;
    _duration = duration;
    tweenMe();
    private function updateTween(vals:Array):void {
    _target.x = vals[0];
    _target.y = vals[1];
    private function endTween(vals:Array):void {
    trace ("ending coordinates: " + vals);
    private function tweenMe(/*e:Event*/):void {
    var myTween:Tween = new Tween(_target, [_target_start_x,
    _target_start_y], [_target_dest_x, _target_dest_y], _duration, 31);
    myTween.easingFunction = Elastic.easeOut;
    myTween.setTweenHandlers(updateTween, endTween);
    Fingers

    You can do show/hide movieclip on mouseover. get your box
    position and assign to the popup (tooltip movieclip).
    see this...
    not tested. but it should work.
    import flash.events.MouseEvent;
    function showClip(evt:MouseEvent) {
    tooltips.x = evt.target.x + evt.target.width;;
    tooltips.y = evt.target.y - evt.target.height;
    tooltips.visible = true
    function hideClip(evt:MouseEvent) {
    tooltips.visible = false;
    box.addEventListener(MouseEvent.MOUSE_OVER, showClip);
    box.addEventListener(MouseEvent.MOUSE_OUT, hideClip);
    I assume you'll create two movieclips named: box and tooltips

  • Converting AS3 to AS2. Some movieclip buttons not working.

    25 movieclip buttons in frame 126 maintimeline. Buttons are on top layer above all other content.
    Buttons 1_1, 2_1, 3_1, 4_1, and 5_1 work. All buttons have correct instance name. The buttons are in a 5x5 grid. Hence the naming convention of column_row. So all row 1 buttons are working. Do not get hand cursor over any of the other buttons. This is totally baffling. I am using Flash CS4. The file is saved as CS3 and the publish settings are AS2, Flash player 8.
    Here is the AS for frame 126.
    stop();
    trace("tScore = "+tScore);
    trace("i = "+i);
    if (i == 0) {
        i++;
    this.podium.signin.unloadMovie();
    videoBtn1_1.onRelease = function() {
        gotoAndStop(127);
        videoBtn1_1.play();
    videoBtn2_1.onRelease = function() {
        gotoAndStop(127);
        videoBtn2_1.play();
    videoBtn3_1.onRelease = function() {
        gotoAndStop(127);
        videoBtn3_1.play();
    videoBtn4_1.onRelease = function() {
        gotoAndStop(127);
        videoBtn4_1.play();
    videoBtn5_1.onRelease = function() {
        gotoAndStop(127);
        videoBtn5_1.play();
    this.videoBtn1_2.onRelease = function() {
        gotoAndStop(127);
        videoBtn1_2.play();
    videoBtn2_2.onRelease = function() {
        gotoAndStop(127);
        videoBtn2_2.play();
    videoBtn3_2.onRelease = function() {
        gotoAndStop(127);
        videoBtn3_2.play();
    videoBtn4_2.onRelease = function() {
        gotoAndStop(127);
        videoBtn4_2.play();
    videoBtn5_2.onRelease = function() {
        gotoAndStop(127);
        videoBtn5_2.play();
    videoBtn1_3.onRelease = function() {
        gotoAndStop(127);
        videoBtn1_3.play();
    videoBtn2_3.onRelease = function() {
        gotoAndStop(127);
        videoBtn2_3.play();
    videoBtn3_3.onRelease = function() {
        gotoAndStop(127);
        videoBtn3_3.play();
    videoBtn4_3.onRelease = function() {
        gotoAndStop(127);
        videoBtn4_3.play();
    videoBtn5_3.onRelease = function() {
        gotoAndStop(127);
        videoBtn5_3.play();
    videoBtn1_4.onRelease = function() {
        gotoAndStop(127);
        videoBtn1_4.play();
    videoBtn2_4.onRelease = function() {
        gotoAndStop(127);
        videoBtn2_4.play();
    videoBtn3_4.onRelease = function() {
        gotoAndStop(127);
        videoBtn3_4.play();
    videoBtn4_4.onRelease = function() {
        gotoAndStop(127);
        videoBtn4_4.play();
    videoBtn5_4.onRelease = function() {
        gotoAndStop(127);
        videoBtn5_4.play();
    videoBtn1_5.onRelease = function() {
        gotoAndStop(127);
        videoBtn1_5.play();
    videoBtn2_5.onRelease = function() {
        gotoAndStop(127);
        videoBtn2_5.play();
    videoBtn3_5.onRelease = function() {
        gotoAndStop(127);
        videoBtn3_5.play();
    videoBtn4_5.onRelease = function() {
        gotoAndStop(127);
        videoBtn4_5.play();
    videoBtn5_5.onRelease = function() {
        gotoAndStop(127);
        videoBtn5_5.play();

    You can probably reduce all that interaction code to a loop...
    for(i=1; i<6; i++){
       for(k=1; k<6; k++){
          this["videoBtn"+i+"_"+k].onRelease = function() {
              gotoAndStop(127);
              this.play();
    As for why movng the buttons to another layer fixed anything, it will not have mattered.  Whatever fixed the problem will remain a mystery.  It could have been an issue with instance names/frames since you are at frame 126 for some reason.  If you transition the buttons into place, that might be related to what the problem was.

  • How do you convert this code from AS3 to AS2?

    Hi,
    I created some AS3 code that is working perfectly for us.
    However now we need to convert it to AS2 so that it can be Flash
    Player 8 compatible. If it could also be compatible for Flash
    Player 7 that would be ideal but not a requirement.
    Thanks in advance.

    Are you wanting someone to do the conversion for you, or are
    you asking for general tips for doing the conversion yourself?
    i can give you tips:
    have a look at the
    ActionScript
    2.0 Migration page.
    In this you'll find the property conversions eg(going from
    AS3 to AS2). y becomes _y, height becomes _height, scaleX becomes
    _xscale, void becomes Void etc.
    you'll find that events need to be converted, eg.
    particle.addEventListener(Event.ENTER_FRAME,
    animateParticle);
    becomes:
    particle.onEnterFrame=animateParticle;
    the onEnterFrame class doesn't pass an Event parameter to the
    event listener. Instead, the event listener is automatically in the
    scope of the event dispatcher, so instead of 'event.target' you
    will be able to just target 'this'.
    You'll need to use setInterval() instead of the Timer class.
    You'll need to use attachMovie() instead of
    addChild().

  • Converting Flash Remoting AS2 to AS3

    Hello
    I was wondering if someone could direct me to some tutorials
    on Flash Remoting for AS3.
    I would like to convert my old AS2 code over but I can't find
    any information on that.
    Does this functionality still exist for AS3?
    Adam

    See
    http://ssr.riaforge.org/

  • Passing Param to Mouse Event in AS3

    Hello All,
    I want to make a tooltip box , when I mouse over an object it will appear with the object color and some other data
    how can I send the color param and other param to mouse event?
    Thanks in Advance

    Hi,
    Maybe this will help you :-
    http://www.ultrashock.com/forums/actionscript/as3-adding-parameter-to-eventlistener-104729 .html
    http://www.orlandmedia.com/blog/actionscript-3/passing-parameters-to-a-mouseevent-listener /

  • Mouse Events are slow

    Hello everyone,
    I'm currently working on an standard as3 (1024x768) app that
    is running inside a chromeless Air window to take advantage of the
    transparency.
    All my tests where done using windows XP professional and AIR
    1.0 (the same problem existed in beta3).
    The issue I'm having is related with Mouse Events. Somehow
    the events take a lot of time to reach the swf file when the user
    clicks inside the transparent window.
    It's natural that the app runs slower inside a transparent
    window (the framerate drops) but I wasn't expecting the clicks to
    suffer from such delay (it takes sometimes 2-5sec).
    The app is very CPU intensive and the transparencies make it
    worse. Something inside the AIR framework is not dispatching the
    events properly.
    I say this because I tried using the virtualMouse class from
    senocular together with a socket to simulate the mouse clicks and
    that did the trick.
    In conclusion:
    Something in the AIR framework for windows XP is messing up
    the dispatch of the Mouse events when the app is under heavy cpu
    usage inside a chromeless window. I click on the window and it
    takes 1-2sec to receive the click event.
    However when I dispatch the MouseEvent.CLICK myself using
    the virtual mouse class the application immediately receives the
    event.
    I know this is a strange bug and not many people will have
    this problem, but I would like to know from someone with knowledge
    of the runtime why this could be happening.
    Thank you
    Tiago Bilou

    Hello everyone,
    I'm currently working on an standard as3 (1024x768) app that
    is running inside a chromeless Air window to take advantage of the
    transparency.
    All my tests where done using windows XP professional and AIR
    1.0 (the same problem existed in beta3).
    The issue I'm having is related with Mouse Events. Somehow
    the events take a lot of time to reach the swf file when the user
    clicks inside the transparent window.
    It's natural that the app runs slower inside a transparent
    window (the framerate drops) but I wasn't expecting the clicks to
    suffer from such delay (it takes sometimes 2-5sec).
    The app is very CPU intensive and the transparencies make it
    worse. Something inside the AIR framework is not dispatching the
    events properly.
    I say this because I tried using the virtualMouse class from
    senocular together with a socket to simulate the mouse clicks and
    that did the trick.
    In conclusion:
    Something in the AIR framework for windows XP is messing up
    the dispatch of the Mouse events when the app is under heavy cpu
    usage inside a chromeless window. I click on the window and it
    takes 1-2sec to receive the click event.
    However when I dispatch the MouseEvent.CLICK myself using
    the virtual mouse class the application immediately receives the
    event.
    I know this is a strange bug and not many people will have
    this problem, but I would like to know from someone with knowledge
    of the runtime why this could be happening.
    Thank you
    Tiago Bilou

  • Migrate existing code of AS3 to AS2 - URLRequest, URLLoader

    Hi,
    I have written code to read an XML file by using URLRequest and URLLoader in ActionScript 3.0. Code is pasted below. This runs well in AS3.  Problem I am facing is because I wrote this in AS3, I am not able to use the DateChooser component in another part of the flash module because it seems like DateChooser component is not supported in AS3. So I want to migrate my below AS3 code back to AS2.
    **** Code in AS3 (I need help in writing equivalent code in AS2) :-
    var xmlText:XML ;
    var xmlReq:URLRequest = new URLRequest("myFile.xml");
    var xmlLoader:URLLoader = new URLLoader();
    xmlLoader.load(xmlReq);
    xmlLoader.addEventListener(Event.COMPLETE,xmlLoaded);
    function xmlLoaded(event:Event):void
        xmlText = new XML(xmlLoader.data);  
        info_txt.htmlText = xmlText.someTag ;
    **** I cannot use the above as is because, when I change the publish settings from AS3 to AS2, I get following errors -
    The class or interface 'URLRequest' could not be loaded.
    The class or interface 'URLLoader' could not be loaded.
    The class or interface 'Event' could not be loaded.
    Same works well in AS3. What should I do to make this work in AS2 or can anyone direct me in writing an equivalent in AS2.
    Please assist.
    Thanks in advance.
    MG

    parsing is done using the xmlnode methods and properties.  how you parse an xml file (in as2) depends on its structure.  but generally, you use firstChild, nextSibling, childNodes and nodeValue in the appropriate sequence to extact data.  the flash help files have sample code.  for tutorials, check google.
    if you're trying to load a cross-domain xml file, you'll have a cross-domain security issue to deal with.

  • Iocane: poison the rodent (simulate X11 mouse events from keyboard)

    Iocane: the colorless, oderless, tasteless poision that will rid your system of its rodent infestation.  Though no promises about its effectiveness against Rodents Of Unusual Size.
    Iocane simulates mouse events from the keyboard.  Iocane can be passed a few parameters which - ideally - could each have a key binding in your favorite window manager.
    If iocane is called with no parameters it starts in interactive mode (which currently lacks documentation ... hey, I just wrote this this morning).  In interactive mode the directional arrows or h/j/k/l keys move the mouse cursor.  The number keys simulate button presses (1 = left button, 2 = middle, 3 = right).  The page up and page down keys simulate mouse wheel activation.  "q" quits from interactive mode returning any grabbed keys to their normal behavior.  Key bindings are all controlled from a simple rc file.
    Iocane can also be passed a series of commands on the command line or the filename for a script file with a list of iocane commands.  Iocane can also read command from its standard input.
    Iocane is conceptually similar to some functions of xdotool, but iocane should work under any window manager (or no wm at all), is much smaller, and the interactive mode allows for a sequence of many actions without the program having to start up and close down many times in rapid succession.
    Please report bugs or feature requests here.  Iocane is currently 127 lines of C, and it will remain small; in other words, features will only be added if the can be added without substantially increasing resource use.
    EDIT: Version 0.2 is now in the AUR
    Last edited by Trilby (2012-11-03 02:23:15)

    Any arbitrary number of buttons should be easy enough to simulate - provided the Xserver actually responds to events with that button number.  An update I'll push to github tomorrow will include a few changes, including buttons 1-9, but if there is need/desire I could increase that.  Sticking to 1-9 allows for the computationally cheaper hack of converting a string to a number by simple substracting 48 from the value of the first character; numbers greater than 9 would require the use of atoi() or some funky conditionals.  In the grand scheme of things this is fairly trivial, but unless there is a real reason to use more than 9 mouse buttons I'd prefer to keep the lighter code.
    Passing a window name and getting it's coordinates is possible but after considering it I've decided it wouldn't fit well in iocane.  The reason being that to do a half-arsed job of it would be pretty easy.  To do it properly, however, it would take quite a bit of scanning through recursive calls to XQueryTree, polling atoms/wmhints, matching strings, checking for subwindows in the case of reparenting window managers, and a bunch of other nonsense ... all to get two coordinates.
    However iocane will play nicely with any tool that will provide those coordinates from a given window name, so I can imagine and invocation such as the following to move the mouse 10 pixels right and down from the top left of a window - lets call it FlamingSquirrel - and simulate a click there:
    iocane $(cool_app FlamingSquirrel) : move 10 10 : button 1
    Currently that could only be done from a command line invocation, not from a script or interactive session, as it requires shell processing for the command substitution.  I can add support for this type of invocation in scripts and interactive mode as well.  Then all you need to do is find (or write) a program that will give coordinates for a window given a title/name.  I suspect such a program probably exists out there, or if you are comfortable with C, I could give you the starting framework for it as I made something that would have much code in common for another task on these forums (it's in jumpstart.c in the "misc" repo on my github).
    In fact, you could use the following
    xdotool mousemove --window FlamingSquirrel 0 0 && iocane offset 10 10 : button 1
    Though if you are using xdotool anyways, I'm not sure if iocane would serve much of a purpose, unless you just prefer iocane's syntax.
    Last edited by Trilby (2012-11-01 00:21:14)

  • Convert as3 to as3

    Can u please convert as3 to as3
    Code here:
    const DEFAULT_VOLUME:Number                                        = 0.6;
    var intLastVolume:Number                                        = DEFAULT_VOLUME;
    VolumContrl.btnMute.addEventListener(MouseEvent.CLICK, muteClicked);
    VolumContrl.btnUnmute.addEventListener(MouseEvent.CLICK, unmuteClicked);
    VolumContrl.mcVolumeScrubber.btnVolumeScrubber.addEventListener(MouseEvent.MOUSE_DOWN, volumeScrubberClicked);
    VolumContrl.mcVolumeScrubber.x = (52 * DEFAULT_VOLUME) + 341;
    VolumContrl.mcVolumeFill.mcFillRed.width = VolumContrl.mcVolumeScrubber.x - 394 + 52;
    setVolume(DEFAULT_VOLUME);
    function muteClicked(e:MouseEvent):void {
              setVolume(0);
              // update scrubber and fill position/width
              VolumContrl.mcVolumeScrubber.x                                        = 341;
              VolumContrl.mcVolumeFill.mcFillRed.width          = 1;
    function unmuteClicked(e:MouseEvent):void {
              // set volume to last used value
              setVolume(intLastVolume);
              // update scrubber and fill position/width
              VolumContrl.mcVolumeScrubber.x = (53 * intLastVolume) + 341;
              VolumContrl.mcVolumeFill.mcFillRed.width = VolumContrl.mcVolumeScrubber.x - 394 + 53;
    function volumeScrubberClicked(e:MouseEvent):void {
              // set volume scrub flag to true
              bolVolumeScrub = true;
              // start drag
              VolumContrl.mcVolumeScrubber.startDrag(false, new Rectangle(341, 19, 53, 0));
    function mouseReleased(e:MouseEvent):void {
              bolVolumeScrub                    = false;
              bolProgressScrub          = false;
              // stop all dragging actions
              VolumContrl.mcVolumeScrubber.stopDrag();
              // update progress/volume fill
              VolumContrl.mcVolumeFill.mcFillRed.width          = VolumContrl.mcVolumeScrubber.x - 394 + 53;
              // save the volume if it's greater than zero
              if((VolumContrl.mcVolumeScrubber.x - 341) / 53 > 0)
                        intLastVolume = (VolumContrl.mcVolumeScrubber.x - 341) / 53;
    function updateDisplay(e:TimerEvent):void {
    if(bolVolumeScrub) {
                        setVolume((VolumContrl.mcVolumeScrubber.x - 341) / 53);
                        VolumContrl.mcVolumeFill.mcFillRed.width = VolumContrl.mcVolumeScrubber.x - 394 + 53;
    function setVolume(intVolume:Number = 0):void {
              // create soundtransform object with the volume from
              // the parameter
              var sndTransform                    = new SoundTransform(intVolume);
              // assign object to netstream sound transform object
              nsStream.soundTransform          = sndTransform;
              // hides/shows mute and unmute button according to the
              // volume
              if(intVolume > 0) {
                        VolumContrl.btnMute.visible                    = true;
                        VolumContrl.btnUnmute.visible          = false;
              } else {
                        VolumContrl.btnMute.visible                    = false;
                        VolumContrl.btnUnmute.visible          = true;

    Asking someone to do it all for you is a bit much, especially when alot of the changes are basic. You should convert as much of it as you can first then ask for help with the rest.  x,y,visible,width,height (jn AS3) become _x,_y,_visible,_width,_height (in AS2)
    If you look up the startDrag method in AS2 you should be able to deternmine how to change that.
    Since this is more of an AS2 question, and only people looking for help with AS2 would be likely to find it useful, you should post in the AS1/2 forums instead of here.

  • Mouse events don't work on a button from a panel ran in a DLL

    Hi.
    I have a DLL that loads a panel.
    Since it's a DLL I can't do the RunUserInterface() function, because the DLL would be stuck waiting for the panel events.
    I only do the LoadPanel().
    When I click with the mouse on one of the buttons, the pushing down event (simulating the button being pressed) doesn't happen and the callback doesn't run.
    But if I press the tab button until the focus reaches the button and press Enter, the callback of the button is executed.
    An even more interesting aspect is that this happens when I call the DLL on TestStand, but on an application of mine that calls the DLL just for debug everything works fine.
    How can I enable the mouse events?
    Thanks for your help.
    Daniel Coelho
    VISToolkit - http://www.vistoolkit.com - Your Real Virtual Instrument Solution
    Controlar - Electronica Industrial e Sistemas, Lda
    Solved!
    Go to Solution.

    Hello Daniel,
    I got surprised when I read your post, because I am experiencing something almost the same as you do.
    I have a DLL (generated by an .fp instrument driver I wrote) which performs continious TCP communication with the UUT.
    It starts 2 threads, each for reading from one of the 2 different IPs the UUT has.
    Another DLL tests this UUT (with the help of the communication DLL above) by exporting functions to be called by TestStand steps.
    If the second DLL wants to display a CVI panel in order to wait for the user response or displays a popup (MessagePopup, ConfirmPopup, etc), user cannot press the buttons.
    Actually, there is a point your program and mine differ. I call RunUserInterface and the button's callbacks call QuitUserInterface, so the execution continues after a button is pressed. The problem is buttons cannot be pressed. I also tried looping on GetUserEvent  but it did not solve the problem.
    There are 2 findings:
    1. I had a small exe to test my instrument driver DLL and the popups in it worked pretty well (this coincides with Daniel's findings).
    2. We workedaround the problem by shutting down the communication threads in the instrument driver DLL before the popup appears and restrating them afterwards. Although they are separate threads in another DLL, they were somehow blocking user events on another DLL running.
    S. Eren BALCI
    www.aselsan.com.tr

  • Change some code from as3 to as2

    Hi, I want to use as2 because it compatible with my website.
    I want to change some code from as3 to as2
    /////////////////////////////image1//////////////////////////////// if(MovieClip(this.parent).imagetxt.text == "a") {     var imgurl:String = "C:/Users/Thái/Desktop/ls/cotton-1.jpg";     var myrequest:URL = new URL(imgurl);     myloader.scaleContent = true;     myloader.load(myrequest); } /////////////////////////////image2//////////////////////////////// else if(MovieClip(this.parent).imagetxt.text == "b") {     var imgurl2:String = "http://aloflash.com/images/upload/3.jpg";     var myrequest2:URLRequest = new URLRequest(imgurl2);     myloader.scaleContent = true;     myloader.load(myrequest2); }thank you for your support.

    use:
    var myloader:MovieClip=this.createEmptyMovieClip("loader_mc",this.getNextHighestDepth());
    if (MovieClip(this._parent).imagetxt.text == "a") {
        var imgurl:String = "C:/Users/Thái/Desktop/ls/cotton-1.jpg";
        myloader.load(imgurl);
    } else if (MovieClip(this._parent).imagetxt.text == "b") {
        var imgurl2:String = "http://aloflash.com/images/upload/3.jpg
        myloader.load(imgurl2);

Maybe you are looking for