Creating functions for movie-clips(serious problem)

Hello,
This is I think my third thread on these forums and in my
previous threads I had always got some help.Well, now I have
another serious problem, can you help me?
I am unable to create a function that can control movie
clips. Let me explain:-
I have 10 movie clips on the stage and I have assigned them
that whenever they crash to an object, they will go to a random
position. Writing this code ten times for each movie clip would be
very tedious, so, I thought about creating a function, but, it
doesn't work. Here's the function, can you correct it?
var object:movieClip;
function position(object) {
var testnum1:Number;
testnum1 = random(290)+36;
_root.object._y = -77.6;
_root.object._x = testnum1;
position(nameofmovieclip)
PLEASE HELP IS REQUIRED!!!!
Thanking All,
Chinmaya

Thanks for the reply,
I tried that, it worked!
But, now, I am encountering a really odd problem. This time
I'll give you my full code.The problem is, that now when the object
collides with another one, it changes its position according to the
code but then after a while, it just passes through the object.
Here's my code:-
function position(object) {
var testnum1:Number;
testnum1 = random(290)+36;
object._y = -77.6;
object._x = testnum1;
metal.onEnterFrame = function() {
_root.metal._y += speednum;
if (_root.metal.hitTest(_root.testline)) {
position(_root.metal);
speednum = random(6)+1;
Can you help me out again,
Thanks,
Chinmaya
P.S. I have tried to use the function like this:
position(metal), but it doesn't work. And yes, I have already
defines speednum somewhere before, so that isn't the
problem.

Similar Messages

  • RemoveChild for movie clip that was added in another function?

    Hello everyone.  I have 3 different functions for my preloader.  I have an Event.OPEN, ProgressEvent.PROGRESS, and an Event.COMPLETE.  In the event.OPEN function, I create a new variable that is data typed to the class name of my preloader that I set in it's property dialogue box.  This is just a simple circle animation.  Below is my code for it:
    function addPreloader(event:Event):void
        var myPreloader:mcPreloader = new mcPreloader();
        myPreloader.x = stage.stageWidth / 2;
        myPreloader.y = stage.stageHeight / 2;
        myPreloader.width = 75;
        myPreloader.height = 75;
        addChild(myPreloader);
    My ProgressEvent.PROGRESS function looks like so:
    function preloadImages(event:ProgressEvent):void
        var percent:Number = Math.round(event.bytesLoaded / event.bytesTotal * 100);
        percent_txt.text = percent + "%";
    and my Event.COMPLETE function looks like so:
    function imageLoaded(event:Event):void
        var myLoadedImage:Loader = Loader(event.target.loader);
        addChild(myLoadedImage);
        new Tween(myLoadedImage, "alpha", Strong.easeIn, 0, 1, 0.5, true);
        event.target.loader.removeEventListener(Event.OPEN, addPreloader);
        event.target.loader.removeEventListener(ProgressEvent.PROGRESS, preloadImages);
        event.target.loader.removeEventListener(Event.COMPLETE, imageLoaded);
    The only problem is that when it's done loading, I'd like to remove the myPreloader from the stage.  Since it is declared in the Event.OPEN function, I can't communicate with it via my Event.COMPLETE function.  How can I successfully remove it from the stage after it's done loading?  Thanks!
    Jesse

    Duh, thanks Kglad.  It's been a long week ;).
    Jesse
    Date: Thu, 9 Jun 2011 13:47:57 -0600
    From: [email protected]
    To: [email protected]
    Subject: removeChild for movie clip that was added in another function?
    var myPreloader:mcPreloader
    function addPreloader(event:Event):void
       myPreloader = new mcPreloader();
        myPreloader.x = stage.stageWidth / 2;
        myPreloader.y = stage.stageHeight / 2;
        myPreloader.width = 75;
        myPreloader.height = 75;
        addChild(myPreloader);
    My ProgressEvent.PROGRESS function looks like so:
    function preloadImages(event:ProgressEvent):void
        var percent:Number = Math.round(event.bytesLoaded / event.bytesTotal * 100);
        percent_txt.text = percent + "%";
    and my Event.COMPLETE function looks like so:
    function imageLoaded(event:Event):void
    removeChild(myPreloader);
    myPreloader=null;
        var myLoadedImage:Loader = Loader(event.target.loader);
        addChild(myLoadedImage);
        new Tween(myLoadedImage, "alpha", Strong.easeIn, 0, 1, 0.5, true);
        event.target.loader.removeEventListener(Event.OPEN, addPreloader);
        event.target.loader.removeEventListener(ProgressEvent.PROGRESS, preloadImages);
        event.target.loader.removeEventListener(Event.COMPLETE, imageLoaded);
    >

  • Check for movie clips with AS?

    Is it possible to check if a frame contain a movie clip with
    AS, and then if movie clip is found run a function? Like a global
    "event handler " for movie clips.

    I want a function that automaticly can detect and fade in any
    movie clip found in any keyframe in the main timeline. So i don't
    have to make
    In the first keyframe in the main timeline
    on (ohh here i found a movie clip)
    //let's run a nice fade function on that movie clip
    mx.transitions.TransitionManager.start
    (eval(TheClip),
    {type:mx.transitions.Fade,
    direction:0,
    duration:1,
    easing:mx.transitions.easing.None.easeNone,
    param1:empty,
    param2:empty
    Something like that

  • Can i use create function for MSSql scalar and table valude function.

    Hi,
    1) Can i use create function for MSSql scalar and table valued function?
    2) How many type of user defined function are there in oracle 11g express?
    3) And can i reture any "type" form user defined function?
    yourse sincerely

    944768 wrote:
    Q1)That means even if i return predefined types like integer, varchar2 then also PGA is used ?The data type does not determine where the variable is stored. A string (called a varchar2 in Oracle) can be stored in stack space, heap space, on disk, in a memory mapped file, in a shared memory, in an atom table, etc.
    It is the who and what is defining and using that string, that determines where and how it is stored.
    The Oracle sever supports 2 languages in PL/SQL. The PL (Programming Logic) language is a procedural/declarative language. It is NOT SQL. SQL is integrated with it. The PL/SQL engine uses private process memory (PGA). So PL/SQL variables exist in the PGA (but there are exceptions such as LOBs).
    Q2) So please suggest me solution in oracle.Sounds to me you are looking at how to implement a T-SQL style function as an Oracle function, and once implemented, do joins on the function.
    Do not use PL/SQL in SQL in place of a SQL select. It is not T-SQL.
    One cannot use PL/SQL to create functions along the style of T-SQL, where the function executes a SQL using some conditional logic, and then return as if the function was a native SQL select.
    T-SQL is an extension to the SQL language - making it a hybrid and very impure language implementation. PL is based on ADA - part of the Pascal family of languages. The E-SQL (embedded SQL) approach used in languages like C/C++, Cobol and Ada, has been transparently done in PL/SQL. You can write and mix PL code and variables with SQL code. And the PL/SQL engine figures out how to make the call from the PL/SQL engine to the SQL engine.
    But PL/SQL is not "part" of the SQL language and does not "extend" the SQL language in a T-SQL fashion.
    So you need to check your SQL-Server preconcepts in at the door, as they are not only irrelevant in Oracle, they are WRONG in Oracle.
    The correct way in Oracle, in a nutshell - Use the SQL language to do data processing. Use PL/SQL to manage conditional process flow and the handling of errors.

  • Create function for ODD or EVEN(NUMBER)  in pls sql

    create function for ODD or EVEN(NUMBER) also
    if number is odd multiply by 5
    if number is even multiply by 10;

    865253 wrote:
    create function for ODD or EVEN(NUMBER) also
    if number is odd multiply by 5
    if number is even multiply by 10;
    create function fn_get_no (n_in in number) return number is
    o_num number;
    begin
    if mod(n_in,2) = 0 then
    o_num := n_in*10;
    else
    o_num := n_in*5;
    end if;
    return o_num;
    end;
    select fn_get_no(5) odd, fn_get_no(4) even from dual;
    ODD EVEN
    25 40 Vivek L

  • Can you create a "constructor" for movie clips?

    What I'm doing:
    var this_array[counter] = new monster; //monster is a movie clip
    init_monster(); //set's things like .name, .x, .y, etc.
    What I want to do:
    var this_array[counter] = new monster();
    When I add a "monster"  I then call a function to "initialize" all of it's stats.
    Is there a way in the creation of the object, like with a constructor, where it automatilly does it on 1 line?
    I'm teaching myself and am a little stuck on this part.  If I have to create a "monster class" to do what I want just say so.
    Any simple examples or links to simple examples would be great. Thanks in advance.

    Ok so I've made a class Monster, and I have my movie object Red_Monster
    How would I go about creating the variable so it knows it's both?
    The only thing I can think of is linking them together as a .variable of the other.
    Example:
    var this_monster[x] = new Red_Monster();
    this_monster[x].stats = new Monster();
    It just seems a bit slopy, it would be nice to have this_monster know it's both.  Is there a way to do that?
    (added)
    I've gotten Monster to extend MovieClip, and this is working to use it as a movieclip.
    Currently trying to change the image of the movie clip in code to Red_Monster. Is there a way to do that?
    (added)
    Found how to do it, sort of.  Change the class linkage name to Monster instead of Red_Monster.  I just have to make classes for each movie clip.
    (last add, answer for anyone else)
    Ok the answer is to create a Monster class that extends MovieClip.  Then for each color_Monster they all extend Monster, no other code needed inside each class other then the constructor.

  • How do I create a play button for movie clip using AS3

    Hello.
    Bit new to this and have been searching the adobe forums and google. I am trying to create a button that will play an imported MovieClip.
    I have a movie clip that I've imported into it's own layer (Layer1) Frame 1.  I've given the MovieClip an instance name of foundationMovie.
    I've created a button and have that on its own layer(Layer2) above layer1, it is also in Frame 1.
    I've added a
    stop (); action to layer2
    The video is not set to autoplay.
    I want the video to start playing when the viewer clicks the button.  I know I've got to put some kind of event listener using AS3 in my timeline somewhere.
    I've found some code and I've been trying to work with it.  I'm sure I've mutilated it beyond usability but this is what I've got.
    stop ();
    player.addEventListener(MouseEvent.CLICK,play);
    function play(event:MouseEvent)
    gotoAndPlay("foundationMovie");
    If someone could point me the right direction or help me with my code I would really appreciate it.  Thanks.

    First, you need to clear up what you are working with... a movieclip and a video are usually entirely different things.
    Next, your code may get you started on your way with some changes.   You shouldn't use "play" as a function name due to there already being a play() method/function in Flash.
    If the movieclip is a movieclip and has an instance name of "foundationMovie", and your button has an instance name of "player" then the following adjusted code would normally work...
    stop ();
    player.addEventListener(MouseEvent.CLICK,playMovie);
    function playMovie(event:MouseEvent)
         foundationMovie.play();

  • 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

  • Need back and forward functions for moves

    I have a working tictactoe game with implemented back and forward moves buttons, but i don't have any idea how to create the two functions using linked lists. can anyone please suggest these functions and provide some code snippets?

    Java4Geek wrote:
    that's the problem! i'm not using anything for move storing (yet) because I am confused about what exactly needs to be stored for a move. should be something like a node of (player, player's move, opponent's move)?why would you want to store the move AND the opponent's move in a single node? (not saying you're wrong, just wondering why you'd want to do that.)
    Think about the information that you'd need to know in order to go backward or forwards.
    Would you need to know which player made the move?
    Would you need to know what the player's move was?

  • How do I View Guides for Movie Clips in Relation to Entire Scene?

    My boss purchased a flash animation from a company a few months ago that she now needs me to fix. The goal is to resize the animation to different dimensions for a new banner. I took the original file, brought up the document settings, and changed the size to the new one we need, and hit the "scale content" checkbox. The file I have after doing this is shown below; I have highlighted the shape I will be talking about in pink. Nothing is the correct size now so I am trying to resize them to fit the stage area. I am having trouble with the green shape that is highlighted Pink.
    The person who originally made this file made that highlighted shape into a movie clip and then dropped it in to the main timeline. I was wondering if there was a way that I could see where that shape is in relation to the area of the entire stage and the other objects in the main timeline? Meaning if I am inside of the greenblock movie clip all I see is what is below:
    With this view I cannot tell where that shape is in relation to everything else. I am hoping someone can tell me how to view the guides from my main file inside of this movie clip( I already have guides turned on), or any other way of seeing what size and where my shape is in relation to rest of the objects on the stage of my main file. I would take any option that would let me tweak the green shape inside of the movie clip and see in real time how it looks in relation to the rest of the items on the stage as I make changes.
    Any suggestions on how to get perspective on where my movie clip is in relation to the stage and other objects on it would be greatly appreciated.
    Sincerely,
    Tissal

    Somehow double clicking on your system seems to be connected to the command
    fl.getDocumentDOM().enterEditMode('');//the view where you don`t see the rest of your stage
    whereas normally it defaults to
    fl.getDocumentDOM().enterEditMode('inPlace'); //the view where you can see everything els on stge alphablended
    you can either create a shortcut to
    edit>edit in place or alter the standard behaviour of your double click
    or right click(Windows) or ctrl-click(MAc) the mc and choose Edit in Place

  • Formats for movie clip used in PSE 4 slide show

    Still finding it difficult to find documentation of what formats are supported for using digital camera movie clips in PSE 4 slide show.
    The movie file from my Canon camera is 640 x 480, 30 fps Motion JPEG and has a .AVI extension. I am able to use it "as is" in a PSE 4 slide show. However, sometimes I need to trim the movie clip in Windows Movie Maker 2 in order to keep only the best part.
    My question is what parameters can I specify to save my movie clip in Movie Maker 2 so that I can use it as a movie clip in a Photoshop Elements 4 slide show that will be saved as a WMV file?
    Barb O

    Karin Sue,
    >Also, are the projects saved in a folder somewhere, or only as part of the Catalog?"
    The definition of the "project", which is the "Creation" in Organizer terms is saved only in the Catalog.
    >If you publish your creation as a pdf or wmv they are saved in the folder you designate. Once published, I don't believe there is any way to edit. If you save the creation, you can go back and edit and republish if you like.
    Yes, the WMV or PDF file is saved in the folder that you designate. You are correct that if you save the Creation, you can go back and re-edit. When you Save the Creation gets a thumbnail within the Organizer photo well and you can click on the thumbnail to go back in to the Creation process make modifications and save a new WMV or PDF file.
    Note: that the Save window documents that the PDF choice does not support some options such as Pan and zoom, videos, and certain transitiions.
    Barb O

  • Movie Clip "Play" problem

    Dear all
    I have a singl movie clip which has an embedded video inside.
    I use the following actionscript commands to stop and play it
    onClipEvent(load) {
    stop();
    onClipEvent(mouseDown) {
    play(); }
    onClipEvent(mouseUp) {
    stop(); }
    The problem I face is that the movie clip should play when
    clicked by mouse ONLY on movie clip area which occupies only a
    small part of the stage. However, when I click the mouse ANYWHERE
    on the stage the movie starts to play.
    Any hint? Do I need to control the coordinates of the mouse ?
    Thanks
    Hagop

    sorry, I made a mistake- i had not re-saved my files, so it
    worked but not the way i thought...
    my code, based on your response is attached- however it
    doesnt work...
    mcOther is a mc within the "child" - other.swf.
    this code needs to be in the "parent" swf...
    thank you.

  • Can I create folders for movies in iTunes like playlists for music

    I have a lot of TV series that I have ripped into ipad compatible format.  I want to be able to put them into a folder like a playlist for movies so I don't have to scroll forever to find them.  If I need to use genre how do I tag the movies so they get sorted?

    Use MetaZ to tag the files as TV Shows and the correct series and all other info.
    -> http://www.macupdate.com/app/mac/36029/metaz

  • Checking files for movie clips

    Hi,
    Is there a quicker way to do a global search within a large
    flash file to see if any movie clips still exist, without having to
    open every frame & check ea symbol individually on the timeline
    to check in addition to searching the library?
    thanks.

    use the Movie Explorer.
    --> **Adobe Certified Expert**
    --> www.mudbubble.com
    --> www.keyframer.com
    dmc99 wrote:
    > Hi,
    >
    > Is there a quicker way to do a global search within a
    large flash file to see
    > if any movie clips still exist, without having to open
    every frame & check ea
    > symbol individually on the timeline to check in addition
    to searching the
    > library?
    >
    > thanks.
    >

  • External SWF or internal symbol for movie clips

    I'm creating a Flash interactive thing which is basically a couple minute animated intro and then a menu of products to choose from. You click on one of 12 products and get a little animation about how it works. So my question is where to put these 12 product animations? I was originally thinking to just put them in the main timeline and just jump to them with labels but I'm thinking that the timeline is going to get too hairy, it's already got a lot. Now I'm wondering what the best approach should be. Should I produce 12 external SWF movies to be loaded when clicked on, or should I just make each product animation an internal movie symbol and just add an instance from the library to my main timeline? Or is there any other approach that might be better for some reason?
    Thanks,
    ~peter

    yes, as i mentioned, guidelines can be given:
    1.  loaded objects won't display as quickly (unless they're preloaded) as embedded objects.  they must load before they can be displayed
    2.  using loaded objects decreases the size of the main swf (and therefore decreases the main swf's load time) when compared with embedding objects in swfs.
    and, as for loading vs embedding swfs, the above still applies.  but there's one over-riding factor when considering swfs:
    3.  embedded swfs have their actionscript, if any is present, disabled.  so, almost always, you load, not embed swfs.

Maybe you are looking for

  • Checks Boxes in a Grid

    Hi Experts, I am binding my data to a grid and after that i have added a check box column as last column and i kept the Grid Collapse level as  2.My data is binded as following COL1                COL2           COL3                     COL4   A     

  • What does the "S" mean in reference to lenses? EF-S vs EF lens?

    I have both a digital camera, the 60D, and recently acquired an EOS 1N 35mm film camera.  I have bought lenses for my 60D but not the 1N film camera....was told that my 18-55mm lens for my 60D would not be interchangeable with the 1N?  So, EF-S vs EF

  • Error in solution email...

    I just got an email saying one of my answers had been selected as a solution - it hadn't, I had selected a solution. Also, there was an undefined variable in the email. See the screenshot. Liam Super User/Rock Star on the Spotify Community!

  • How to install two oracle database on one system

    i want to install two oracle databases on single system how it is possible how i can manager oracle home and is this possible to install two different version of oracle in single home or single system forexample oracle 9 and oracle 8 . A.R

  • Help pls, abstract

    im trying a calculator proram to run it and i keep getting this error, im stuck. can anyone please advice me on what to do. thanks in advace the error: C:\Program Files\calc.java:8: calc should be declared abstract; it does not define actionPerformed