Movieclip isPlaying

I have a library of movieclips (hundreds of them) that i
would like to add control to.
I would like to be able to pause and resume their playback,
but I need to read if the movieclip is stopped before allowing it
to be paused.
I have tried doing a class extension of MovieClip with a
state property. This would normally work, but that would require me
to go through tons of files and extend every movieclip library
item.
What i am trying to do now is redefine the movieClip class
using prototype by adding a state property and a pause function and
setting the state accordingly. I cannot get this to work either.
this is the code that i put in:
MovieClip.prototype.state = 1; //0:stopped; 1:playing;
2:paused;
MovieClip.prototype.stop = function () {
trace(this);
this["state"] = 0;
// super.stop();
MovieClip.prototype.play = function () {
this["state"] = 1;
// super.play();
MovieClip.prototype.pause = function () {
if (this["state"]) {
this.stop();
this["state"] = 2;
thanks for any insight

According to ActionScript reference the property exists. Refer to: MovieClip - Adobe ActionScript® 3 (AS3 ) API Reference

Similar Messages

  • Compiling error from var isPlaying:Boolean = true;

    I need help with correcting a compiling error from the code listed below. The  error reads as follows:
    Scene 1, Layer 'actions', Frame 1, Line 10
    1152: A conflict exists with inherited definition flash.display:MovieClip.isPlaying in namespace public.
    Thanks in advance. Here's my code:
    import flash.events.MouseEvent;
    import flash.geom.Rectangle;
    import flash.events.Event;
    //define constraints to keep thumb inside of bar
    var constraint:Rectangle = new Rectangle (bar.x, bar.y, bar.width-thumb.width, 0);
    var ratio:Number = animatedBug.totalFrames / (bar.width - thumb.width);
    var isPlaying:Boolean = true;
    //make the movie clip behave like a button
    thumb.buttonMode = true;
    durr.text = String(animatedBug.totalFrames);
    animatedBug.stop();
    thumb.addEventListener(MouseEvent.MOUSE_DOWN, handleDown);
    stage.addEventListener(MouseEvent.MOUSE_UP, handleUp);
    addEventListener(Event.ENTER_FRAME, trackPlayback);
    function handleDown(e:MouseEvent):void {
        //pass in the constrain to contain thumb within bar
        e.target.startDrag(false, constraint);
        addEventListener(Event.ENTER_FRAME, trackthumbPos);
        removeEventListener(Event.ENTER_FRAME, trackPlayback);
    function handleUp(e:MouseEvent):void {
        thumb.stopDrag();
        removeEventListener(Event.ENTER_FRAME, trackthumbPos);
        addEventListener(Event.ENTER_FRAME, trackPlayback);
        if (animatedBug.isPlaying == true) {
            animatedBug.play();
        } else {
            animatedBug.stop();
    function trackthumbPos(e:Event):void {
        var dif:Number = thumb.x - bar.x;
        curr.text = String(animatedBug.currentFrame);
        animatedBug.gotoAndStop(Math.ceil(dif * ratio));
    function trackPayback(e:Event):void {
        if(isPlaying == true) {
            thumb.x = bar.x + (animatedBug.currentFrame / ratio);
        curr.text = String(animatedBug.currentFrame);

    Hello Andrei1/Ned,
    I followed your recommendations by changing the isPlaying variable to jumpStart as well as cleaning up the code a bit. The code now works. Many Thanks!
    import flash.events.MouseEvent;
    import flash.geom.Rectangle;
    import flash.events.Event;
    //define constraints to keep thumb inside of bar
    var constraint:Rectangle = new Rectangle (bar.x, bar.y, bar.width-thumb.width, 0);
    var ratio:Number = animatedBug.totalFrames / (bar.width - thumb.width);
    var jumpStart:Boolean = true;
    //make the movie clip behave like a button
    thumb.buttonMode = true;
    durr.text = String(animatedBug.totalFrames);
    animatedBug.stop();
    thumb.addEventListener(MouseEvent.MOUSE_DOWN, handleDown);
    stage.addEventListener(MouseEvent.MOUSE_UP, handleUp);
    addEventListener(Event.ENTER_FRAME, trackPlayback);
    function handleDown(e:MouseEvent):void {
        //pass in the constrain to contain thumb within bar
        e.target.startDrag(false, constraint);
        addEventListener(Event.ENTER_FRAME, trackthumbPos);
        removeEventListener(Event.ENTER_FRAME, trackPlayback);
    function handleUp(e:MouseEvent):void {
        thumb.stopDrag();
        removeEventListener(Event.ENTER_FRAME, trackthumbPos);
        addEventListener(Event.ENTER_FRAME, trackPlayback);
        if (jumpStart) {
            animatedBug.play();
        } else {
            animatedBug.stop();
    function trackthumbPos(e:Event):void {
        var dif:Number = thumb.x - bar.x;
        curr.text = String(animatedBug.currentFrame);
        animatedBug.gotoAndStop(Math.ceil(dif * ratio));
    function trackPlayback(e:Event):void {
        if(jumpStart) {
            thumb.x = bar.x + (animatedBug.currentFrame / ratio);
        curr.text = String(animatedBug.currentFrame);

  • Problem of defining value to a textfield in MovieClip

    hello,dear everyone
    there is problem that realy confused me.that is the
    textfield(or other display objects) in MovieClip can't be defined
    when i jumpto that frame.check these simple code:
    mc.stop()
    function goNext(evt:Event){
    mc.nextFrame()
    dosth()
    function dosth()
    if(mc.currentFrame==2)
    mc.mytext.text="hello"
    nextBT.addEventListener("click",goNext)
    the mc is a simple MC that have 2 frames,and the textfield
    object is in the second frame.
    and what i try to do is when i clicked the button,the mc
    jumpto the second frame.and i define a value to that textfield.but
    it's failed when i try to do like that.
    as i debug the program.i found that when i define the value
    to the textfield,that textfield is a Null Object(should be the
    TextField object).not only the textfield not work,but also other
    elements such as Button objects.
    so,i am thinking that must because the objects are too late
    to initialized before they be used.maybe there are some event can
    tell me that all elements has been initialized,as i can use them
    then.what do you think,my friend?

    If all of the code you have is in the first frame, then it
    has processed long before anything ever moved to the second frame.
    What you could try is to have a variables layer that extends
    both frames, and assign the value of the textfield text to that
    variable. Make the textfield associate with that variable (in the
    properties section for it), So when the movieclip moves to the
    second frame the text field should automatically acquire the
    variable value.
    I may not have interpretted your problem correctly, so you
    might have to clarify things if I missed the target.

  • Multiple Animations for a single MovieClip sprite

    Ok, after hours of exhausting searching, and having to learn how to animate a simple sprite for the 100th time, I hope I might found I more specific, and better explained answer to my problem.
    I'm trying to make a flash game, of course, and I want my main Player sprite to be able to play multiple animations based on specific input. So, a running right animation, a running left animation, a jump animation, and an attack animation.
    At the moment, the most I can seem to achieve is to create a single timeline, with a default frame in the exact middle. Then when player holds left, it plays the previous frame, or scrolls backwards through the timeline. When the Right key is held, it plays forward from the default middle.
    It's ugly and extremely limited. I've tried using the gotoAndStop() and gotoAndPlay() methods, but because the statement checking for the key being pressed is constantly being checked, it will stay on the frame chosen for those methods, rather than move forward along the time line.
    I would greatly appreciate a better method for this, or a more specific tutorial to achieve the goal i'm looking for.
    I've seen mention of the attachMovie() method, but I can not find an understandable explanation of how to properly use it in the way I desire.
    essentially, the sprite will have the default standing frame while no keys are pressed. Then, if the right key is down, it plays the running right animation. When the left key is down, it plays the running left animation. When the jump key is pressed, it plays the jump animation. And when the attack key is pressed, it plays the attack animation.
    I hope that's enough information and that it's understandable, if not, let me know what more you need to know and I'll do my best to explain it more.

    You can do this a number of ways but I will try to explain the what I think is the easiest.
    Step 1
    Draw a box on the stage
    Step 2
    convert this into a movieclip (F8), name this myCharacter (or anything you want really), then press ok. Now select this movieClip and in the properties dialogue box, type "box", again, without the quotes. Then press enter.
    Step 3
    Double click this new movieClip (this should take you into this movieClip timeline)
    Step 4
    Now press F6, 3 times. This wil give you 3 additional key frames on this timeline. You should now have 4 key frames.
    |Step 5
    Select key frame 1 on this timeline and press F8. Type into the diag box "standing", without the quotes. Then select the Movie Clip radio button, if it is not already selected.
    Step 6
    Step 12
    Make sure  your library is in view, if not Ctrl+L. You should see the movement clips you created, running_right, running_left, etc. Double Click any one of these and add the animation your want in these movs.
    There we go, simples.....Test you animation and see how you are doing.
    Select key frame 2 on this timeline and press F8. Type into the diag box "running_right", without the quotes. Then select the Movie Clip radio button, if it is not already selected.
    Step 7
    Select key frame 3 on this timeline and press F8. Type into the diag box "running_left", without the quotes. Then select the Movie Clip radio button, if it is not already selected.
    Step 8
    Select key frame 4 on this timeline and press F8. Type into the diag box "jumping", without the quotes. Then select the Movie Clip radio button, if it is not already selected.
    Great, once you have done this, these new movieClips should now have appeared in your library (press Ctrl+L if you cannot see your library)
    Ok then you have just created your movement MovieClip. You now need to get back to the main timeline. You can just keep on clicking the stage to get back to this location. Once there you need to select the box you have just created and name this "box" for the time being.
    Ok then a little bit of programming now.
    Step 9Create a new layer in the timeline and name it scripts.
    Step 10Then select this layer and press F9 on your keyboard. THis should bring up the scripting pane for this frame.
    Step 11Type in the following code
    box.stop();// when you run this animation, this command will stop your box from doing anything
    var keyBoardListener:Object = new Object();// Creates a new Object for the keyboard presses
    keyBoardListener.onKeyDown = function() {
    if (Key.isDown(Key.LEFT)) {// runnning LEFT action
      _root.box.gotoAndStop(3);// Frame where the running right animation is
    } else if (Key.isDown(Key.RIGHT)) {// running RIGHT action
      _root.box.gotoAndStop(2);// Frame where the running right animation is
    } else if (Key.isDown(Key.UP)) {// JUMPING action
      _root.box.gotoAndStop(4);// Frame where the JUMPING animation is
    keyBoardListener.onKeyUp = function() {
    _root.box.gotoAndStop(1);// When the keys are released, this action takes your animation back to frame 1, where your character is just standing still.
    Key.addListener(keyBoardListener);// this assigns the listener to your key press detection Object.
    Step 12
    Edit the action movs within your library by double clicking each one and adding movement to each. Then test your animation.

  • MovieClip Hit problem.

    MovieClip Hit area doesn't work properly. I have two
    movieclip's next to each other, one is button mode true, but the
    hit area isn't correct.
    Here is my .fla file (just an example, very simple) -
    http://www.speedyshare.com/831305914.html
    , just open and test the movie, you see it (then you roll over it
    should fade in into blue and at mouse roll out it should fade out
    back to white, but on "o" and a lit of bit on "m" hit area is
    wrong).
    How to fix this?

    I really don't know guys.

  • Export animation to SWF and plays as MovieClip

    Hi to EveryBody.
    We are evaluating the Rome AIR  applicaction in order to create presetations and swf animations.
    We  have made an animation, the Anim Clips Animation,  without anything  more.
    We have exported to SWF (Flash Player Compatible)  and everything went ok.
    We have a special player made  in flex that plays de SWFs Casting it as a MovieClip and when the object  is Casted the result is a null object.
    We have had  this problems  with SWFs compiled with flash player in AS2 but if it was  compiled in AS3 it works.
    Any idea or solutions.
    Thanks
    The player Code for Flash Builder 4: When you  click the button de conversión is realized and the movie variable is  null.
    <?xml version="1.0"?>
    <!-- controls\swfloader\SWFLoaderSimple.mxml-->
    <s:Application xmlns:fx="http://ns.adobe.com/mxml/2009"
                    xmlns:s="library://ns.adobe.com/flex/spark"
                    xmlns:mx="library://ns.adobe.com/flex/mx">
         <fx:Script>
             <![CDATA[
                 function convert():void{
                     var movie:MovieClip = player.content as MovieClip;               
                     movie.gotoAndPlay(1);
             ]]>
         </fx:Script>
         <s:VGroup>
             <mx:SWFLoader source="Rome.swf" id="player"/>
             <s:Button label="Convert" click="convert()"/>
         </s:VGroup>
    </s:Application>

    Fixed Layout EPUB files support most of the animation you can do in InDesign.
    https://indesignsecrets.com/lynda-com-course-creating-fixed-layout-epubs-indesign-cc.php

  • How do I use a button within a movieclip to go to the root?

    Hi there, I am new to flash and AS3 and need some help
    getting my buttons to work.
    I made a script for the file that i am working with that has
    buttons located within 2 movieclips. I want that button to load and
    image into a UILoader (problemLoader_mc) that I placed on the stage
    on the main timeline (the timeline that contains WeekBar_mc). The
    problem is that I don't know how to get to the root of the file to
    start a new directory to tell my function to load the image i want.
    I have tried multiple approaches including:
    MovieClip(root).problemLoader_mc.source = problemArray[0]
    MovieClip(parent).problemLoader_mc.source = problemArray[0]
    root.problemLoader_mc.source = problemArray[0]
    parent.problemLoader_mc.source = problemArray[0]
    (root as MovieClip).problemLoader_mc.source = problemArray[0]
    If anyone can help me out with this, I would greatly
    appreciate it, I am banging my head against a wall at the moment.
    (Also, please excuse my vague descriptions, I am still learning the
    official terms.)
    Here is the code that I have written that pertains to this
    problem:

    I have a mental block for reasoning things out as far as
    assigning the listener to an object two mc's away from the main
    timeline while having the function in the main timeline, so I may
    play with that on my own for awhile. One thing you didn't do
    though, was to pay the same attention to the problemArray[0]
    assignment in that function, which I assume also lives in the root.
    But here's what I'd do for the moment.
    Take all that code except the array and plant it in the
    timeline where WEEK1btn lives, modifying it as follows....
    WEEK1_btn.addEventListener(MouseEvent.CLICK, pload1);
    function pload1(event:Event)
    MovieClip(this.parent.parent).problemLoader_mc.source =
    MovieClip(this.parent.parent).problemArray[0];
    I haven't utlized root myself yet, so I am not comfortable
    offering you a solution that attempts it.

  • Preview of a movieclip

    Hello,
    On main stage when working with a movieclip symbol that contains animation i only see first frame of that animation. And if that animation starts blank the preview of that movieclip symbol will also be blank. And its very hard to do any kind of work with that kind of movieclip symbol on the main stage - selecting, composing with other elements, because simply you dont see it.  Is there a way to chose which frame of a movieclip is displayed as a preview? Currently my workaround is to insert one aditional frame at the start of movieclip's timeline and paste onto it a graphic that will represent the movieclip, then delete it after all the work has been done.
    Thank you!

    HAving something in the first frame is needed if you want to see the movieclip while editing on the stage.  What you can do, instead of deleting after the work has been done, place the graphic on a new layer and when you are done change that layer to be a Guide layer so that it is not included when the file is compiled, but is still there in case you need it again.

  • I need to get sound events from sounds embedded in a MovieClip

    I'm working on a SoundManager class for a game development
    platform. Unfortunately, I can't leverage the Sound class because
    the requirements are that the sounds for an application would be
    embedded in individual MovieClip objects and set to stream as the
    clip plays.
    The idea is that this would allow third-party developers to
    make simple edits to the sounds by using the envelope controls for
    the embedded sounds. I can manually fire an event when the sound
    finishes by calling a custom method in the last frame of the movie
    clip, however, this is not completely accurate and it makes it
    impossible to seamlessly loop sounds.
    Now, the Flash player must be aware that the sound has
    finished playing. I presume that sounds embedded in the IDE are
    handled by the Sound class in some way. Is there any way at all
    that I can expose an event when the embedded sound finishes
    playing?
    I'd really prefer to use another approach, and just attach
    sound files from a Library or from external files, but I don't have
    a choice in this particular case. This is the way the application
    has to work.
    I will probably have to give up on the precision I want in
    order to complete this job on time, but I refuse to believe that
    what I'm trying to do is impossible. I would appreciate any help
    anyone can give me.

    You'll have to update your OS on your Macbook.
    Click on the black Apple logo at the top left of your Mac screen.  Then click on Software Update.
    support.apple.com/kb/ht1338

  • MovieClip buttons inside a MovieClip button inside another MovieClip button

    I am trying to make a Portfolio of my study abroad experience and can get something right about the movie clip buttons inside each other. I have a button to click on titled "travel" and a window shows up with more movieclip buttons to organize different locations of pictures. I can click on the button to have to slide of pictures but nothing happens. I have the "turnOffAllButtons"  coding and  also have the coding for stay clicked, but I can't get the 3rd set to show up. what am i not doing?
    I don't have any errors or output comments showing up

    I have it working now. what I did, I make a slideshow setup (gotoAndStop(1);) in a specific frame and the code I put in for the next, didnt work.
    this is was I have now, without the "turnOffAllButtons" coding:
    Main Button (actions Layer):
    stop();
    travelButton_mc.buttonMode=true;
    travelButton_mc.addEventListener(MouseEvent.ROLL_OVER, colorizetravelButton);
    function colorizetravelButton(givenEvent:MouseEvent){
      if (givenEvent.currentTarget.currentFrame != 50)
      travelButton_mc.gotoAndPlay(2);
    travelButton_mc.addEventListener(MouseEvent.ROLL_OUT, decolorizetravelButton);
    function decolorizetravelButton(givenEvent:MouseEvent){
      if (givenEvent.currentTarget.currentFrame != 50)
      travelButton_mc.gotoAndPlay(21);
    travelButton_mc.addEventListener(MouseEvent.CLICK, loadtravelLocations);
    function loadtravelLocations(givenEvent:MouseEvent){
      travelButton_mc.gotoAndStop(50);
      travelLocations_mc.gotoAndPlay(1);
    Inside the travelLocations_mc I have currently one button to show a slide of pictures, this is the second layer of buttoncode:
    stop();
    scotlandButton_mc.buttonMode=true;
    scotlandButton_mc.addEventListener(MouseEvent.ROLL_OVER, colorizescotlandButton);
    function colorizescotlandButton(givenEvent:MouseEvent){
      if (givenEvent.currentTarget.currentFrame != 50)
      scotlandButton_mc.gotoAndPlay(2);
    scotlandButton_mc.addEventListener(MouseEvent.ROLL_OUT, decolorizescotlandButton);
    function decolorizescotlandButton(givenEvent:MouseEvent){
      if (givenEvent.currentTarget.currentFrame != 50)
      scotlandButton_mc.gotoAndPlay(21);
    scotlandButton_mc.addEventListener(MouseEvent.CLICK, loadscotlandInfoPage);
    function loadscotlandInfoPage(givenEvent:MouseEvent){
      scotlandButton_mc.gotoAndStop(50);
      scotlandInfoPage_mc.gotoAndPlay(1);
    I turned the alpha up so you can see the mc that loads
    I currently have a keyframe at 60 with a code of stop(); so the travelLocations_mc will still
    does this make sense?

  • Calling a variable from inside a movieclip AS3 in Flash CS4

    I am trying to trace a variable string from inside a movieclip which is inside another movieclip on the main timeline using:
    trace(VariableString);
    and also
    trace(stage.VariableString);
    Neither work
    The variable is an input textfield and traces fine when it is on the main timeline but will not work from inside the movieclip. I am using Actionscript 3 in Flash CS4.
    I appreciate this has probably been discussed previously on this forum but I cannot find a difinitve answer that seems to work.
    Thanks

    Thanks for the reply. However this did not seem to work.
    I think I had better explain a little better.
    On Keyfrme1 I have a MovieClip1 containing a text input component. I have created a variable on keyframe 1 using:
    var VariableString1:String = new String();
    When clicking on a seperate button this happens:
    VariableString1 = MovieClip1.text;
    I can trace this correctly on the main timeline using:
    trace(VariableString1);
    However, if I try to trace this from  another keyframe inside a movieclip2 which is inside another movieclip3 using:
    trace(MovieClip1(root).VariableString1);
    I just get the error 1180 call to a possibly undefined method MovieClip1
    Sorry if this is not very clear but I am getting very confused with this.
    Thanks again

  • Problem in Loading Multiple image in Single Sprite/MovieClip

    Hi All,
    I am having a killing problem in loading multiple images in single movie clip/sprite using a separate class.
    Here is the ImageLoader.as class
    package com.project.utils{
        import com.project.*;
        import com.project.utils.*;
        import flash.events.EventDispatcher;
        import flash.display.MovieClip;
        import flash.events.Event;
        import flash.events.ProgressEvent;
        import flash.display.Loader;
        import flash.events.IOErrorEvent;
        import flash.net.URLLoader;
        import flash.events.MouseEvent;
        import flash.net.URLRequest;
        import flash.display.Bitmap;
        public class ImageLoader extends EventDispatcher {
            public var imgloader:Loader;
            public var imgMc:MovieClip;
            public var imgObject:Object;
            public var loaded:Number;
            public function ImageLoader():void {
                imgMc = new MovieClip();
                imgObject = new Object();
                imgloader = new Loader();
            public function loadImage(imgHolder:MovieClip, imgObj:Object):void {
                imgMc = new MovieClip();
                imgObject = new Object();
                imgloader = new Loader();
                imgMc = imgHolder;
                imgObject = imgObj;
                imgloader.contentLoaderInfo.addEventListener(Event.COMPLETE,onImgLoad);
                imgloader.contentLoaderInfo.addEventListener(ProgressEvent.PROGRESS,onImgLoadProgress);
                imgloader.contentLoaderInfo.addEventListener(IOErrorEvent.IO_ERROR,onImageLoadFailed);
                imgloader.load(new URLRequest(imgObj.FilePath));
            private function onImgLoad(Evt:Event):void {
                var image:Bitmap = Bitmap(Evt.target.content);
                try {
                    imgMc.removeChildAt(0);
                } catch (error:Error) {
                imgMc.addChild(image);
                try {
                    if (imgObject.URL != undefined) {
                        imgMc.buttonMode = true;
                        imgMc.removeEventListener(MouseEvent.CLICK, onImageClicked);
                        imgMc.addEventListener(MouseEvent.CLICK, onImageClicked);
                } catch (err:Error) {
                dispatchEvent(new CustomEvent("CustomEvent.ON_IMGE_LOAD"));
            private function onImageClicked(evt:MouseEvent):void {
                trace("Image Attrs:"+imgObject.URL +" Target "+imgObject.Target);
            private function onImgLoadProgress(Evt:ProgressEvent):void {
                if (Evt.bytesLoaded>0) {
                    loaded = Math.floor((Evt.bytesLoaded*100)/Evt.bytesTotal);
                    dispatchEvent(new CustomEvent("CustomEvent.ON_IMGE_LOAD_PROC",loaded));
            private function onImageLoadFailed(Evt:IOErrorEvent):void {
                trace("Image Loading Failed");
                dispatchEvent(new CustomEvent("CustomEvent.ON_IMGE_LOAD_FAIL"));
    Here I am loading some images using the above class in a for loop, like
                for (var i=0; i < 3; i++) {
                    //imgLoader=new ImageLoader;
                    imgLoader.addEventListener("CustomEvent.ON_IMGE_LOAD",onImageLoad);
                    var target:MovieClip=videolist_mc["list" + mcCount + "_mc"];
                    target.list_mc.visible=false;
                    var imgObj:Object=new Object;
                    imgObj.FilePath=list[i].Thumbnail;
                    imgObj.Url=list[i].Url;
                    imgObj.Target=list[i].Target;
                    target.list_mc.urlObj=new Object  ;
                    target.list_mc.urlObj=imgObj;
                    imgLoader.loadImage(target.list_mc.imgholder_mc,imgObj);
                    target.list_mc.lable_txt.htmlText="<b>" + list[i].Label + "</b>";
                    target.list_mc.imgholder_mc.buttonMode=true;
                    target.list_mc.imgholder_mc.addEventListener(MouseEvent.CLICK,onItemPressed);
                    mcCount++;
    In this case, the ImageLoader.as works only on the last movie clip from the for loop. For example, if i am trying to load three image in three movie clips namely img_mc1,img_mc2 and img_mc3 using the for loop and ImageLoader.as, I am getting the image loaded in the third movie clip only img_mc.
    See at the same time, If i uncomment onething in the for loop that is
    //imgLoader=new ImageLoader;         
    its working like a charm. But I know creating class objects in a for loop is not a good idea and also its causes some other problems in my application.
    So, help to get rid out of this problem.
    Thanks
    -Varun

    package com.project.utils{
        import com.project.*;
        import com.project.utils.*;
        import flash.events.EventDispatcher;
        import flash.display.MovieClip;
        import flash.events.Event;
        import flash.events.ProgressEvent;
        import flash.display.Loader;
        import flash.events.IOErrorEvent;
        import flash.net.URLLoader;
        import flash.events.MouseEvent;
        import flash.net.URLRequest;
        import flash.display.Bitmap;
        public class ImageLoader extends EventDispatcher {
            public var imgloader:Loader;
            public var imgMc:MovieClip;
            public var imgObject:Object;
            public var loaded:Number;
            public function ImageLoader():void {
    // better add you movieclip to the stage if you want to view anything added to it.
                imgMc = new MovieClip();
                imgObject = new Object();
                imgloader = new Loader();
            public function loadImage(filepath:String):void {
                imgloader.contentLoaderInfo.addEventListener(Event.COMPLETE,onImgLoad);
                imgloader.contentLoaderInfo.addEventListener(ProgressEvent.PROGRESS,onImgLoadPr ogress);
                imgloader.contentLoaderInfo.addEventListener(IOErrorEvent.IO_ERROR,onImageLoadF ailed);
                imgloader.load(new URLRequest(filepath));
            private function onImgLoad(Evt:Event):void {
                var image:Bitmap = Bitmap(Evt.target.content);
                try {
                    imgMc.removeChildAt(0);
                } catch (error:Error) {
                imgMc.addChild(image);
                try {
                    if (imgObject.URL != undefined) {
                        imgMc.buttonMode = true;
                        imgMc.removeEventListener(MouseEvent.CLICK, onImageClicked);
                        imgMc.addEventListener(MouseEvent.CLICK, onImageClicked);
                } catch (err:Error) {
                dispatchEvent(new CustomEvent("CustomEvent.ON_IMGE_LOAD"));
            private function onImageClicked(evt:MouseEvent):void {
                trace("Image Attrs:"+imgObject.URL +" Target "+imgObject.Target);
            private function onImgLoadProgress(Evt:ProgressEvent):void {
                if (Evt.bytesLoaded>0) {
                    loaded = Math.floor((Evt.bytesLoaded*100)/Evt.bytesTotal);
                    dispatchEvent(new CustomEvent("CustomEvent.ON_IMGE_LOAD_PROC",loaded));
            private function onImageLoadFailed(Evt:IOErrorEvent):void {
                trace("Image Loading Failed");
                dispatchEvent(new CustomEvent("CustomEvent.ON_IMGE_LOAD_FAIL"));
    Here I am loading some images using the above class in a for loop, like
                for (var i=0; i < 3; i++) {
                    var imgLoader:ImageLoader=new ImageLoader();
                    imgLoader.addEventListener("CustomEvent.ON_IMGE_LOAD",onImageLoad);
                    var target:MovieClip=videolist_mc["list" + mcCount + "_mc"];
                    target.list_mc.visible=false;
                    var imgObj:Object=new Object;
                    imgObj.FilePath=list[i].Thumbnail;
                    imgObj.Url=list[i].Url;
                    imgObj.Target=list[i].Target;
                    target.list_mc.urlObj=new Object  ;
                    target.list_mc.urlObj=imgObj;
                    imgLoader.loadImage(pass the image file's path/name);
                    target.list_mc.lable_txt.htmlText="<b>" + list[i].Label + "</b>";
                    target.list_mc.imgholder_mc.buttonMode=true;
                    target.list_mc.imgholder_mc.addEventListener(MouseEvent.CLICK,onItemPressed);
                    mcCount++;

  • Help please!  I need code for a button to stop a movieclip, when both are in a nested animation.

    I'm working on a project that has a button and a movieclip, which we want the button to stop, both nested in a movieclip on the main timeline.
    The button instance = muteBtn
    The clip to stop instance = backmusic
    The movieclip they are nested in = ecard
    There's also a preloader that works just fine on the main timeline.
    I've seen a wide variety of ways to stop a streaming MP3 and they all look way too complicated for my current Flash knowledge level.  As far as I know, if the MP3 is in a movieclip, stopping that clip will also stop the MP3.  If that's just dead wrong and what I'm trying to do will never work, please just let me know so I can struggle in another direction.
    What I'd prefer though would be the coding to make this button work.  I've tried a wide variety of ways to code something that seems like it should be so simple, and keep getting the error "Access of undefined property muteBtn".  I'm assuming this means it can't find the muteBtn in the nested layer.  How do I better define the muteBtn?  Do I then need to add something else that more clearly defines where the clip I want it to stop is since it is nested too?  PLEASE HELP ME!! Thank you in advance!
    Some of what I've tried:
    function endMusic(e:Event):void {
        ecard.backmusic.stop();
    or
    function endMusic(e:Event):void {
        backmusic.stop();
    with...
    muteBtn.addEventListener(MouseEvent.CLICK, endMusic);

    When you target objects, you need to consider the path to the object based on where you are trying to target from.  So if your code is in the main timeline and your button is inside a movieclip, then you need to target the button via the movieclip...
       movieclipName.muteBtn.addEventListener(MouseEvent.CLICK, endMusic);
    As far as stopping a moiveclip resulting in stopping a sound from playing, it is not likely to work.  To stop a sound you need to target the sound to stop it.

  • To use the same code for many movieclips

    Dear all.
    I am using the flash to build my personal book online. I need zoom  many movieclip, my images.
    i make the code and function perfectly. But I want to find a way to use the same function for all movieclips and so, mantaining my code clean.
    mc_01.addEventListener(MouseEvent.MIDDLE_MOUSE_DOWN, Drag);
    mc_01.addEventListener(MouseEvent.MIDDLE_MOUSE_UP, unDrag);
    mc_02.addEventListener(MouseEvent.MIDDLE_MOUSE_DOWN, Drag);
    mc_02.addEventListener(MouseEvent.MIDDLE_MOUSE_UP, unDrag);
    and many others....
    function Zoom(e:MouseEvent):void
            mc_01.x = 0;  //I try here for this.x but the previews movie, called "Books" is who have changed your x value.
            mc_01.y = 0;
    I
    EDIT: For untangle, the previews movie is called MyAllPhotos and then, contain all movieclips that are each movie clip is one my images

    Hi Mr Kglad.
    And when I call a property like a X position I use this["mc_"+padF(i)].x = 0;  for substitute the mc_01.x = 0 ?
    My problem realy is inside the function. Your loop add an event to my clips and direction to function Drag and UnDrag.
    But inside in this functions, I need get some informations for the clip.
    Here the code:
    function Zoom(e:MouseEvent):void  //Sorry, but the correct name my functions is Zoom and not Drag and unDrag
               var mod:Number = 50;
               mc_01.scaleX += e.delta / mod; //in this name mc what I need to use? this, parent? I try and not function.
               mc_01.scaleY += e.delta / mod;

  • Using the radio button component to go to a frame on a MovieClip

    hello,
    I am using the radio button component in Flash with a continue button.
    When the user clicks their option in the radio button and then clicks continue, I want it to go to a movieClips Specific frame.
    Here is the breakdown and the script I have so far is below.
    The radio group os named RadioButtonGroup
    The instance names for each of the three options are noviceButton,intermediateButton,expertButton
    My continue button has an instance name of continueButton
    and my movie clip I am trying to target has an instance name of level_mc
    here is my code so far:
    continueButton.enabled=false
    noviceButton.addEventListener(MouseEvent.CLICK, revealContinue);
    intermediateButton.addEventListener(MouseEvent.CLICK, revealContinue);
    expertButton.addEventListener(MouseEvent.CLICK, revealContinue);
    function revealContinue(evt){
        continueButton.enabled=true;
    continueButton.addEventListener(MouseEvent.CLICK, clickContinue);
    function clickContinue(evt){
    var frameNumber=mc_levels.Number(noviceButton.group.selectedData)
    gotoAndStop (frameNumber);
    the problem starts with my varFrame line-I don't know how to get it to go to the movieClip and gotoAndStop at a specific frame, based on which radio button was clicked and after the continue button is clicked.
    Does anyone out there have any ideas?
    thanks
    babs

    use:
    continueButton.enabled=false
    noviceButton.addEventListener(MouseEvent.CLICK, revealContinue);
    intermediateButton.addEventListener(MouseEvent.CLICK, revealContinue);
    expertButton.addEventListener(MouseEvent.CLICK, revealContinue);
    function revealContinue(evt){
        continueButton.enabled=true;
    continueButton.addEventListener(MouseEvent.CLICK, clickContinue);
    function clickContinue(evt){
    var frameNumber=mc_levels.Number(noviceButton.group.selectedData)
    level_mc.gotoAndStop (frameNumber);

Maybe you are looking for

  • Ipod Nano Error 1417 Tried and won;t work

    I've tried looking through the restart method, the disconnect and reconnect method, and nothing works. My Ipod Nano is Ver. 1.0, and the update process does not pop up with a dialogue box, all it does is 'updating' but it's really doing nothing, help

  • Embedding all media within pdf file

    I'd like to figure out a way of creating one interactive pdf to deliver to clients that has all the media graphics, buttons, and movies all embedded into one file without having to provide the directory structure and all the ancillary file required f

  • Router Crashes after entering "show run" or similar commands

    Hello, Im having a problem with my Company router C3845-ADVSECURITYK9-M, software Version 15.1(4)M. After i issue "show run" it tends to crash in middle of output, router restarts itself to be precise....same thing happened when i tried "show stack"

  • How to type Number in table?

    it sounds stupid. but I really do not know. when I type number like 89 in one cell of the table, it will change to the currency. for example, "89" is automatically changed to "£89.00" how to avoid this effect?

  • Yellow warning signs with ! in it

    I am working in imovie-- do not know what I did-- but in my project libary one of my movies have the yellow warning sign with ! in it--- when I try to watch the movie all that comes is --sourse clip is missing, sign. Please help me as I want to keep