Movie Clips vs the Stage help me out plz

Before i start i currently am taking a class on flash and i
dont think we have gone terribly in depth.
I have 2 sets of Code one in a Movie Clip and another on the
Stage.
the issue i have is neither one can see variables from the
other. is there some special syntax or notation i need to pass the
variables
I cant see the Current Unit in the Button

Syntactically your code is just fine. I didn’t receive
any errors when I checked it. However I would rearrange some things
in it. The 2 eventhandlers in the onEnterFrame function, I would
pull these out and put them outside of the onEnterFrame function
but on the same frame.
“the issue i have is neither one can see variables from
the other. is there some special syntax or notation i need to pass
the variables”
Inside that mc, the code that you have below “//Code in
Button”, it is typically recommended that you don’t
reference other movieclips by using ‘_levelX’. Use a
relative path, such as ‘this._parent” or
“this._parent._parent” depending on how many movieclips
are nested into it. Also note, when you reference a movieclip from
inside an eventHandler (onPress, onRelease, onEnterFrame, etc.) you
are already within an object. So to reference something on the same
tier you should use ‘this._parent’. Once you find the
correct tier by using the code I mentioned in the last sentence,
you then need to attach the instance name of the movieclip you are
trying to access (that is if you are trying to access a movieclip).
For an example, ‘this._parent.currentguy’.
I hope this helps, I understand it may be hard to grasp
however give it a shot and post back.
You may be interested in this link that is from the livedocs;
http://livedocs.macromedia.com/flash/8/main/wwhelp/wwhimpl/common/html/wwhelp.htm?context= LiveDocs_Parts&file=00001220.html

