[fla8] snap to object at runtime?

Hi all,
is there a way to enable some sort of 'snap to object' to
draggable
objects in a movie at runtime?
I'm creating a tiny app that will allow the user to drag
object and
align them side-by-side. Aligning them in a perfect way is
almost
impossible. If only I could get them to snap to their
nodes/corners...
Any idea?
thanks in advance.
tony

Writing a simple snap to grid function is pretty easy, and
may work well for
what you need. Essentially, you just test the _xmouse and
_ymouse using mod,
if mousePos % snapSetting == 0, then you know you're on a
grid point.
This should get you started:
var snapSpace = 10;
var myInterval:Number;
clipA.onPress = function(){
myInterval = setInterval(startDragging, 5, this);
clipA.onRelease = clipA.onReleaseOutside = function(){
clearInterval(myInterval);
function startDragging(clipRef:MovieClip){
if(_xmouse % snapSpace == 0){
clipRef._x = _xmouse;
if(_ymouse % snapSpace == 0){
clipRef._y = _ymouse;
Dave -
www.offroadfire.com
Head Developer
http://www.blurredistinction.com
Adobe Community Expert
http://www.adobe.com/communities/experts/

Similar Messages

  • How do I create multiple objects during runtime?

    I don't know how to create multiple objects during runtime, here's my problem:
    I get a String as input. Then I create an object called newobject. I put the object in a hashtable with the above string as key.
    Then comes the problem, in order to create a new object, I have to rerun the same class, which uses the same name (newobject) to create a 2nd object. Now my hashtable doesn't reference to my 1st object anymore...
    Is there anyway I can fill up the hashtable with different objects, and make each key point to each object it was supposed to?
    For those who want to see a bit of the program:
    public class PlayBalloon{
    public Hashtable ht = new Hashtable();
    for(){
    Balloon pB = newBalloon;
    newBalloon=new Balloon(pB);
    ht.put("Some input from user", newBalloon);
    for(){
    ht.get(s).draw;<= s=string, draw=own meth. in Balloon
    }

    I think i can see the problem that you are having. You have, in effect, duplicate keys in your hashtable - ie, two strings used as keys with the same name.
    The way that a hashtable works is as follows...
    When you ask for a value that is mapped to a key it will go through the table and return the first occurence it finds of the key you asked for. It does this by using the equals() method of whatever object the key is (in your case it is a String).
    If you cant use different Strings for your keys in your hashtable then i would consider writing an ObjectNameKey class which contains the String value that you are trying to put in the hashtable and an occurrence number/index or something to make it unique. Remember to override the equals method in your ObjectNameKey object or else the hash lookup will not work. For example
    class ObjectNameKey {
        private String name;
        private int occurence;
        public ObjectNameKey(String name, int occ) {
            this.name = name;
            this.occurence = occ;
        public String getName() {
            return name;
        public String getOccur() {
            return occurence;
        public boolean equals(Object o) {
            if (!(o instanceof ObjectNameKey)) {
                return false;
            ObjectNameKey onk = (ObjectNameKey)o;
            if (onk.getName().equals(name) && onk.getOccur() == occurence) return true;
            return false;

  • How to create a text object at runtime?

    Hi,
    I am using crystal reports for visual studio 2010 and using c# to programming.
    I need to create  a text object in a specific section like section 2. and also I need to control the text object's position and text.
    I tried to move a object like:
    reportDocument1.ReportDefinition.Sections[j].ReportObjects<i>.Left = 0x8760;
    but object's position doesn't change at all.
    How can I do these (create a text object and change a object postion)?
    Thanks

    Hi Don,
    Thank you.
    I have downloaded a RAS ( report application Server ) sample.
    The sample uses the Business Objects Enterprise XI release 2. I am using win 7 and crystal reports for vs2010. Can I use this version of crystal reports to create  a text object at runtime? If not, what is the lowest version I have to purchase to achieve what I want?
    Basicly I need following capabilities at runtime:
    1) craete text objects, line objects, image objects.
    2) change text object, line object and image object positions, sizes, values of text object. If can I like to be able to change font as well.
    3) supress objects, sections. 
    4) change section's height

  • Custom Annotation :: inject object at runtime

    I would like develop a custom annotation to inject object at runtime. The annotation will work as follows
    1. develop ValidatorClass annotation on type.
    2. If annotated on a type object will be created at runtime and injected to the object. e.g. in class A it will inject validatorimpl object to vald object/
    Please let me know how to implement that.
    package com.debopam.validate
    public interface validator{
    public String validate();
    package com.debopam.validate
    public class validatorimpl implements validator{
    public String validate(){
       return "true";
    pckage com.debopam
    public class A{
    @ValidatorClass(name="com.debopam.validate.validatorimpl")
    validator vald;
    }

    yogeshd,
    It might be that the .class file for the annotation that you are compiling against is the one you have given us the source code for above, but when you run the program, the class file for the annotation is not the same, and is one that was compiled before you added the static field.
    This can happen if your classpath is wrong. (and would explain why the problem only occurs sometimes - because it is only failing when the classpath is wrong).
    If you run the following program with the Fully qualified name of your annotation as the argument, and with the same classpath as you run your program, it can tell you where it is finding the annotation class file. Check that this is the same one that you are compiling to.
    class WhereLoaded {
        public static void main(String[] args) {
            Class theClass=null;
            if(args.length > 0) {
                try {
                    theClass=Class.forName(args[0]);
                } catch (Exception e) {
                    e.printStackTrace();
                    theClass=Object.class;
            } else {
                System.out.println(
                    "The first argument should be a fully qualified class name," +
                    " using java.lang.Object instead"
                theClass=Object.class;
            String name=theClass.getName();
            name=name.substring(name.lastIndexOf(".")+1) + ".class";
            System.out.println(name + " loaded from " + theClass.getResource(name));
    }regards
    Bruce

  • Populating a authorisation object at runtime...

    Hi,
    how to populate a authorisation object at runtime? is it possible to have a variable etc that can be populated a runtime?
    I have a object zsales_off which has different values for different users. i need to create separate roles just to have different values for sales office for different users. i would like to avoid this by having a single role with the zsales_off getting populated at runtime.
    Details steps with code will be appreciated.
    thank you.

    Hello AHP,
    i am not still very clear about the detailed steps to be carried out as i am a novice in abap.
    i have created the authorisation variable and am using it in the query. if i manually assign values for sales office in the role, it is working fine.
    i want to assign values at run time. i am confused with the process as such.
    few doubts like:
    1> the variable should be of "authorisation" processing type or "customer exit" processing type.
    2>what to use I_step=0 or I_step =1? how to use? where to use?
    3>to write a abap code or use a func module, which one? how to use.
    any example(like in my case different sales office values for diffrent users) with DETAILED STEPS & CODE would be appreciated.
    also i need to have multiple single values for each user(but not interval).
    Please help.

  • Object with runtime number '0' not defined

    Hello,
    We have a problem in one step of the workflow we created for sales orders.
    The following are the errors:
    EXECUTE_METHOD_OBJECT_SYNC -> Object with runtime number '0' not defined
    EXECUTE_METHOD_BOR -> Object with runtime number '0' not defined
    EXECUTE_METHOD_BOR -> Object with runtime number '0' not defined
    Object with runtime number '0' not defined
    Message no. OL808
    We have already seen all the binds and correct.
    Thanks!
    Ariel Prebianca

    Associated message no with message 'Object with runtime number '0' not defined' is OL 808.
    Check Note 1322173 - Wrong error msg raised in BP_JOB_READ of interrupt process. It may not directly solve the issue but it will help you show correct message.

  • Creating and compiling JavaFX objects at runtime

    I am interested in the possibility of creating JavaFX objects at runtime where their definition is not know until runtime and am unsure about how to do this. Clearly I will need the JavaFX Script compiler at runtime which I guess is not that much of a problem but I am looking to accomplish this within the browser context so it would mean that I need the compiler to be available as part of the standard JRE much in the same way as the JavaFX Script interpreter is to obviate the need for it to be downloaded.
    Does anyone know if the JavaFX Script compiler is available as a built-in component within the latest versions of the JRE? If not, is it planned to include it in the future (JSE 7 perhaps)?
    Thanks,
    The Gibbon

    Perhaps the thread [Dynamic Scripting, how?|http://forums.sun.com/thread.jspa?threadID=5379268] can help.

  • Creating View Objects at Runtime for Validation

    In Oracle® Application Development Framework
    Developer’s Guide For Forms/4GL Developers tutorial there is a topic about Creating View Objects at Runtime for Validation.
    Is there any sample code available for this topic?
    Please help
    Regards
    S Karar

    I have created a helper method . The code is given below
    protected ViewObject getValidationVO(String viewObjectDefName) {
    // Create a new name for the VO instance being used for validation
    String name = "Validation_" + viewObjectDefName.replace('.', '_');
    // Try to see if an instance of this name already exists
    ViewObject vo = getDBTransaction().getRootApplicationModule().findViewObject(name);
    // If it doesn't already exist, create it using the definition name
    if (vo == null) {
    vo = getDBTransaction().getRootApplicationModule().createViewObject(name,viewObjectDefName);
    return vo;
    // Validation_bc4j_project of type ApplicationModule not found
    and created a validation method.
    The code inside validation method is given below.
    public boolean validateAvgMr(Number data) {
    String batch_catg = getQuality();
    // Get the view object instance for validation
    ViewObject vo = getValidationVO("bc4j_project.v_sqc0150");
    if (getTestStage()=="DOLLOP" && getQuality()=="DECO")
    // Set it's bind variables (which it will typically have!)
    vo.setNamedWhereClauseParam("batch_catg","DECO");
    vo.executeQuery();
    Number dol_mr_lcl=(Number)vo.first().getAttribute("DolMrLclStd");
    setStdMrLcl(dol_mr_lcl);
    return true;
    return true;
    I have checked the validation view and it is returing value with the same bind variable value but is not returning any value when using inside this method validation.
    I have checked several times but can't find the fault in the code.
    Please help

  • Modify object in runtime.

    Ok, I wonder, since there is no simulation loop or anything, how do I modify an object in runtime. For instance, I want an object to check a variable for the color of the object. I also made a grid/surface with different y-values in the coordinates with lineArray, and would like to update the surface in runtime. How is this done, with behavious or something else?
    Thanks in advance.

    Yes, you use the Behavior framework for that. You can select different stimuli to activate a Behavior (elapsed time, number of rendered frames, user input, ...).
    PS: There is a simulation loop, but it's not under user control. But the Behavior framework interacts with it.

  • Naming Objects at runtime

    Hi all!
    I want to make instances of a class in a for loop then naming them for example something+i. so you would get somethig1, something2 and so on..
    or even maybe naming them after a string provided by the user.
    googlet it and found a previous posted thread where the replyes was that you couldnt do thi. I think it was missinterpiated a little. I know this is possible have seen it done at one time..
    Any tips would be greatly apriciated :)
    regeards
    Pelle

    Well, I am making the new object at runtime. So why
    shouldn it be possible to name it to?1) Objects do not have names.
    2) Variable names are determined at compile time.
    This is so because this is how the Java Language spec defines the language to work.
    http://java.sun.com/docs/books/jls/third_edition/html/j3TOC.html

  • Identify objects at runtime

    Is there a way to identify objects on a form at runtime other than items in blocks?
    For instance, I want to identify frames on a canvas, boilerplate (text labels), tabbed canvases, etc. at runtime without actually naming them - as in getting the names/ids programatically through maybe get_canvas_property() or get_form_property.

    You can use FIND_* built-ins for canvases and Windows - you can't address boilerplat objects at runtime.

  • How could I know the kind of an object in runtime ???

    Hi,
    Is there any way in order that I can to know the kind of a control (xfa object) in runtime (using JavaScript)?.
    What's the attribute for that?
    For example:
    Drop-Down List :
    choiceList
    Text-Field :
    textEdit
    Check or Radio-Button :
    checkButton
    Thank you in advance!
    Dan

    [email protected] wrote:
    > Hi,
    >
    > Is there any way in order that I can to know the kind of a control (xfa object) in runtime (using JavaScript)?.
    >
    > What's the attribute for that?
    >
    > For example:
    >
    > Drop-Down List : choiceList
    > Text-Field : textEdit
    > Check or Radio-Button : checkButton
    >
    > Thank you in advance!
    > Dan
    Dan,
    Try this in JavaScript: this.ui.oneOfChild.className
    Justin Klei
    Cardinal Solutions Group
    www.cardinalsolutions.com

  • What is the difference between data base objects and runtime objects

    What is the difference between data base objects and runtime objects

    Hi raja,
    data base objects means u can have the presence of these objects in the database.So the tables,searchhelps,structures,lockobjects comes under these ones.
    Runtime objects are created and destroyed after the program ends, any changes we make to them are temporary only.
    regards,
    nagaraj
    Message was edited by: nagaraj kumar nishtala

  • Getting Bitmap object at runtime

    When you load an external SWF at runtime and instantiate a symbol that contains a Bitmap object in the .fla file the type of the Bitmap is actually Shape at runtime. Without exporting the object for ActionScript is there any way to get the actual Bitmap object without using bitmapData.draw on a new object?
    Where I am going with this is I would like to use the object where a Bitmap type is needed without creating a new bitmap object for memory reasons but it seems like Flash turns this into a generic Shape object at some point.

    After doing some research it seems like I am basically stuck unless I give it a linkage name in the library which is not an option because this is a .swf that is going to be loading dynamically on an iOS device.
    Oh well =/

  • Dynamically catch a function call from an object at runtime

    Hi,
    I have a bit of an interesting question.
    Say I have a dynamic object named Foo. It may have a set of explicitly defined functions:
    public function helloWorld():String
         return "hello world";
    public function get name():String
         return "My Name";
    etc.
    I want to be able to create a further function
    public function handleFunctionCall(functionCall:String, args:Array):*
         trace("Function: " + functionCall + " was called with the arguments:");
         for(var i:int=0; i<args.length; i++)
              trace(args[i]);
    The purpose of this is so that I can declare the object Foo and then call any function and handle it accordingly at runtime.
    e.g.
    var foo:Foo=new Foo();
    foo.bar();
    foo.whathaveyou();
    foo.whatever();
    Hope someone can point me in the right direction.

    I'd be interested to know more about what you are trying to achieve, but the code below should work:
    public function handleFunctionCall( functionName : String, args : Array ) : *
       var functionToCall : Function = this[ functionName ];
       return functionToCall.call( this, args );
    For alternative approaches you may want to take a look at behavioural design patterns. The command or strategy pattern may suit your needs.

Maybe you are looking for

  • BPM for n:1 Scenario

    Hello All Experts, I just want to develop a scenario where records are picked up by JDBC adapter and sends it to other system (File Adapter) and to BPM. and BPM after receiving a records from JDBC will wait for a message(File name ) from system where

  • Unable to import data in FDM

    We are trying to load data into FDM and resulting in error : An error occurred importing the file . The view log is as follows what am i missing ** Begin FDM Runtime Error Log Entry [2008-09-26-19:08:59] ** ERROR: Code................................

  • Query in Tabke Maintanance Generator

    Hi, My requirement is : I am creating table maintanance generator for a table. In this table i have space id is the primary key other few fiedls are non primary keys. Now my requirement is when user enters non primary key fields in SM30 transaction i

  • Can I use adobe after effects with my project from premiere elements

    Wondering if I can use adobe after effects with my premiere elements project

  • Verify Your Account 11

    Several new users have asked why they cannot post links and images and receive the following message when they try: Body text cannot contain images or links until we are able to verify your account. Simply put, we are preventing spam. Typical users w