What is the best way to deal with a 'Implicit coercion' in a table to a sprite?

Hi all!

With the continued support of this forum, I'm getting closer to have a programme of work. I can't wait to be able to help others like me once I've finished learning the ropes of AS3.

I'll briefly explain what I want to achieve and then followed with my question.

Background

I created a random number of 12 x 9 grid that fills each cell with an image, based on the numeric value of each cell. I also have a random play button that makes random numbers in the grid. The problem I am running became my click event of button to erase the current images off the grid in order to allocate the new (for example by removing the objects display battery in order to place the new ones in the same places).

Question

My question is this: what is the best way to manage an implicit constraint from a table to a sprite? I pasted my complete code below so that you can see how the functions are supposed to work together. My sentence is apparently not being able to use a value from array with a sprite (sprite represents the real layout of the grid on the pile of display while the table starts as a number that is assigned an image that must be transmitted to the sprite).

============================================================================

package
{
import flash.display.MovieClip;
import flash.display.DisplayObject;
import flash.events.MouseEvent;
import flash.display.Sprite;
import flash.text.TextField;
import flash.text.TextFormat;
import flash.utils.getDefinitionByName;

SerializableAttribute public class extends MovieClip Blanko
{
Contains 12 * 9 grid of cells.
var grid: Sprite;
Maintains the shuffle button.
var shuffleButton:Sprite;
Is equal to 12 columns, 9 lines.
var cols: int = 12;
lines of the var: int = 9;
Equal number of grid cells (108).
cells var: int = COL * rows;
Sets of cell width and height to 40 pixels.
var cellW:int = 40;
var cellH:int = 40;
Contains 108 images of cell.
var imageArray:Array = [];
Contains 108 numerical values for the cells in the grid.
var cellNumbers:Array = [];

Constructor calls the functions "generateGrid" and "makeShuffleButton".
public void Blanko()
{
generateGrid();
makeShuffleButton();
}

Creates and displays the grid 12 * 9.
private function generateGrid (): void
{
grid = new Sprite;
var i: int = 0;


for (i = 0; i < cells; i ++)
{
cellNumbers.push (i % 9 + 1);
}
trace ("before shuffle:", cellNumbers);
shuffleCells (cellNumbers);
trace ("after shuffle:", cellNumbers);
var _cell:Sprite;

for (i = 0; i < cells; i ++)
{

/ / This line is where the implicit constraint occurs. '_cell' is a leprechaun trying

on a temporary basis equal to a value from array.
_cell = drawCells (cellNumbers [i]);
_cell.x = (I % cols) * cellW;
_cell.y = (I / COL) * cellH;

grid.addChild (_cell);
}
}

Creates a "shuffle" button and adds a mouse click event.
private function makeShuffleButton (): void
{
var _label:TextField = new TextField();
_label. AutoSize = 'center ';
TextField (_label) .multiline = TextField (_label) .wordWrap = false;
TextField (_label) .defaultTextFormat is new TextFormat ("Arial", 11, 0xFFFFFF, "bold");.
_label. Text = "SHUFFLE";
_label.x = 4;
_label.y = 2;
shuffleButton = new Sprite();
shuffleButton.graphics.beginFill (0 x 484848);
shuffleButton.graphics.drawRoundRect (0, 0, _label.width + _label.x * 2, _label.height +)
_label.y * 2, 10);
shuffleButton.addChild (_label);
shuffleButton.buttonMode = shuffleButton.useHandCursor = true;
shuffleButton.mouseChildren = false;
shuffleButton.x = grid.x + 30 + grid.width - shuffleButton.width;
shuffleButton.y = grid.y + grid.height + 10;
this.addChild (shuffleButton);
shuffleButton.addEventListener (MouseEvent.CLICK, onShuffleButtonClick);
}

Erase the images of the cell, mix of their numbers and then assigned these new images.
private function onShuffleButtonClick (): void
{
eraseCells();
shuffleCells (cellNumbers);
trace ("after shuffle:", cellNumbers);


for (var i: int = 0; i < cells; i ++)
{
drawCells (cellNumbers [i]);
}
}

Deletes any existing cells in the battery of the display image.
private void eraseCells(): void
{
While (imageArray.numChildren > 0)
{
imageArray.removeChildAt (0);
}
}

Changes cell phones numbers (makes random table).
private void shuffleCells(_array:Array):void
{
var _number:int = 0;
var _a:int = 0;
var _b:int = 0;
var _rand:int = 0;

for (var i: int = _array.length - 1; i > 0; i-)
{
_rand = Math.Random () * (i - 1);
_A = _array [i];
_B = _array [_rand];
_ARRAY [i] = _b;
[_Rand] _ARRAY = _a;
}
}

Retrieves and sets a custom image to a cell based on its numerical value.
private void drawCells(_numeral:int):Array
{
var _classRef: Class = Class (getDefinitionByName ("skin" + _numeral));
_classRef.x = 30;
imageArray.push (_classRef);
imageArray.addChild (_classRef);
return of demonstration;
}
}
}

