How to drag an object in case like this?

Hi, with the little I know about Action script after reading and following a book I decided to exercise on my own by trying to drag on object that changes its 2 children when the mouse clicks. I'm sure there are much better  ways to do that but nevertheless I expected my script to give expected results but it doesn't. The problem is that when I create/change the children by clicking they don't appear under the mouse but at some different offsets depending on where the clicking is. Why is it doing this?
function makeBox():void {
     box = new Shape;
     box.name = "Box";
     box.graphics.beginFill(0x66FF00);
     box.graphics.lineStyle(5, 0x6600CC);
     box.graphics.drawRect(mouseX, mouseY, 50, 50);
function makeOval():void {
     oval = new Shape;
     oval.name = "Oval";
     oval.graphics.beginFill(0xFF3300);
     oval.graphics.lineStyle(3, 0xFFFFFF);
     oval.graphics.drawCircle(mouseX, mouseY, 25);
var box:Shape;
var oval:Shape;
var Clip:MovieClip = new MovieClip;
addChild(Clip);
stage.addEventListener(MouseEvent.MOUSE_DOWN, onClicking, false, 0, true);
function onClicking(some:MouseEvent):void {
          if (Clip.numChildren == 0) {
               makeOval();
               Clip.addChild(oval);
          } else if (Clip.getChildAt(0) == oval) {
               makeBox();
               Clip.addChild(box);    
               Clip.removeChild(oval);
          } else {
               makeOval();
               Clip.addChild(oval);
               Clip.removeChild(box);
     Clip.startDrag();         
I will greatly appreciate your help

I haven't deduced why as yet, but the following revision of your function code appears to do what I believe you expected you'd see...
function onClicking(some:MouseEvent):void {
    if (Clip.numChildren == 0) {
               makeOval();
               Clip.addChild(oval);
          } else if (Clip.getChildAt(0) == oval) {
               makeBox();
                box.x = -Clip.x;
                box.y = -Clip.y;
               Clip.addChild(box);    
               Clip.removeChild(oval);
          } else {
               makeOval();
                oval.x = -Clip.x;
                oval.y = -Clip.y;
               Clip.addChild(oval);
               Clip.removeChild(box);
     Clip.startDrag();
I played with numerous aspects before coming to this conclusion.  The change I made is based on observing that wherever I click on the stage relative to the 0,0 axis of the stage becomes the position of the added Child relative to the place where I clicked ... you have to watch it to see what I mean, but if I click at 100,100, Then the objects lands 100,100 from that point (200,200). I may play with it more, but I may wait to see if kGlad or someone else stops in and knows right off what's at play here.

Similar Messages

  • How do I create & edit a pattern like this in Illustrator?

    I want to know how to create and edit a pattern like this in Illustrator:
    And then be able to do this:
    (same pattern with blue square effect)
    Any advice would be appreciated.

    Read up on creating patterns. This one is just simple lines and very easy to do, but remember that the defining rectangle MUST be at the very back of the stack:
    Start off by making your pattern tile (top). Drag the drawing to the Swatches panel.
    Fill a rectangle with the pattern. Scale and rotate the pattern fill (see Scale and Rotate dialogues).
    Recolour the pattern using Edit > Edit Colors > Recolor Artwork

  • How Can I Speed Up My Video Like This? (Example Included)

    iMovie is currently optimizing my video so figured i'd ask this now rather than when i'm editing.
    I recorded video of myself getting a haircut and would like to speed the video up and add some music to it; similar to this video i found on youtube.
    How can I speed up the film like this and slow it down as done in this video?
    http://www.youtube.com/watch?v=-OmFShCpXSU

    Quite easy to do.
    Watch the tutorial here:
    http://www.apple.com/ilife/tutorials/#imovie-timing
    You can access these tutorials and ask questions from within iMovie Help.
    Regards,
    Z

  • How do I make my terminal look like this?

    Hello, I'm trying to figure out how this guy made so his terminal look the way it does.
    I've searched around some sites but I can't really figure out what to look for as I don't know the name of the application or what it really is, just that it looks like that.
    http://sites.google.com/site/gotmor/dze … xmonad.png

    Rob (the dzen dev, IIRC and BTW) is probably using urxvt as a terminal. The prompt is a two-line prompt like this one, you'll need zsh for it. Also, he uses XMonad, a tiling window manager, which doesn't draw any window decorations, so there's no close/maximize/minimize buttons or title bar. Good luck getting into them all, you're in for quite a journey.

  • How to design a dashboard to look like this link

    Hi all
    i have been trying to search for links/ papers or documents to help me to design my dashboard to look like this
    https://www.google.com/search?biw=1600&bih=775&q=oracle+bi+dashboard+examples+11g&bav=on.2,or.r_cp.r_qf.&bvm=bv.51495398,d.cGE,pv.xjs.s.en_US.M4-36_38X9A.O&um=1&ie=UTF-8&hl=en&tbm=isch&source=og&sa=N&tab=wi&ei=ShImUsXtFqr3iwLe8YHgCg#facrc=_&imgdii=_&imgrc=O-rJev3XQgdMQM%3A%3BQC-E1G4bmJozeM%3Bhttp%253A%252F%252Fshivabizint.files.wordpress.com%252F2013%252F06%252Fsample_app_v305.jpg%3Bhttp%253A%252F%252Fshivabizint.wordpress.com%252Fcategory%252Fobi-ee%252Fobiee-11g%252F%3B1109%3B542
    can anyone who has it or has a document share it or share his knowledge how to do it please ?
    thanks

    The Oracle By Example has a series of tutorials that will get you a very basic understanding.  Designing dashboards is a process that requires you to understand both Data Visualization practices and knowledge of the tool you are working with.
    Please review the following
    http://www.oracle.com/technetwork/middleware/bi-enterprise-edition/tutorials/obiee11g-453435.html
    Oracle BI Analytics and Dashboards 11g
    Oracle BI EE (11.1.1.7): New Features - (New)
    Creating Analyses and Building Dashboards 11g  (OBI EE 11.1.1.6.2BP1)
    Creating Analyses and Dashboards 11g
    Creating and Using Action Links and Actions
    Creating and Deploying Custom Styles, Skin, and Messages in Oracle BI 11g 
    Sending Alerts in Oracle BI EE 11g by Using Oracle BI Delivers 

  • How can I do a Background image like this (example inside)

    Check this out:
    Click Here
    Notice if you view the background image by itself, its much bigger than what is appearing on the website in the browser.  Is it set to automatically adjust to your monitor size?  How can I achieve this through CSS?
    Also, how can I setup a transparent background (like in the middle of the page?)
    Thanks

    "Is it set to automatically adjust to your monitor size?  How can I achieve this through CSS?"
    It's an illusion.  The body background image is defined with a fixed position, so the image is actually floating off to the left when viewport width is decreased.  Another example of this can be seen here along with the CSS code used to create it.
    http://alt-web.com/DEMOS/fixed-background.shtml. 
    Nancy O.
    Alt-Web Design & Publishing
    Web | Graphics |  Print | Media Specialists
    www.alt-web.com/
    HTML Validator -  http://validator.w3.org
    CSS Validator - http://jigsaw.w3.org/css-validator/
    Tutorials - http://w3schools.com/

  • How to do pop-up text box like this?

    On 1-800-Flowers website home page if you hover over the thumbnails a text box pops up in the the bottom right corner, is there an action in GoLive that can do something like this? It's nice how they have everything in one cell and when doing a onmouseover it does the "shadowOver(event,this)".
    http://ww22.1800flowers.com/
    Thanks,
    Wesley

    Is it possible to just have a text message pop up in a box (table) onmouseover? Such as:
    http://www.dynamicdrive.com/dynamicindex5/popinfo2.htm
    I've been working with this script but it is required to have this javascript within the head.
    Thanks,
    Wesley

  • How can I export the same quality like this video ?

    I found this video and upload here :
    http://www.mediafire.com/?4uoygmlvfm5uccu
    HD 720p
    and the file size is very small : 3.87 MB with length : 38s but has very good quality.
    Does anyone know how to render like this ?

    I can only guess what you want exactly.
    To make the top menu item move left when the cursor overs above it tou could do something like:
    ul.MenuBarHorizontal a.MenuBarItemHover, ul.MenuBarHorizontal a.MenuBarItemSubmenuHover, ul.MenuBarHorizontal a.MenuBarSubmenuVisible {
       margin-left: -3em;
        width: 8em;
    I hope this helps.
    Ben

  • How can I implement a check constraint like this

    A column can have this values: first 3 letters can be �ing� �fig� �erd� then it can either have �1,2,4,5� and then 3 more numbers.
    Like this: ing1003 or fig2432 etc.
    I have tried this:
    columnName LIKE �[ing-fig-erd][1-2-4-5][0-9][0-9][0-9]�
    But it doesn�t work. I have been looking around and haven�t found anything that can help me with this.
    Anyone got any suggesting?
    Cheers
    envida

    CHECK(code LIKE '[ing,fig,erd,][1,2,3,4,5][0-9][0-9][0-9]'))This is a regular expression. Oracle database does not yet support regular expressoions (10g will). So what it is actually doing is apllying the whole string as a literal. Because there are no wild cards, any row where code literally does not equal '[ing,fig,erd,][1,2,3,4,5][0-9][0-9][0-9]' will fail i.e. all of them.
    If you really want to use regular expressions either have a look at the PL/SQL package OWA_PATTERN or consider importing the Java Regexp package and implementing some Java Stored Procedures. Alternatively you can could cook up something using translate or replace.
    Cheers, APC

  • How to add button on heading just like this page in template?

    Hi,
    I'd like to create template that have many buttons on heading
    just like this page. But in the wizard to create template, it
    can only add three button: one for application,another for
    home,and the other for help. What should I do? Do I create
    template by coding? Please tell me.
    Thanks,
    Sirin

    You need to use an unstructured UI template. Structured UI
    templates are not supported with Portal pages.
    Regards,
    Jerry

  • How can I get a free case like everyone else?

    I'm a 67-year-old grandmother who stood in line and upgraded to the iPhone 4 on June 29 so I could see my grandsons in another state when I talked to them on the phone. The only cases available when I bought the phone at the AT&T store were iFrogz. I assume this is one of the third party cases that Steve Jobs said won't get a refund? I spent the same amount of money that everyone else did, and now they will get a free case and I won't. Not fair.

    You can still get a free case, just not your money back for the one you have.
    Claim your new case and sell it on ebay if you don't want it.

  • How do I make a text stretch like this?

    http://www.youtube.com/watch?v=YYI9tK3o2YY
    Heroes word stretches at first. How do I make that? I've glowed it like there, and blurred out like that. But I can't figure out how to strech it.
    Also, how do I create those red circles around "O" at 6th second, tutorial would be nice. I'm fairly new to this program.

    I can't see what you've posted due to network restrictions where I work, but the text stretch sounds like stuff you could accomplish by a combination of animating the scale and some of the distort effects (like Bezier Warp, Corner Pin, Mesh Distort, etc.)
    Red circles might be particles, shape layer(s), or Radio Waves depending on how it looks (again, I can't see it).
    If you're new to AE, I highly recommend you start here first: [link] Go through all of the resources that page links to. It will get you up to speed on the basics of AE which will remove a lot of the frustration a newcomer can experience.

  • How will the ipad batery and screen like this ???

    hi!
    i plan on using my ipad in the dental surgery i am working in to stand most of the time on a dock.
    while standing on a dock i want it to run movies or slideshows with special offers, before after pictures etc and then i want to take it off the dock several times a day to show the patient his or her pictures i took before to explain findings.
    how would the screen like to run 8 hours a day? would it be bad?
    how would the batteries react to the ipad running 8 hours a day, most of the time on a dock with power supply but several times a day 5-10 min battery powered. would the battery have a new loading cyce every time i put the ipad back on the dock? would this use reduce the battery life of it?

    Most battery suppliers of Nickle-Metal Hydride batteries say leaving them on a charger all the time shortens battery life...but you really have to ask what does that mean with respect to the planned life of the display you are planning. Your own plans for changing to another display approach may make that concern moot.
    Apple provides this information on the iPad batteries:
    http://www.apple.com/batteries/ipad.html
    An important part of that is the recommendation of monthly complete charge cycles: drain the battery all the way, the unit shutsdown automatically at a charge level of 1%, or so. Then recharges on wall power to full charge. You could probably do that with a single days' usage as you have described.
    Since the unit would be constantly changing images, you would not have to worry about anything like display damage from burning pixels like you do with computer monitors.
    Why not get one and try it out and see what the patient reaction is? Sounds like a clever use to me.

  • How to create a revolving website list, like this...

    Hi there, Im new to flash, but the main reason I got it was so I could create an object to put on a webpage. I want to be able to create a revolving website list, with pictures of the sites in the list, like on the main page of this site:  http://www.tamberlow.com/
    Please can somebody help me? Or point me in the right direction
    Thanks for your time,
    Jackie xxx

    that's a (not very well-done) carousel.  you can search for:  flash <your actionscript version> carousel.
    most are horizontal but it's not much different to make one like the site you referenced.

  • How do a re-create a website like this?

    Hi there,
    I really like the design of this website - can anyone tell me how I go about re-creating it:
    http://www.bluedanube.ca/home.html
    I see that it's done with tables instead of CSS.
    Would it be possible to have the banner as a large image on the body table with all the content centered in a table or is this the wrong way to go?  How could I do it with the use of CSS.
    Please help!
    Slante!

    How could I do it better but keep the design looking cool?
    Your question is broad enough that entire college curriculums have been created to provide the tools to help answer such a question. Note that there is no one answer that can possibly apply to all situations. Thus the education is provided to give you the tools to answer that question for each project as it applies to that project. And believe me, cool in my generation does not equate to cool in today's up-and-coming generation. The definition of cool for a site needs to consider the target audience's definition of cool.
    And don't fall into the trap that some designers do. Sometimes, designs are created that, while gorgeous, are very difficult - or impossible - to navigate and become disfunctional. I am one who still believes that form follows function.
    Would a background image on the body suffice with the wrapper div centered?  Is this the way to go?
    Maybe
    I am not trying to discourage you from creating a gorgeous site. In fact, the company who designed the site[1] we've discussed has several other sites that are just as pretty, but, IMO, are much more useful. I just want you to keep some things in mind while creating your design.
    [1] Minimal has its place, too. Perhaps that was part of the goal for that site since it really does not have a lot of information to convey.
    Mark A. Boyd
    Keep-On-Learnin' :-)

Maybe you are looking for

  • Two iPhoto questions

    I am using iPhoto 9.2.3. 1.     How do I know if my library is "managed" or referenced"? 2.     On the HD, "iPhoto library" appears twice: {user name} > pictures > iPhoto library  Opens up all my photos. The other one: {user name} >  iPhoto library 

  • Process Message Processing delay

    Can anybody explain, why does it take longer time in SAP for a process message to process successfully? In CO54 - From the moment it gets created (yello light) to the moment when it is successfully processed (green light). We have an issue in one of

  • Another Verizon (Iphone) Data Plan Rip off!

    Once again Verizon is trying to rip off their customers by giving them no choice when it comes to data plans if you want an Iphone. Just like they tried to force data plans on Feature Phones last year,now if you want an Iphone you must spend $29.99 a

  • Just bought this PB12" 1,5G4  and have questions...

    I'm deaply in Love right now with this little computer... I've been an iBook user for quit a while and a Mac user for more. I have these few questions that you might be able to help out with. 1.- Heat, ouch, man this computer is hot, is it normal?? i

  • Backup games on the cloud

    Hi all, Hello, How to know what games are fully stored in the cloud (levels, trophies, progressions etc ...) Is Throne wars fully backed up for exemple? Regards.