Similar Messages

  • Dynamically adding multiple instances of a movie clip to the stage with one button

    hello,
    I was wondering if there was a way to add several instances
    of the same movie clip to the stage dynamically utilizing one
    button.
    I can do one with the following code placed on the button...
    on (release) {
    attachMovie ("filledCircle", "filled1", 5);
    filled1._x = 370;
    filled1._y = 225;
    But I want the user to be able to hit the button again and
    get yet another instance of "filledCircle" on the stage.
    I also want the user to be able to drag these instances
    around...
    Any help would be appreciated...
    Thanks,
    Muhl

    Muhl,
    > I was wondering if there was a way to add several
    > instances of the same movie clip to the stage
    > dynamically utilizing one button.
    Sure thing.
    > I can do one with the following code placed on the
    > button...
    >
    > on (release) {
    > attachMovie ("filledCircle", "filled1", 5);
    > filled1._x = 370;
    > filled1._y = 225;
    > }
    Gotcha.
    > But I want the user to be able to hit the button again
    > and get yet another instance of "filledCircle" on the
    > stage.
    You're in luck, because this isn't very hard to do. The main
    thing to
    keep in mind is that each instance must have A) its own
    unique instance name
    and B) its own unique depth. In your example, the instance
    name is filled1
    and the depth is 5. The next clip's instance name should be
    filled2 at a
    depth of 6. Then filled3, depth 7, and so on. You can use a
    single
    variable to handle the incrementation.
    // code in a frame
    var counter:Number = 1;
    // code on your button
    on (release) {
    attachMovie ("filledCircle", "filled" + counter, counter +
    4);
    With me so far? The variable counter contains the numeric
    value 1. The
    second parameter of attachMovie() is provided with a
    concatenation of
    "filled" + 1, which makes "filled1". The third parameter is
    provided with
    the sum of counter plus 4, which makes 5. Obviously, we need
    a bit more.
    The button must, in addition, increment the value of counter.
    The ++
    operator handles this perfectly.
    on (release) {
    attachMovie ("filledCircle", "filled" + counter, counter +
    4);
    counter++;
    Now, it seems you also want to position the attached movie
    clip to (370,
    225). Are they call supposed to go to the same place? If so,
    you may use a
    second variable to hold a reference to the newly attached
    clip. Look up
    MovieClip.attachMovie(), and you'll see that the method
    returns the exact
    reference you need.
    // code in a frame
    var counter:Number = 1;
    var mc:MovieClip;
    // code on your button
    on (release) {
    mc = attachMovie ("filledCircle", "filled" + counter,
    counter + 4);
    counter++;
    mc._x = 370;
    mc._y = 225;
    Make sense?
    > I also want the user to be able to drag these instances
    > around...
    Then you need to handle a few events. You're dealing with
    movie clips
    here, so your best bet is to study up on the MovieClip class,
    which defines
    all movie clips. (Note, also, that the TextField class
    defines all input
    and dynamic text fields; the Sound class defines all sounds,
    etc. This is a
    very handy arrangement of the ActionScript 2.0 Language
    Reference.)
    // code in a frame
    var counter:Number = 1;
    var mc:MovieClip;
    // code on your button
    on (release) {
    mc = attachMovie ("filledCircle", "filled" + counter,
    counter + 4);
    counter++;
    mc._x = 370;
    mc._y = 225;
    mc.onPress = function() {
    this.startDrag();
    mc.onRelease = function() {
    this.stopDrag();
    Easy as that. You're simply assigning a function literal to
    the event
    of each new MovieClip instance as you create it. Take a look
    and you'll see
    each of these class members available to you -- that is, to
    all movie clips.
    MovieClip.onPress, MovieClip.startDrag(), MovieClip._x, etc.
    Wherever it shows the term MovieClip in the Language
    Reference, just
    replace that with the instance name of your clip -- or a
    reference to that
    clip (which even includes the global "this" property).
    David
    stiller (at) quip (dot) net
    Dev essays:
    http://www.quip.net/blog/
    "Luck is the residue of good design."

  • Removing a movie clip from the stage - need help

    I am learning AS3 after using AS2 for a long time.  I'm making progress but need help.  I have a simple Flash website with the sections laid out the timeline with labels.  In one section called Media, I have a movie instance of a Flash movie gallery player.  It loads just fine but when I leave that section to go to another, the sound of the video is still playing.  Visually it's not seen but the sound still plays.  I suspect I need to put some sort of remove commamnd in the script but I'm having trouble getting the right result.
    I appreciate any help I can get with this.
    Thanks!
    BC

    See if the following posting helps...
    http://forums.adobe.com/thread/754549?tstart=0

  • How do I recerence Movie Clips on the Main Timeline from inside a class?

    Hey everyone, this might be a stupid question but I thought
    I'd ask cause it's making me nuts. I'm all of 2 days into AS3
    (coming from not using Flash at all in YEARS) so feel free to
    consider me ignorant. I do have plenty of application development
    experience in other areas though.
    I can't seem to create a class that can reference an instance
    of a movie clip on my main timeline. I'd post code of what I've
    tried but I've gone through so many desperate edits & wild
    guesses that it was just garbled junk before I deleted it all.
    Basically here's how I figured Flash could work, though maybe
    it doesn't work this way at all.
    I'm assuming that with AS 3 being so big on being a true
    object oriented environment, I wouldn't need to mix my code and
    interface together. Preferably I'd be using the Flash authoring
    tools just to design my interface. Create a button... place it
    somewhere... give it an instance name. Roughly the equivilant of
    Apple's InterfaceBuilder for those of you that might be familiar
    with Cocoa development. I can see maybe having to put a few lines
    of ActionScript onto frame 1 (though really I'm hoping Flash would
    have a better method of kicking off the application at this point
    that using code tied to frames) to load my classes & such, but
    after that I'd like all of my code to be held in external class
    files.
    So maybe I've got:
    Interface.fla - My interface
    Button_1
    Button_2
    TextField_1
    Main.as - My main controller class using to handle all of my
    applications behavior
    SomeClass.as - Some helper Class
    SomeOtherClass.as - Some helper Class
    Main.as would have instructions in its initialization method
    to go ahead & attach events to buttons & initialize
    anything else that needs to happen when the application starts.
    From there on it would all be objects communicating back &
    forth. Button_1 would get clicked with would fire
    Main.someMethod(). Main.someMethod() would then do it's thing and
    set the value of TextField_1. All very clean & code is very
    separated from interface.
    Unfortunately I can't for the life of me figure out how AS3
    classes reference each other like that. There doesn't seem to be
    any kind of a global 'root' or '_root' I can use to locate any
    movie clips on the stage. I've searched the help & the web for
    any kind of simple tutorial but to no avail. My job has tasked me
    with building a flash app for a project but I'd really rather not
    have a tone of ActionScript just shoved into frame 1. That just
    seems... ugh! (::shudder::)
    Can someone maybe point me in the right direction here? I'm
    really willing to do my homework but I can't seem to locate the
    info I need to get started. Also, is there an ActionScript IRC
    channel or something maybe?
    Thanks,
    Cliff

    I worked with the problem last night and the solution I
    started coming to involved creating my own custom document class
    based off which extends MovieClip. My thought is that way I have
    access to the initialization routine of the timeline itself and
    that all of the elements on the main timeline should be
    "properties" of my custom class.
    Is this correct? Is there a down side to doing this & if
    so what is it & why?
    Also, just for my reference, the last time I did anything
    with ActionScript I think I was using '_root' to target the main
    timeline. WHat are the global variable names in AS 3? Is it just
    'root' & 'stage' or 'Root' & 'Stage' or what?

  • Boundary for movie clips following the mouse

    here's my AS...
    myInterval = setInterval(KBMOglobal,15);
    function KBMOglobal () {
    KBMOglobal1._x -= (KBMOglobal1._x - _xmouse)/10;
    KBMOglobal1._y -= (KBMOglobal1._y - _ymouse)/10-2;
    ok, so my movie clip follows the mouse around, with a small
    delay and the y axis is slightly lowered. the stage of my movie is
    380 x 640. does anyone have any suggestions on how to create a
    boundary, equal to the size of my stage, that does not let the
    movie clips that follow the mouse extend past? does that even make
    any sense? essentially, i would like the movie clips to follow the
    mouse, the entire movie clip stay visible on the stage. because of
    the positioning of the items on the stage that initiate this
    function, i only have to consider the width of each movie clip,
    which luckily is a constant = 200. does that make any sense? let me
    try this all again....
    how do adjust the above function so that the movie clip,
    KBMOglobal1 (which has a width of 200) stay within the horizontal
    limits of the stage (which is 380)?
    thanks for your time and to everyone in this forum that has
    been so very helpful with all my questions in this project so far,
    yall rock!

    quote:
    Originally posted by:
    NickTheNameless
    this is almost working perfectly, however i need to adjust
    the boundary of the x axis. for some reason, the movie clip stops
    following the mouse when it reaches half way across stage,
    horizontally.
    would you please be so kind to explain what your script is
    doing? because i'm not a total idiot, i realize i could probably
    replace 380 with 760 (double the width of the stage) and it would
    work as expected. however, if you could spare the time to explain
    what the following two lines are doing, step by step....i'll give
    you my first born.....
    KBMOglobalGeneralCancelDispatch._x<0?KBMOglobalGeneralCancelDispatch._x=0:KBMOglobalGenera lCancelDispatch._x;
    KBMOglobalGeneralCancelDispatch._x>380-KBMOglobalGeneralCancelDispatch._width?KBMOglobalG eneralCancelDispatch._x=380-KBMOglobalGeneralCancelDispatch._width:KBMOglobalGeneralCancel Dispatch._x;
    thanks again for your time!
    do you know ?: operator? it is like if...else... statements,
    when we say:
    somethingIsTrue ? do1() : do2();
    it is exactly same meaning like:
    if (somethingIsTrue) {
    do1();
    } else {
    do2();
    Now, we look at this line:
    KBMOglobalGeneralCancelDispatch._x<0?
    KBMOglobalGeneralCancelDispatch._x=0:
    KBMOglobalGeneralCancelDispatch._x;
    it is same like
    if (KBMOglobalGeneralCancelDispatch._x<0) {
    KBMOglobalGeneralCancelDispatch._x=0
    } else {
    KBMOglobalGeneralCancelDispatch._x

  • How to keep a Movie Clip on the screen for 5 secs.

    I am having trouble with keeping a movie clip on the screen.
    I am setting it up to play a movie using the .onPress function. It
    is calling the movie but only shows it for a split second. How can
    I make the movie stay on the stage for 5 seconds? Here is how I
    have it coded:
    rc1MC.onPress = function() {
    if (rc1MC.hitTest(_xmouse, _ymouse, false)){
    _global.correct++;
    updateStats();
    var c1:MovieClip = this.attachMovie ("correct1_mc",
    "correct1",4300);
    var ymov = this._y;
    var gravity = 20;
    c1.onEnterFrame = function() {
    ymov += gravity;
    xmov *= 0.5;
    c1._rotation += 5;
    c1._x += xSpeed;
    c1._y = ymov;
    if (c1._y>stageHeight) {
    c1.removeMovieClip();
    delete this.onPress;
    Thanks Brandon

    Got my answer...
    http://forums.verizon.com/t5/FiOS-TV-Technical-Assistance/For-Those-of-You-Who-Want-to-View-Subscrib...

  • How do I inactivate all other movie clips except the running one.

    Hello guys
    I would need help to inactivate all other actions on movie clips while the active movie clip is running. So in my flash scen when the user makes a roll over on a movie clip I would like that movie clip to play all frames in that movie clip before the user can roll over on an other movie clip. So the active movie clip don't gets interupted. What actionscript 2.0 should I look for?
    Thanks!
    /Klas

    You could use a boolean variable in a conditional that wraps whetever functionality the objects have to prevent them from taking those actions.  So when you rollover an object it starts to activate its animation or whatever and sets that boolean to prevent any others from doing the same.  And when it completes its actions it rets the boolean.
    If you show your rollover code it might be easier to show an example, but it might be something like...
    var allowPlay = true;
    mc1.onRollOver = rolloverFunction;
    mc2.onRollOver = rolloverFunction;
    mc3.onRollOver = rolloverFunction;
    function rolloverFunction(){
       if(allowPlay){
           allowPlay = false;
           this.play(); // or whatever action your rollover executes
    and when that animation completes the movieclip resets the allowPlay to true.
    _root.allowPlay = true;

  • HitTest for multiple Movie Clip at the same time

    I have a movie it is a triangle.I duplicate it and I want to hitTest on the first triangle movie clip and I added 3 different line movie clips on the 3 side of triangle.I tried to write a code something like that.
    if(firstTriangle_mc.hitTestObject(line1_mc,line2_mc,line_3mc){
    trace("Ok");
    but I've got error.I think it is not allowed hitTestObject for multiple Movie Clips.So is there anyone have an opinion about it?What should I do?

    Here is another test for multiple movie clips for hitTestPoint but only the first work the others don't
    uc_mc.addEventListener(Event.ENTER_FRAME,hitle);
    function hitle(e:Event) {
    if (uc_mc.hitTestPoint(cub1,cub1Y,true)&&(cub2,cub2Y,true)&&(cub3,cub3Y,true)) {
      uc_mc.alpha=0.5;
    }else{
      uc_mc.alpha=1;
    The code above doesn't work.What should I do?

  • Passing a variable from a movie clip to the main timeline

    Hi,
    I'm having trouble passing a variable from a movie clip in my
    flash file to the main timeline.
    I have a movieclip with the instance name IntroNav which
    contains several buttons. Clicking a button sets the variable
    "page" to a specific name, i.e. page = "home"
    However, outside of the movie clip, on the main timeline I am
    unable to call this variable, and "page" seems to have no value.
    Can anyone tell me why this is and how to solve it?
    Thanks

    Umm, yes ... declare your variables correctly.
    var page:String = new String(); //proper complete
    var page:String; //strict typing
    var page:String = "home"; //stirct typing with value
    declaration
    Do not declare the variable in your buttons, you would have
    to do so in every button and be constantly resetting the value.
    Declare it on the main timeline at the lowest level. You do not
    need to use it as a _global, you just need to resolve your path
    issues. You can 'set' the variable value from a button, without any
    problem, but you have to call to the variable correctly.
    You do not 'name' a variable as "_root.page" , the '_root'
    refers to the lowest level of the SWF or the main timeline, as does
    a call to ' _level0' (that's a zero). If the variable is declared
    on the main timeline, and you're calling from the MC/button or
    anywhere you can refer to the variable by calling to it by
    the proper path of '_root.page'
    To set the variable from any of your button/MC instances
    call:
    _root.page = "value"; OR _level0.page = "value";
    But you must have the varibale declared on the main timeline,
    and only once and the playhead should be stopped or it will reset
    the value to the default upon looping.

  • Garage Band 10.0.2 - How do I move clips in the editor?

    Pretty basic question about Garage Band 10.0.2.   I find it difficult to grab and move clips in the editor - the bottom window - as I could in previous versions. Instead, I'm having to go up to the top window to move clips closer together.  What am I doing wrong?

    Hold down the command key, while you click the region in the track editor and drag it. Don't click the ruler, click the wave shape in the audio region.

  • I selected restore factory settings on my ipod touch but now after restart it stuck on apple icon what will i do anybody help me out plz,even it's not appering on itunes on my p.c

    i selected restore factory settings on my ipod touch but now after restart it stuck on apple icon what will i do anybody help me out plz,even it's not appering on itunes on my p.c

    Try:
    - iOS: Not responding or does not turn on
    - If not successful and you can't fully turn the iPod fully off, let the battery fully drain. After charging for an least an hour try the above again.
    - If still not successful that indicates a hardware problem and an appointment at the Genius Bar of an Apple store is in order.

  • Deadline: 22 May 08H00 Help ME Please Scrolling a movie clip from the Centre

    Hi
    It has been a while since I have been here I am in need for
    some serious help, I am so frustrated.
    What I want to do is pretty simple, I am building a DJ
    website and the navigation is a pitch controller, similar to what
    they have on a mixing board anyway, when you drag the pitch
    controller I need the movie clip symbol to scroll either up and
    down, so technically the pitch controller will have to start from
    the center, but I have no idea what I am doing.
    I have been going through tutorials for 15 hours but all they
    show you is how to create a normal scroller that starts at the top
    and srolls down. I am in desprite need as I have a deadline to meet
    for tomorrow morning. HELP

    ok this is the code I got from a tutorial that i was woking
    from, but I dont really understand it in detail what I do know is I
    dont need the arror buttons in this code becuase all I need is a
    the scroller.
    scrolling = function () {
    var scrollHeight:Number = scrollTrack._height;
    var contentHeight:Number = contentMain._height;
    var scrollFaceHeight:Number = scrollFace._height;
    var maskHeight:Number = maskedView._height;
    var initPosition:Number = scrollFace._y=scrollTrack._y;
    var initContentPos:Number = contentMain._y;
    var finalContentPos:Number =
    maskHeight-contentHeight+initContentPos;
    var left:Number = scrollTrack._x;
    var top:Number = scrollTrack._y;
    var right:Number = scrollTrack._x;
    var bottom:Number =
    scrollTrack._height-scrollFaceHeight+scrollTrack._y;
    var dy:Number = 0;
    var speed:Number = 10;
    var moveVal:Number =
    (contentHeight-maskHeight)/(scrollHeight-scrollFaceHeight);
    scrollFace.onPress = function() {
    var currPos:Number = this._y;
    startDrag(this, false, left, top, right, bottom);
    this.onMouseMove = function() {
    dy = Math.abs(initPosition-this._y);
    contentMain._y = Math.round(dy*-1*moveVal+initContentPos);
    scrollFace.onMouseUp = function() {
    stopDrag();
    delete this.onMouseMove;
    btnUp.onPress = function() {
    this.onEnterFrame = function() {
    if (contentMain._y+speed<maskedView._y) {
    if (scrollFace._y<=top) {
    scrollFace._y = top;
    } else {
    scrollFace._y -= speed/moveVal;
    contentMain._y += speed;
    } else {
    scrollFace._y = top;
    contentMain._y = maskedView._y;
    delete this.onEnterFrame;
    btnUp.onDragOut = function() {
    delete this.onEnterFrame;
    btnUp.onRelease = function() {
    delete this.onEnterFrame;
    btnDown.onPress = function() {
    this.onEnterFrame = function() {
    if (contentMain._y-speed>finalContentPos) {
    if (scrollFace._y>=bottom) {
    scrollFace._y = bottom;
    } else {
    scrollFace._y += speed/moveVal;
    contentMain._y -= speed;
    } else {
    scrollFace._y = bottom;
    contentMain._y = finalContentPos;
    delete this.onEnterFrame;
    btnDown.onRelease = function() {
    delete this.onEnterFrame;
    btnDown.onDragOut = function() {
    delete this.onEnterFrame;
    if (contentHeight<maskHeight) {
    scrollFace._visible = false;
    btnUp.enabled = false;
    btnDown.enabled = false;
    } else {
    scrollFace._visible = true;
    btnUp.enabled = true;
    btnDown.enabled = true;
    scrolling();

  • When i publish the movie to youtube, the sound gets cut out half way through.  help?

    I'm trying to publish a short movie to youtube.  It plays fine in the editing screen, but when I publish it, half way through, the sound cuts out on the video.  There's still some background music that's playing, but the voices get cut out.  I've tried republishing it in a different size and the sound cuts out at the exact same place.  Any suggestions? 

    You can contact support and have them troubleshoot the songs for you.
    http://www.apple.com/support/itunes/contact/

  • Attaching Dynamic Movie Clips on a Stage Movie Clip

    Hi guys ,
    I am calling more images in dynamic movieclip on the stage
    from XML file and show them on the stage after that evry movieclip
    is draggable and there is lots of labels (movieclips) on which i
    have to drag the images called from xml files and placed on that
    label , label is also draggable once when i placed object on the
    label moviecli then when i drag the label all images placed in side
    the label should also move with the label .
    And there might be more labels and more images , i can place
    any images in a label or more images on different label but will
    work siimilarly described above .
    So please suggest me and help me out ASAP.

    Ok if I understand you, you have several movieclips on the
    stage that are created dynamically. Some of them are called
    "labels" and some are images. You want to drag and drop an image
    onto a label. Then when you do that you want the image to become a
    child movieclip of the label movieclip. That way when you drag the
    label movie clip and all the images inside it will move along with
    it.
    Are the images movieclips as well or are they just images?

  • New tweens and resizing the stage: Help!

    Hi all. I'm going nuts trying to figure this out.
    I built an animation project at 630 pixels wide. Turns out the project needs to be 430 pixels wide. In CS3, using the classic tweens, I would simply resize the stage, Onion All, then resize everything on the stage at once. But with the new tween structure, it looks like I can't do a mass resize like that. Anything that's been tweened using the motion editor does not resize.
    I know I can just create a new movie clip, paste all frames into it and then resize the MC, but I have some JPEGs of signatures that pixellate when they are resized that way.
    So, can you onion skin the new tweens? Is there a workaround?
    Thanks!

    I'm afraid there isn't a good answer for this one - it's one of the present limitations that we're aware of. The problem is twofold: One instance per tween instead of two/more (Edit multiple frames is entirely based on multiple instances - a tween only has one), and auto-keyframing (usually making things easier, but for this, complicating things - if you change the scale at a location it automatically tweens the change, which you don't want in this use case).
    For any motion paths, you need to select each and then scale them (you can use the Transform panel to enter a percentage. Mutliple selected motion paths will scale the instances instead (unfortunately for this case).  You can try selecting multiple and using the Transform panel, but this doesn't work well yet.
    If you haven't tweened the scale of your instances and they start at the same position, you're in a bit more luck. Put the playhead at the first frame of the span(s) and then scale the instances. If you have tweened the scale, then you'd need to move the scale tween up/down in the motion editor (press the Alt key while dragging the path in the graph).
    In the even less likely chance the instances share the same tween, I'd do this for one instance, save it as a preset and then apply it to the rest.
    I know this is a pain - I'm sorry it's not better for changing the size of the Stage. We didn't get the time to make Edit Mutliple Frames better for new motion in this release.

Maybe you are looking for

  • I am unable to create the Matser repository in ODI

    Hi, I am using 10.1.3.5.0 ODi and Sql server 2008. I have installed the ODI successfully , but when i am trying to create the Master repository i am not seeing the driver for 2008. I have installed Microsoft SQL Server JDBC Driver 3.0 and copy the sq

  • Safari and pop up?

    i am getting one single pop up add over and over again like at least 5 times a minute. it is like... a cell phone horoscope problem i have reset safari several times and it has not fixed the problem. and block pop up IS selected help?

  • Interface between Mysql to SAP

    Hi all,     I have to develop an interface between SAP to Mysql. Please suggest your ideas. Requirement: There is a machine called Acelli with Mysql database. We have a custom transaction in SAP, where user will select a line in table cotrol and clic

  • Is there a way to turn the GPS on my MacBook Pro off?

    How do I turn the GPS on my MacBook Pro off? Everytime I log onto iCloud to find my iPhone it pops up too.

  • Unable to download TV shows - keeps restarting

    I have been trying to download Prison Break "The Message" and a couple of episodes of Heroes recently. When the file downloads and the file begins processing the file then begins downloading from the start again or comes up with an error message such