Go Back   kirupaForum > Flash > ActionScript 3.0

Reply
 
Thread Tools Display Modes
Old 11-26-2009, 01:19 AM   #1
n000bie
Registered User
Array problem

I got a 8x8 grid, filled with random movie clips from 7 frames (they got no. 1 to 7).

What am I trying to do (from last 3 days) ?

When clicked on any movie clip get their neighbor movie clip type and if they are same disappear.

This is taken from the first row.

3 2 1 7 2 6 6 6

here If i click the third clip which is 1, check both side compare it with current one and if it is not same do nothing else disappear.

Here is the code i have done so far
Code:
public function clickPiece(e:Event) 
        {
            
            var currPiece:String;
            var match:Array;
            
            currPiece = e.currentTarget.type
            trace(currPiece);
            //trace(grid[0][0].type);
            for(var i:int=1; i<8; i++){
                //trace(grid[i][0].type);
                if (currPiece == grid[i][0].type) {
                    match.push(grid[i][0]);
                    trace (match.length);
                    }
            }
           
          }
this code gives me error
can anyone tell me what shall i do from here..... i am stuck

Last edited by n000bie; 11-26-2009 at 01:25 AM..
n000bie is offline   Reply With Quote

Sponsored Links (Guests Only) - Register | Need Help?
 

Old 11-26-2009, 11:38 AM   #2
_kp
 
 
_kp's Avatar
If you get an error you should post it, it will tell what is wrong with your code.

Anyway I already see a few problems: first you should initialize that Array (var match:Array = [];).

Also the number of items in your array/grid seems odd, why do you have 8 slots when there are only 7 movieclips? Is grid[0][0] empty? You probably should start your loop with var i:int=0 and make its length to match the amount of items you want to put in it.
_kp is online now   Reply With Quote
Reply


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -4. The time now is 06:02 PM.

SUPPORTERS:

kirupa.com's fast and reliable hosting provided by Media Temple. flash components
Creative web apps. Make your own free flash banners and photo slideshows.
Check out the great, high-quality flash extensions. Buy or sell stock flash, video, audio and fonts for as little as 50 cents at FlashDen.

Flash Transition Effects

Flash Effect Tutorials

Digicrafts Components
Flash effects. Art without coding. Upload, publish, deliver. Secure hosting for your professional or academic video, presentations & more. Screencast.com
Streamsolutions Content Delivery Networks Flipping Book - page flip flash component.
Flash-Gallery.com - Get your flash photo gallery (flash component or swf gallery Learn how to advertise on kirupa.com
 

cdn
content delivery network (cdn)

Powered by vBulletin® Version 3.8.4
Copyright ©2000 - 2010, Jelsoft Enterprises Ltd. Copyright 2010 - kirupa.com Copyright 2010 - kirupa.com