===========================================================================

Any help with this is greatly appreciated. Thank you!

If you want to have an array of Sprites that you later clear that is fine. But this does not mean that your function should return to it.

You need your function to return the sprite so that you can add it to the display list and everything what you need.

So just have the function get Sprite, push it in the "toBeClearedInTheFutureArray" and then return a reference to the currently acquired sprite.

Tags: Adobe Animate

Similar Questions

  • What is the best way to deal with the pages being removed from the site in British Colombia?

    A customer wants a page removed from their Web site; What is the best way to go about removing/deleting a page in British Colombia and keep all attributed to the laid-off page SEO ranking?

    Should I delete the page and then add URL redirect via the module to redirect BC a relevant page.

    or

    I have to keep the page alive but 301 redirect using the property of the redirection page 301 in addition to Options?

    One is better than the other?

    Redirect via the page is there if you want to keep the page for any reason content wise, etc. in the admin. Web site wise is no different. A 301 redirect is a redirect 301 Grant, there is no difference.

  • What is the best way to deal with the events of Qml-components of java script or C++?

    Hello

    Please suggest which is the best way to treat the Qml-components signal in the manuscript of java or C++.

    can read contacts in javaScript?

    When you want to make things more complex: Yes.
    QT made it much easier for me as a java developer, bb, but you will need to learn some basics.

  • the best way to deal with the changed values maskMode?

    Hi people

    I just found out that the values listed for maskModes have changed between CC14 and CC15 who broke most of my scripts of masking.

    IE MaskMode.ADD in CC14 has the value 6413 but CC15 is 6813.

    What is the best way to deal with this? is there a simple solution or what I need to check the version of AE which is used and adjust from there?

    is there a direct way to access the name ie "MaskMode.ADD" instead of the value?

    Thanks... /JL

    To get the string maskMode by the current mask, you can loop through all the values possible maskmodes and stop when you click on:

    for (var k in MaskMode){
        if (myMask.maskMode === MaskMode[k]) break;
        };
    // at this stage k is the maskMode string (eg: "ADD")
    

    Xavier

  • I currently have creative cloud of a photographer.  I must add my subscription first.  What is the best way to go with the best available prices?

    I currently have creative cloud of a photographer.  I must add my subscription first.  What is the best way to go with the best available prices?

    Hello

    Please see the pricing and membership creative cloud plans | Adobe Creative Cloud for plans.

    Otherwise, you can talk with the sales of Adobe as well.

    I recommend going for the plan of single-app.

    Kind regards

    Sheena

  • What is the best way to work with Word documents in The InDesign CS4?

    I work in Microsoft Word 2007 and all my documents have.doc format.

    What is the best way to work with Word documents in InDesign CS4?

    David Blatner says to avoid copying and pasting text from Word instead of placing (Ctrl + D).

    How to paste RTF or text Document?

    I want to do a book layout in ID CS4 and its main feature is that there is the left page with the text and the right - with graphics.

    So, if I understand correctly place the text on each page I create for example 70 Word documents and place each element on 70 pages left?

    He loks like wasting time. I have supplements another way to make such provision?  What kind?

    It is best to place any text.

    You can have all your text in a single file and debit allows you to add text, images and pages as necessary block (hold down the SHIFT key when you click the loaded text cursor), but it is somewhat atypical for the thread on one side of the spread in the perspective of automatic flow, so you don't have to set up properly.

    It is a case where a block of text that you type will work to your advantage. On your master page, add a text block to the left page, but not to the right (or at least not donned one to the right - for another project you can actually two threads of independent text). Hold the cursor of the load on a frame on the left side of a page document and auto-flux. ID will add new spreads as needed, but only to put the text on the left side.

    Peter

  • What is the best way to move with esx3.5 vmtools key/value pairs?

    Hello

    I found both candidates to store the key/value pairs for a vmware client. My ultimate goal is to run a process on the VC box that updates these data, and then read through the software tools of vm on the host (somehow) were invited.

    The first method is through 'guestinfo' settings which can be adjusted in four ways:

    Add the variable of the vmx fileprompt.
    Set the variable manually on the client (using vmwareservice.exe - cmd "infoset");
    using vmware-cmd (vmware-cmd & lt; vm-cfg-path & gt; setguestinfo & lt; variable & gt; & lt; value & gt;)
    the use of vmcom.dll COM objects (seems to be deprecated in ESX 3.5)
    These variables are easily accessible on the client by running vmwareservice.exe - cmd 'info-get guestinfo.variablename '. However, I cannot find a convenient way (better based on powershell) of their definition of a scheduled task or service to VC area.

    The second method is the customfields of guests in VItoolkit property, which can be defined as follows:

    get - vm MyVMName | Game-CustomField-nameOfValue name-value DataToBeStored
    Unfortunately, I am unable to access these data in the comments, and indeed I do not know if this is possible. If this isn't the case, I guess my only recourse would be to write a tool to connect to Web services on the VC box with a low privilege account. I prefer not to do this because it means the network infrastructure implementation to point the guest to the right VC, development of custom etc permissions...

    So, my questions are:

    • Is it possible to define variables of guestinfo through VI Toolbox, running on the virtual circuit?

    • Is it possible to read customfields on the client, through the vmtools?

    • Or is there another method to make this key/value data exchange?

    You can add/edit entries in the VMX file like this

    $vm = get-vm  | Get-View
    
    $vmConfigSpec = New-Object VMware.Vim.VirtualMachineConfigSpec
    $vmConfigSpec.extraconfig += New-Object VMware.Vim.optionvalue
    $vmConfigSpec.extraconfig[0].Key= "guestinfo"
    $vmConfigSpec.extraconfig[0].Value = "whatever"
    
    $vm.ReconfigVM($vmConfigSpec)
    
  • What is the best way to comply with footage of 60 fps 24 fps without slowing down?

    So I understand how time remapping and reinterpret the cadence of the 60 fps footage to slow it down, but I'm at a loss as to how I can do 24 fps without just which establishes it as such, giving a jerky export.

    I'm shooting on a Rebel t3i that only allows me to shoot in 720 p at 60 frames per second. Is it possible to drop the frame rate without changing the duration while preserving quality?

    Thanks for any help in advance!

    Shiraz

    Drop your 60 p clip into a sequence of 24 p. Cliquer click with the right button, and then select frame Blend. It's about as good as you will get in Premiere Pro.

    If you need 24 p, why not shoot 1080 p? The T3i plans to 23.976 (24 p) mode 1920 x 1080 p. You can always scale the clip 1080 p to 720 p.

  • My Acrobat has stopped working.  I have the CS6 Master Collection.  I had this happen before and I had to reinstall with the entire suite.  Is this stil the best way to deal with this?

    Sorry, meant CS6.

    Hey Gary Kirby,

    Please make sure that you are connected to your system as administrator.

    Let me know the exact error that invites on your screen when launching Acrobat.

    You might also check out this link to doc KB and try solutions as indicated:

    Does not start after 30 days. Installed as part of a suite CS6

    Please check and let me know.

    Kind regards

    Ana Maria

  • What is the best way to run immediately given sql stored in a table

    I have a variable string containing row_ids for example "12,24,35,23".

    and a table

    ROW_ID, sql
    1, "insert into une_table values (23, 'Happy');"
    6, "insert into some_other_table values (24, 'Sad');"
    12, "insert into une_table values (23, 'Crazzzy');"
    15, "insert into some_other_table values (23, 'Old');"
    23, "insert into another_table values (23, 'Left');"
    24, "insert into stuff_table values (23, 'Gold');"
    30, ' insert into values (23, 'Even') ancienne_table;
    35, "insert into archive_table values (23,"True");"

    And I need to write a function, plsql which takes the list of the row_ids as an argument and executes the sql statements stored in the table that corresponds.

    I will try a combination of cursor and execute immediate instructions to do it for the moment but suspect I'm being very inefficient. So any suggestions or examples of similar code, that everyone knows would be immensely appreciated.

    See you soon


    Reuben

    Hello
    I'm assuming row_id column will take place separately. Here's the code just convert this procedure

    Declare
    ROW_ID varchar2 (1000): = '12,24,35,23';
    rid the number;
    insert_query VARCHAR2 (10000);
    Start
    While instr(row_id,',',1)<>0
    loop
    RID: = to_number (substr (row_id, 1, instr(row_id,',',1)-1));
    Start
    Select in the insert_query where row_id = rid;
    immediately run insert_query;
    commit;
    exception when others then
    null;
    end;
    ROW_ID: = substr (row_id, instr(row_id,',',1) + 1);
    end loop;
    RID: = to_number (row_Id);
    Select in the insert_query where row_id = rid;
    immediately run insert_query;
    commit;
    end;

    Replace with and insert query column name by respective tablename

    Published by: user648705 on March 10, 2009 13:59

  • Best way to deal with pictures from the start? (Bridge CS5 and iPhoto)

    Hi all

    I am just learning the strings of all the suite CS5 and began to add keywords etc in bridge, when I realized that I couldn't access the files in my iPhoto library ('09). I read a few threads on this topic, but have not really found a consensus on how to deal with it.

    I think I'm in a good position to get things right from the start, because I have no tags or sides etc. in my configuration of iPhoto (and only add keywords for the few photos that weren't in my iPhoto library), and wonder what you think is the best way to sort photos given I intend to use them in web design etc. and all the parts of my suite CS5.

    If the photos in iPhoto is the best what is the best way to do it? I have read suggestions do a right-click on the library and click "Show content" - or something like cela, but that does not come up as an option when I right click my iPhoto in Bridge library. Thanks a lot for your help!

    Please let me know if there is any info I could give you that could be useful in order to understand this one.

    Best,

    Mara

    PS: for the temporary folder, I use a name like to-do Images

    Remember once the keywords are used is not just the manipulation/image adjustments which are important metadata but also robust observation with integrity

  • What is the best way to sync contacts with a host of webdav?

    I use Thunderbird and Contacts Android as of client applications with an owncloud 8 hosted remotely. I have activated the application Contacts on Owncloud and now I want to sync the contacts between these systems. What is the best way to do it?

    I try to get sorted first Thunderbird. I tried Addressbooks Synchronizer, but currently, it gives me a message telling me that my credentials are wrong or is sitting silently, do nothing. I am aware that it is a file synchronization, the method of synchronization not saved, so it is not ideal, in any case.

    Is there a better, good timing, method I can use? I refuse to the thing that he is an unreasonable request or that no one asked before me, but I can't seem to find the answer.

    Thanks, Martin

    WebDAV my initial reaction was sogo connector.
    These guys recommend the same http://kb.mozillazine.org/Sharing_address_books

    Here http://www.sogo.nu/english/downloads/frontends.html

  • What is the best way to preserve my having iPhoto library merge my pictures of girls with mine that his iMac had stopped working.

    What is the best way to preserve my iPhoto library had fusion - UN-intentionally - pictures of girls with mine as its iMac had stopped working. Some how I have about 48 000 pictures now where before I was about 11 000

    The iMac's hard drive has been deleted in tact and two weeks ago, she bought a new iMac 27' which has only the "Photos" application, but in trying to restore his iPhoto library, it gets about 24% then stops with a po - up window saying "cannot continue due to inconsistancies", that these are we don't know.

    I think using his old h/drive connected via usb to my iMac, I managed to save his library.

    On an external drive, I would like to make my backups that are up to date for a few days so that my photos need to be secured.

    1. Can I remove my iPhoto library and then re - import of my external hard drive?

    2. Can I give my daughter a copy of the "iPhoto app" and install on its new iMac and then re - import photos into iPhoto?

    More popular tips.

    Alan

    I copy the library from the back to the top first before deleting anything, in case something goes wrong. You can choose which library to open hold down the option (or alt) key key and launch of iPhoto. In the menu that appears, select "Choose Library"

    No. but you can give him the iphoto library and she can open it with Photos.

  • What is the best way to Sync Output (TTL) digital with analog output?

    I'm trying to generate analog signals that synchronize the rising edge of a digital signal (TTL). The ttl will be the trigger for the camera. The advice I have is USB-6343 X. In my project, I used a clock as a ttl so I can give frequency easily. Could someone tell me what is the best way to accomplish this task? My project seems to work, but I hope it has more neat way. Thanks in advance for any help!

    Kind regards

    Eric

    Hi Econg,

    They should be nanoseconds, if any, there is a trigger of material goes with a hardware clock.

  • What is the best way to replace an Appasure Agent with hardware new and new computer name?

    What is the best way to replace an Appasure Agent with hardware new and new computer name?

    Thank you that's what I needed

