How to make my own grid and perform a "snap to grid" effect?

Hi! I am a newbie in flash and I am trying to create a puzzle like game (a chinese puzzle game called tangram). I am wondering what kind of functions should I use to create a "triangular" grid i.e. something similar to this ? http://img40.imageshack.us/img40/2259/triangulargrid.jpg. What should I do to make the movie clips to perform the "snap to grid" effect to this grid?I have tried to draw my own grid and used the "cacheAsBitmap" function to implent it, however it doesnt seems to be working. Is there any suggestions or tutorials to this problem? Thank you very much.

Well, the project you are taking is not a simple one. It requires quite an experience with AS3. It is not a few lines of code but an understanding of Flash display list model and how objects can interact. In addition, there is no a single solution but rather wide array of possible approaches depending on use case.
To illustrate, the code below draws a mesh that replicates the image in your first post. Do you think that this is enough from the standpoint of your AS3 knowledge to get you started?
This code needs Flash 10:
var side:Number = 400;
var s:Sprite = new Sprite();
var g:Graphics = s.graphics;
g.lineStyle(3);
//g.beginFill(0xFF8000);
g.drawTriangles(
     Vector.<Number>([     0, 0, side * .5, 0, side, 0,
     side * .25, side * .25, side * .75, side * .25,
     0, side * .5, side * .5, side * .5, side, side * .5,
     side * .25, side * .75, side * .75, side * .75,
     0, side, side * .5, side, side, side
     Vector.<int>([
          0, 1, 3,
          1, 2, 4,
          0, 3, 5,
          1, 3, 6,
          5, 3, 6,
          1, 2, 4,
          1, 4, 6,
          2, 4, 7,
          6, 4, 7,
          5, 6, 8,
          5, 8, 10,
          6, 8, 11,
          10, 8, 11,
          6, 7, 9,
          6, 9, 11,
          7, 9, 12,
          9, 11, 12
addChild(s);

Similar Messages

  • How to make images fade in and out

    how to make images fade in and out continuously

    HI,
    The Ken Burns effects can do this nicely. Available in the iLife suite of software.
    iLife 06 minimum requirements:
    http://support.apple.com/kb/HT2675
    iLife 06 - Amazon
    Carolyn

  • How do I make my own sounds and put them on a Midi controller?

    I want to be able to make my own sounds and program then into my midi controller.
    Is this possible? If so How do I go about doing it?

    Hey man, am I right in thinking you want to make your own sounds entirely and then map them so that they can be triggered to play by your midi controller? If so, the method I'm thinking is you're going to have to start coding. The program PureData http://puredata.info/ is a good place to start, it's free and there are a lot of online tutorials if you can be bothered looking, but you'll have to put in the effort of learning how to code it properly. This might be worth it if what you are asking is what I'm thinking you're asking. Otherwise, you'll have to make do with the sounds that Logic Express can create, which isn't exactly a limited set... Hope this helps.

  • How to program my own UPI and OPI?

    Hi,
    I just want to know how to program my own UPI and OPI. I want to
    add some features into the DBMS. Is there some one can answer my
    questions, or tell me where to find information? Thanks!
    null

    Follow the bouncing example
    package mil.army.logsa.sandbox.thread;
    import java.util.Observable;
    import java.util.Observer;
    public class RunnableExample implements Observer {
         public static void main(String[] args){
              RunnableExample e = new RunnableExample() ;
              e.exec() ;
         // This is here because you can't reference (this) in the static context of the main method
         private void exec(){
              System.out.println("Launching RunnableExample") ;
              System.out.println("Creating Thing") ;
              Thing t = new Thing(this) ;
              t.start() ;
              System.out.println("Shutting down RunnableExample") ;
         @Override
         public void update(Observable o, Object arg) {
              System.out.println(arg) ;
    class Thing extends Thread {
         private ObservableThing obsThing ;
         public Thing(Observer o){
              super() ;
              obsThing = new ObservableThing() ;
              obsThing.addObserver(o) ;
         public void run(){
              System.out.println("Starting Thing") ;
              for(int i=0; i<100; i++){
                   obsThing.notifyObservers(i + " is " + (i%2==0 ? "EVEN" : "ODD")) ;
              System.out.println("Thing is finished") ;
    class ObservableThing extends Observable{
         public void notifyObservers(Object o){
              setChanged() ;
              super.notifyObservers(o) ;
    }PS.

  • How to make an checkbox editable and uneditable within a single alv output.

    Hi,
    How to make an checkbox editable and uneditable within a single alv output depending on condition.
    I have used Reuse_alv_grid_display.
    In my output every checkbox is editable. i have used edit = 'X'.
    I want editable checkbox for correct value and uneditable checkbox for incorrect value in a single alv

    >
    Mukilansap wrote:
    > I want editable checkbox for correct value and uneditable checkbox for incorrect value in a single alv
    Use alv styles to achieve this, set the style for each record before displaying the ALV. Structure LVC_S_STYL.
    Take a look at the example BCALV_EDIT_02, it is OOPS based, but check how the style table is filled.
    regards,
    Advait

  • How to make google come up and not yahoo when i click anew tab

    how to make google come up and not yahoo when i click a new tab
    == This happened ==
    Every time Firefox opened
    == today

    You can use 1 of these add-ons
    [https://addons.mozilla.org/en-us/firefox/addon/newtaburl/?src=search
    NewTabURL ]
    [https://addons.mozilla.org/en-us/firefox/addon/new-tab-homepage/?src=search New Tab Homepage]
    with NewTabUrl you have more options
    thank you
    Please mark "Solved" the answer that really solve the problem, to help others with a similar problem.

  • Adobe Captivate 7 Project How to make Rollover cations, audio, and video work in HTML format?

    Adobe Captivate 7 Project How to make Rollover cations, audio, and video work in HTML format?

    Honestly, I don't even know why this is an option. The conversion to Flash is completely unusable.
    I have exported some things to Flash, and since I program in Flash all the time I was able to manipulate to work to some degree. Most text captions are built with multiple elements and completely fall apart.
    Sorry, I can't be of more help.

  • When you change PC how to make connection with iphone and new PC

    when you change PC how to make connection with iphone and new PC

    Yes, you can do it the same as any other database. The code would be similar.
    I'd also suggest you not to use the JDBC ODBC bridge for connection. There are other drivers available for that.
    Regards
    xH4x0r

  • How to make custom binary module and add to powershell?

    How to make custom binary module and add to powershell?
    I wish to add 'Microsoft.SharePoint.Client.dll' in powershell as binary module so I can use its intellisense.

    Hi Biraj,
    I replied to this in other thread
    https://social.technet.microsoft.com/Forums/en-US/a13c9cc8-7d53-46b5-b5bb-65404db2d347/how-to-make-intellisense-enable-in-powershell-in-csom-for-sharepoint-online?forum=sharepointdevelopment
    Kind Regards,
    John Naguib
    Senior Consultant
    John Naguib Blog
    John Naguib Twitter
    Please remember to mark this as answered if it helped you

  • If i make my own cloud and log out of the one me and my sister were sharing will she still get my messages ?

    if i make my own cloud and log out of the one me and my sister were sharing will she still get my messages ?

    Answered in your other post.

  • How to make the Page UP and down work on a table control screen?

    Dear all,
    Can some one suggest how to make the table control screen work with Page Up and Page down controls.
    when I press on Page down it works for the first time and after that i need to select the table to make it work the second time. it there a way I can make the index on the screen stay on the table control at all times.
    Regard,
    Vj

    Take this code as a referance:
    Sample code for vertical scrolling in PAI processing will look like this:
    MODULE user_command_XXXX INPUT. (XXXX is screen no.)
      CASE ok_code.
        WHEN 'P--'.
          CLEAR ok_code.
          PERFORM paging USING 'P--'.
        WHEN 'P-'.
          CLEAR ok_code.
          PERFORM paging USING 'P-'.
        WHEN 'P+'.
          CLEAR ok_code.
          PERFORM paging USING 'P+'.
        WHEN 'P++'.
          CLEAR ok_code.
          PERFORM paging USING 'P++'.
    *&      Form  PAGING
    *       Form to do scrolling for screen XXXX
    *      -->CODE   OKCODE value (P--, P-, P+, P++ )
    FORM paging USING code.
      DATA: i TYPE i,
            j TYPE i.
      CASE code.
        WHEN 'P--'. <table control name>-top_line = 1.
        WHEN 'P-'.
          <table control name>-top_line =
                  <table control name>-top_line - line_count.
          IF <table control name>-top_line LE 0.
            <table control name>-top_line = 1.
          ENDIF.
        WHEN 'P+'.
          i = <table control name>-top_line + line_count.
          j = <table control name>-lines - line_count + 1.
          IF j LE 0. j = 1. ENDIF.
          IF i LE j.
            <table control name>-top_line = i.
          ELSE.
            <table control name>-top_line = j.
          ENDIF.
        WHEN 'P++'.
          <table control name>-top_line =
                 <table control name>-lines - line_count + 1.
          IF <table control name>-top_line LE 0.
            <table control name>-top_line = 1.
          ENDIF.
      ENDCASE.
    ENDFORM.                               " PAGING
    Regards,
    Ravi

  • How to make a CD Jacket and print out Song order directly from playlist

    I was wondering if there was a way to make a CD Jacket with artwork from songs selected and also how to make a same size sheet to fit in the CD holder that has the exact song order and titles by printing out directly from your playlist.
    I am not sure I worded that right but hopefully you will know what I mean.
    Any help would be greatly appreciated.
    Thanks

    There is a pretty basic CD insert that you can print from iTunes, if I remember correctly it will print whatever artwork is attached to the first song in the playlist.
    Open iTunes, highlight the playlist in question, go to File>Print and choose the CD Jewel Caser Insert radio button. Theres also a little Theme menu.
    However you can get much more flexibility from a dedicated CD Cover program. I use Cover Star, it's inexpensive and makes good quality CD booklets, back covers and disc overlays. It will generated artwork for you or you can drag your own picture files to it. You can download a trial version from this link: http://autostylus.com/coverstar.html. It's fully functional apart from printing so you can play around with it and save the inserts until you decide if it's for you. Purchasing a license then releases the final function and anything you saved previously can be printed off.

  • How to make our own Ajax based custom compnent

    hi
    i want to make my own Ajax based custom compnent.
    i know JSF custom comppnents, but dont know how to add Ajax functionality in it.
    what should i have to learn for this.
    can any one guide me. if some one have code example it will be appreciated
    br,
    Haroon

    You can read tutorials or manuals from the suppliers of AJAX for JSF components. And of course take a look into the code.
    Examples:
    http://getahead.ltd.uk/dwr
    http://icefaces.org
    http://www.exadel.com/web/portal/products/VisualComponentPlatform
    https://bpcatalog.dev.java.net/ajax/jsf-ajax/
    Overview:
    http://www.jsftutorials.net/
    http://www.jsfmatrix.net/

  • How to make my own custom photo album background from scanned image?

    I know how to use the custom backgrounds within photoshop elements 5.0 but I would like to create my own. I have scanned a map of Big Bend National Park that I used as a DVD title menu and would like to make a photo album and use the same scanned map as the backgroud for all pages. Is that doable in elements 5.0? Can I just add the scanned image into the custom folders somehow?

    My thought is to create a single thread, and within
    that thread continually pull from a static array
    casting each to an EventObject type. But I am confused
    also as to how to dispatch the events to their
    appropriate listeners.This is commonly known as a ProducerConsumerQueue: you have multiple sources of events, and multiple consumers for those events. The queue mediates between producers and consumers.
    In the case of an event thread, the queue runs in one thread, and all the producers run in other threads. In the case of the Swing/AWT event thread, the producer is the GUI code in the JVM, which receives OS-level (considering X an OS for the moment!) window events and then puts them on the queue, associated with the correct object.
    You'll find a LinkedList a better choice for the queue than a static array, as it can grow or shrink without bounds. The consumer side calls removeFirst(); if nothing's in the List, it calls wait(). The producer side calls addLast(), followed by notify(). Needless to say, you'll need synchronization, but you don't want to synchronize your listeners ... that's a fun problem that's left for the reader.
    The various listener lists can be maintained with Maps, where the event object is used to lookup a list of listeners. In a GUI environment, the event object has to maintain the source as well as the event object; in a non-GUI environment, it typically only holds the event type.

  • How to make relation between  gl_je_lines  and wip_transaction_accounts

    I try to write script to make relation between GL and WIP, wip_transaction_accounts and mtl_material_transactions
    1.
    SELECT
    (SELECT meaning
    FROM mfg_lookups
    WHERE lookup_type = 'WIP_TRANSACTION_TYPE'
    AND lookup_code =
    (SELECT TRANSACTION_TYPE
    FROM wip_transactions
    WHERE transaction_id = wta.transaction_id
    ) "Transaction Type" ,
    gjb.NAME "Journal Batch Name" ,
    gjh.NAME "Journal Name" ,
    gjh.je_source "JE Source" ,
    gjh.je_category "JE Category" ,
    glp.period_num "GL Month" ,
    glp.period_year "GL Year" ,
    gjh.default_effective_date "GL Date" ,
    NVL(gje.accounted_dr,0) -NVL( gje.accounted_cr,0) "GL Line Amount" ,
    gje.description "GL Line Description" ,
    (SELECT organization_code
    FROM mtl_parameters
    WHERE organization_id = wta.organization_id
    ) "ORG Name" ,
    NULL "Vendor/Customer Name" ,
    NULL "SO/PO Number" ,
    NULL "Reference Number" ,
    NULL "AP/AR Invoice Number" ,
    NULL "Doc Sequence Value" ,
    NULL "Invoice Type Lookup Code" ,
    NULL "Check Number" ,
    NULL "Line Type" ,
    NULL "Category" ,
    NVL (wta.base_transaction_value, 0) "Transaction Amt" ,
    NULL "AR/PO Receipt Number" ,
    NULL "Applied Invoice Number" ,
    (SELECT a.segment1
    FROM mtl_system_items_b a ,
    wip_discrete_jobs b
    WHERE a.inventory_item_id = b.primary_item_id
    AND a.organization_id = b.organization_id
    AND b.wip_entity_id = wta.wip_entity_id
    AND b.organization_id = wta.organization_id
    ) "Item Name" ,
    gcc.segment1 "Company" ,
    gcc.segment2 "Department" ,
    gcc.segment3 "Account" ,
    (SELECT description
    FROM fnd_flex_values_vl fnd
    WHERE flex_value_set_id = 1009707
    AND TO_CHAR (fnd.flex_value) = gcc.segment3
    ) "Account Description" ,
    gcc.segment4 "Intercompany" ,
    NULL "JE Category Description" ,
    NULL "AP Invoice Line Description"
    TRUNC (wta.transaction_date) "JE Creation/Inv Trans Date" ,
    NULL "JE Created By" ,
    NULL "Reversal Flag" ,
    NULL "Reason Code" ,
    NULL "Subinventory Name" ,
    wta.primary_quantity "Quantity" ,
    NVL (wta.base_transaction_value, 0) "Value" ,
    gje.context ,
    gje.attribute1 ,
    gje.attribute2 ,
    gje.attribute3 ,
    gje.attribute4 ,
    gje.attribute5 ,
    DECODE(gjh.status,'P','Posted','U','Unposted','Error') "Post Status"
    FROM gl_je_lines gje ,
    gl_je_headers gjh ,
    gl_je_batches gjb ,
    wip_transaction_accounts wta ,
    gl_code_combinations gcc ,
    gl_periods glp
    WHERE 1 =1
    AND gje.je_header_id = gjh.je_header_id
    AND gjh.je_batch_id = gjb.je_batch_id
    AND UPPER (gjh.je_source) = 'INVENTORY'
    AND gcc.code_combination_id = gje.code_combination_id
    AND wta.reference_account = gje.code_combination_id
    AND TRUNC(wta.transaction_date) BETWEEN glp.START_DATE AND glp.END_DATE
    AND gje.reference_1 = wta.gl_batch_id
    AND gje.gl_sl_link_table = 'WTA'
    AND glp.period_name = gjh.period_name
    AND glp.period_set_name = 'OVT_US_CAL'
    ==
    2.
    SELECT mtt.transaction_type_name "Transaction Type" ,to_char(mmt.transaction_date,'mm/dd/yyyy hh:mi:ss') as teas, mta.transaction_id,mta.organization_id, mmt.organization_id,
    gjb.NAME "Journal Batch Name" ,
    gjh.NAME "Journal Name" ,
    gjh.je_source "JE Source" ,
    gjh.je_category "JE Category" ,
    glp.period_num "GL Month" ,
    glp.period_year "GL Year" ,
    gjh.default_effective_date "GL Date" ,
    NVL(gje.accounted_dr,0) - NVL(gje.accounted_cr,0) "GL Line Amount" ,
    gje.description "GL Line Description" ,
    (SELECT organization_code
    FROM mtl_parameters
    WHERE organization_id = mta.organization_id
    ) "ORG Name" ,
    NULL "Vendor/Customer Name" ,
    NULL "SO/PO Number" ,
    mmt.TRANSACTION_REFERENCE "Reference Number" ,
    NULL "AP/AR Invoice Number" ,
    NULL "Doc Sequence Value" ,
    NULL "Invoice Type Lookup Code" ,
    NULL "Check Number" ,
    NULL "Line Type" ,
    NULL "Category" ,
    NVL (mta.base_transaction_value, 0) "Transaction Amt" ,
    NULL "AR/PO Receipt Number" ,
    NULL "Applied Invoice Number" ,
    (SELECT segment1
    FROM mtl_system_items_b
    WHERE inventory_item_id = mmt.inventory_item_id
    AND organization_id = mmt.organization_id
    ) "Item Name" ,
    gcc.segment1 "Company" ,
    gcc.segment2 "Department" ,
    gcc.segment3 "Account" ,
    (SELECT description
    FROM fnd_flex_values_vl fnd
    WHERE flex_value_set_id = 1009707
    AND TO_CHAR (fnd.flex_value) = gcc.segment3
    ) "Account Description" ,
    gcc.segment4 "Intercompany" ,
    NULL "JE Category Description" ,
    NULL "AP Invoice Line Description"
    TRUNC (mta.transaction_date) "JE Creation/Inv Trans Date" ,
    NULL "JE Created By" ,
    NULL "Reversal Flag" ,
    (SELECT MGD.SEGMENT1
    FROM MTL_GENERIC_DISPOSITIONS MGD,
    MTL_MATERIAL_TRANSACTIONS MMTT
    WHERE MGD.DISPOSITION_ID = MMTT.TRANSACTION_SOURCE_ID
    AND MMTT.TRANSACTION_SOURCE_TYPE_ID = 6
    AND MGD.ORGANIZATION_ID = MMTT.ORGANIZATION_ID
    AND MMTT.TRANSACTION_ID = MMT.TRANSACTION_ID
    ) "Reason Code" ,
    mmt.SUBINVENTORY_CODE "Subinventory Name" ,
    mta.primary_quantity "Quantity" ,
    NVL (mta.base_transaction_value, 0) "Value" ,
    gje.context ,
    gje.attribute1 ,
    gje.attribute2 ,
    gje.attribute3 ,
    gje.attribute4 ,
    gje.attribute5 ,
    DECODE(gjh.status,'P','Posted','U','Unposted','Error') "Post Status" -
    FROM gl_je_lines gje ,
    gl_je_headers gjh ,
    gl_je_batches gjb ,
    mtl_transaction_accounts mta ,
    mtl_material_transactions mmt ,
    mtl_transaction_types mtt ,
    gl_code_combinations gcc ,
    gl_periods glp
    WHERE 1 =1
    AND mta.transaction_id = mmt.transaction_id
    AND gje.je_header_id = gjh.je_header_id
    AND gjh.je_batch_id = gjb.je_batch_id
    AND UPPER (gjh.je_source) = 'INVENTORY'
    AND gcc.code_combination_id = gje.code_combination_id
    AND mta.reference_account = gje.code_combination_id
    AND TRUNC(mta.transaction_date) BETWEEN glp.START_DATE AND glp.END_DATE
    and mta.request_id=mmt.request_id
    and mta.inventory_item_id=mmt.inventory_item_id
    AND gje.reference_1 = mta.gl_batch_id
    AND gje.gl_sl_link_table = 'MTA'
    AND mtt.transaction_type_id = mmt.transaction_type_id
    AND glp.period_name = gjh.period_name
    AND glp.period_set_name = 'OVT_US_CAL'
    When gl_je_lines have multiple line this script on the same transaction_id it will get wrong information. By setup all wip_transaction_accounts.GL_SL_Lind_id and mtl_transaction_accounts.GL_SL_Lind_id is null
    Anyone can help?

    Hello.
    How are you reaching the inconsistencies ? Are you comparing report's results?
    Octavio

Maybe you are looking for

  • Lync phone device sign in failed

    Hi. I have an environment of Lync 2010. Front End Pool - 1 server Director pool - 2 servers AV pool - 2 servers My DNS system is split brain. Local domain company.net, external domain company.com DNS pinpoint zones: lyncpool01.company.net pointed to

  • Traffic light in Excell addin ??

    Hi, can we achive Traffic light in Excell addin without webanalyzer? Thanks

  • An unknown error occurred when i try to login to the app store

    someone please help, when I try to login to the app store, it says an unknown error has occured, also, when I try to use facetime it says "the server encountered an error processing registration. please try again later. also, when i try logging into

  • I want a help?

    How can I get Apple ID account, I tried to create it pass through to apps store and made its verification. But if I am going to install new apps they notice me again to verify my account. My divice is iPad touch 13gb. Please help me ?

  • SecurityException running loadads.bat from sample portal

    I installed WebLogic Server 6.1 SP2 and then Portal SP1, these work fine. I then installed the sample portal application and it starts up fine. When I try to run the loadads.bat I get this SecurityException. Does this have anything to do with the fac