A Flash Developer Resource Site

Results 1 to 7 of 7

Thread: change coordinates for movie clip using numeric stepper

  1. #1
    Member
    Join Date
    Mar 2014
    Posts
    32

    change coordinates for movie clip using numeric stepper

    Hello!

    I really have no idea, how this would work, what code would do this action.
    So I have a numeric stepper with an instance name my_nstep, then I have an object mc_mill, which coordinates the numeric stepper should change(if numeric stepper is pressed up, then mc_mill goes up for 5 pixels, if numeric stepper is pressed down, then mc_mill goes down for 5 pixels)
    And also I have like these molecules - mc_mol, which would have to get compressed down or expand also with the nummeric stepper..


    I know my code is totally wrong and Im sorry for that, but im really a noobie in coding..

    so..this is how I tried to wrote it :

    if(NumericStepper++);
    mc_mill.y=5++;
    else {
    if(NumericStepper--);
    mc_mill.y=5--;
    }


    this is the .fla file : numstepper.fla

    I hope You understand and can help me
    Thank You!!!

  2. #2
    . fruitbeard's Avatar
    Join Date
    Oct 2011
    Posts
    1,785
    Hi,

    You need to remove the small bit of you code have as it won't work with the numeric stepper, try this
    PHP Code:
    my_nstep.minimum 0;// *** minimum value;
    my_nstep.maximum 100;// *** maximum value;
    my_nstep.stepSize 5;// *** Step amount; you can use decimals like so, my_nstep.stepSize = 0.25
    my_nstep.value 50;// *** Initial value;

    // *** set mc_mill to numeric initial value, not necessary, but needed so you can make changes to layout;
    mc_mill._y my_nstep.value;

    // *** Create listener object
    var my_nstepListener:Object = new Object();
    my_nstepListener.change = function(e:Object)
    {
        
    // *** Make changes to _y value;
        
    mc_mill._y e.target.value;
        
    // *** Traces;
        
    trace(e.target.value);
    };

    // *** Assign lisenter to object;
    my_nstep.addEventListener("change",my_nstepListener); 
    you may need to change the layout a bit or put the mill inside of a clip and associate the _y values accordingly

  3. #3
    . fruitbeard's Avatar
    Join Date
    Oct 2011
    Posts
    1,785
    Hi,

    If you wish to have a non input text field with the numeric stepper, then add
    PHP Code:
    my_nstep.inputField.editable false

  4. #4
    Member
    Join Date
    Mar 2014
    Posts
    32
    Oh My God, thank You for such a great great reply! The code is fantastic and Your help is much appreciated!
    One small thing is that it works in the opposite directions - when num stepper is pressed up, the mill goes down, and when num stepper is pressed down, the mill goes up. But im gonna try fixing it.

    Thank You again!
    Last edited by Miamii; 03-16-2014 at 10:08 AM.

  5. #5
    Designer, Programmer, Musician angelhdz's Avatar
    Join Date
    Mar 2010
    Posts
    971
    PHP Code:
    //IMPORTANT: We set the the height of your canvas here,
    //so the reverse script works
    var StageHeight:Number 400;
    //////////////////////////////////////////////

    my_nstep.minimum 0;// *** minimum value; 
    my_nstep.maximum 400;// *** maximum value; 
    my_nstep.stepSize 5;// *** Step amount; you can use decimals like so, my_nstep.stepSize = 0.25 
    my_nstep.value 50;// *** Initial value; 

    // *** set mc_mill to numeric initial value, not necessary, but needed so you can make changes to layout; 
    mc_mill._y my_nstep.value
    mc_mill._y StageHeight my_nstep.value;



    // *** Create listener object 
    var my_nstepListener:Object = new Object(); 
    my_nstepListener.change = function(e:Object

        
    // *** Make changes to _y value; 
            
    mc_mill._y StageHeight e.target.value;
       
        
    // *** Traces; 
        
    trace(e.target.value); 
    }; 

    // *** Assign lisenter to object; 
    my_nstep.addEventListener("change",my_nstepListener); 
    Already mastering AS3. It was so fun. Now into Javascript and PHP and all its libraries

  6. #6
    . fruitbeard's Avatar
    Join Date
    Oct 2011
    Posts
    1,785
    Hi,

    If you haven't adapted it yet or figured it out, perhaps you did it by yourself?

    Although Angels was ok you were confined to the StageHeight var which is not so good if you want to move things around and the pusher did not stay within the jug when pressed, so I converted the graphics to a movieclip and so on.

    Its CS5, low as I can go

    Converting my AS2 hobby to AS3 http://fruitbeard.net/as3/site

  7. #7
    Member
    Join Date
    Mar 2014
    Posts
    32

    Thumbs up

    Once again HUGE thanks for the help

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  




Click Here to Expand Forum to Full Width

HTML5 Development Center