Maybe you are looking for

  • How can I get the rear bar orange firefox option?

    I've recently updated at 28, I think 19 and I hate just the new user interface.But what I can adjust to wait the bar orange firefox which is at the top right.Is there a setting in the options to get that back or do I have to download an add on?

  • Satellite C660-10F - need for Windows XP 32 bit LAN driver

    HelloI want to my hard drive of the C660-10F to a storage network using Ghost 15 recovery disk backup CD. So I have to configure the recovery disk bootable CD with the driver LAN C660-10F for XP 32 bit to get access to the network at the start of thi

  • Satellite 3000-514: display dims

    Hallo, I got a Satellite 3000 514.A couple of months ago, it falls on the floor and the broken screen.However, I had another screen from ebay.Unfortunately it wasn't a 3000-514, but a 3000-2xx.It was no problem to install it.When you use Notepad it a

  • Pass simple don't connect screen locked HP DV6 P 605ea

    Hello I've been running Simple pass Windows 8.1 on my HP Pavilion DV6 6053ea for a while now and only in the last few days it has stopped working properly.  It won't let me through the lock screen. I don't want to enter a password every time win 8.1

  • Bluetooth works only with windows 7 ultimate

    I'm going round in circles trying to get the bluetooth to work Model: Sony vaio VGN-Z11VNWindows 7 ultimate x 64 When I go, control panel, add a device, he finds nothing. Bluetooth devices are turned on and discoverable. I tried downloadding the broa