Constrain To Sprite doesn't like rotating sprites...
I have a bunch of movable sprites that I'd like to constrain
to a box
(basically just the whole stage). Problem is that they also
have the
ability to rotate, only at 90 degree intervals, though.
They're relatively
rectangular shapes (puzzle pieces). But when you rotate them
with the
Constrain to Sprite behavior on them, their aspect ratio gets
all screwed
up, and then sometimes they start moving on their own until
they hit an
edge, quite odd behavior. Is there a way to make this
behavior work with
sprites that can be rotated without these glitches? Or is
there a better
alternative? I tried writing my own contstrain script, which
worked except
that you could still drag the sprites off the edge, they'd
just keep
bouncing back and forth until you released the mouse button.
Also not good
behavior.
Are you dragging these sprites around or are you moving them
in some
other way?
If you are dragging the sprites around then you can use
sprite(X).within(Y) to keep your sprites from leaving the
stage area.
1. Make a borderless empty toolbox shape sprite that is
slightly smaller
than the whole stage. Make is sprite 1.
2. constrain each sprite to that sprite.
3. use a simple behavior like this to control the moving of
each sprite:
property thisSprite
property animateMe
on beginSprite me
thisSprite = me.spriteNum
animateMe = false
sprite(thisSprite).constraint = 1
end
on mouseDown me
animateMe = true
end
on mouseUp me
animateMe = false
end
on exitFrame me
if animateMe then
sprite(thisSprite).loc = the mouseLoc
end if
end
Rob
Rob Dillon
Adobe Community Expert
http://www.ddg-designs.com
412-243-9119
http://www.macromedia.com/software/trial/
Similar Messages
-
I have a sprite on stage that I want to rotate, The sprite itself contains a shape (a triangle) with these coordinates (10,10)(10,50)(20,30).
When I rotate the sprite (as it is now) using spritename.rotate=nn, it rotates, but around the (0,0) position of the parent container (a movieclip). In an attempt to figure out what was going on, I set up some trace statements, including one to check the width and height of the sprite. It changes with each rotation.
Not sure what is going on here, or why the sprite rotates using the parent mc, but if someone could point me in the right direction, I would appreciate it.use:
var sp:Sprite = new Sprite();
with(sp.graphics){
beginFill(0xaa0000);
moveTo(0,0);
lineTo(0,40);
lineTo(10,20);
lineTo(0,0);
sp.x = -sp.width/2;
sp.y = -sp.height/2;
var p:Sprite = new Sprite();
p.addChild(sp);
p.x = 10+p.width/2;
p.y = 10+p.height/2;
addChild(p);
now p will act like your sprite with its reg point changed to the center. just rotate and otherwise manipulate p instead of sp. -
Why doesn't the rotate gesture on my trackpad behave as it used to for switching between tabs when it works the same with all other programs besides Firefox?
I changed the about:config to make the rotate gesture move between tabs, and it worked great for well over a year. Now it behaves erratically as described here:
https://bugzilla.mozilla.org/show_bug.cgi?id=877598
It used to be very controllable to move one tab over, now it is erratic and moves quickly and to unexpected tabs regardless of how slow I do the rotate gesture. This is the main reason I use Firefox over Chrome and I would like to continue to do so unless there is no fix to this.Just set the browser.gesture.twist.threshold to something around 15-25.
-
How do i put a mobile number in on numbers '09? like 0414441472. Doesn't like 0 at the front. Thanks
Ed,
There are a number of ways to do this. Your phone number consists of all numerals, yet isn't a numeric value, but rather a text value. Numbers doesn't know that, so it treats it as a numeric value and strips off what it feels is an unnecessary leading zero.
You have there options:
Format the cells as Text prior to making the entry.
Leave the cells as a Numeric value format, but choose Custom Format to set the number of displayed places and choose to display leading zeros.
Use the Numeral System Format and set it to base 10, displaying 9 digits, or whatever you need.
There are ways to convert a number to text and add required leading zeros with a formula too, but it's needless work.
Jerry -
MP3-Library doesn't like some of MediaSource's ID3 t
Just a tip for MP3-Library users:
On rare occasions, MediaSource 3.30.2 will produce an ID3 tag that MP3-Library doesn't like. (This is pretty rare -- out of 45 tracks I updated the tags on, 6 did this.) This results in the file being displayed as corrupted. If you select "Analyze/Fix MP3," it finds a frame or two with random specifications at the very start of the file, followed by a single bad frame, and then all good frames.
If you check all availiable fix options (delete selected frames [check the junk and bad ones], delete garbage before st frame, delete garbage after last frame), it lops about 30 bytes off the end of the tag/header and takes a few good frames off the start of the file.
According to MP3Utility and EncSpot, there's nothing wrong with the files, and they play just fine in MediaSource, Winamp, and on the Zen. The header data that was destroyed doesn't affect the ID3 data. It only seems to have removed the Xing header. (No, I don't use Xing. LAME 3.97 alpha puts Xing-compatible headers on its VBR files.)
The following are the summary data that MP3Utility shows. This is from the original file, fresh out of LAME:
<i>File size: 3,63,232 bytes
Offset to first frame header: 2,630 bytes
MPEG version .0; Layer III
Bitrate: VBR (Xing); Sample rate: 44,00 Hz
Channel mode: Joint stereo
Private: No; CRCs: No; Copyrighted: No
Original: No; Emphasis: None
Frame size: ,52 samples/frame
Frame length: 47 bytes/frame (unpadded)
Pad size: byte(s)
Estimated frames: 8,945
Estimated time: 3:54 (234 secs.)</i>
This is after importing the file into the PC Music Library and clicking "Update Tag." I didn't modify anything, just told it to re-write the ID3 tag:
<i>File size: 3,63,232 bytes
Offset to first frame header: 2,630 bytes
MPEG version .0; Layer III
Bitrate: VBR (Xing); Sample rate: 44,00 Hz
Channel mode: Joint stereo
Private: No; CRCs: No; Copyrighted: No
Original: No; Emphasis: None
Frame size: ,52 samples/frame
Frame length: 47 bytes/frame (unpadded)
Pad size: byte(s)
Estimated frames: 8,945
Estimated time: 3:54 (234 secs.)</i>
And this is after MP3-Library "fixed" it:
<i>File size: 3,629,325 bytes
Offset to first frame header: 2,600 bytes
MPEG version .0; Layer III
Bitrate: 224 kbps; Sample rate: 44,00 Hz
Channel mode: Joint stereo
Private: No; CRCs: No; Copyrighted: No
Original: No; Emphasis: None
Frame size: ,52 samples/frame
Frame length: 73 bytes/frame (unpadded)
Pad size: byte(s)
Estimated frames: 4,96
Estimated time: 2:0 (30 secs.)</i>
No, MP3-Library DIDN'T chop 04 seconds off the file. The estimated frame count and length are WRONG because the Xing header was destroyed by MP3-Library. This header would normally tell MP3Utility how long the file really is, otherwise it takes the bitrate of the first frame and extrapolates that over the file length. (Without this header, many programs' progress sliders won't be as accurate.)
So, if MP3-Library tells you a file is corrupted after going through MediaSource and the file wasn't corrupted before, DON'T fix it. You'll only make things worse. I've never seen MediaSource or my Zen actually damage a file.
(At first, I told it to fix 'em. Now I'm going through and restoring the backups it made.)i have used mp3-libary many times before because it said a large amount of my collection was corrupted. but it seams to be better.as i havent used media source to import them so i think they may have actually be corrupt. but interesting findings.
-
Batch changes don't function. From simple commands like "rotate clockwise" to "lift and stamp" the command only affects to the last image in the group selected. Similar problems? Solutions? Suggestions? Thanks, Bruce
Glad it helped. Everyone has been bitten by this at one time or another. Fortunately you only get bit once
Well if you haven't already read it two or three times the User manual is really very good. Apple really did a nice job with it. The on-line version is nice because it is searchable.
After that the Apple Pro Training Series book Aperture 3 is very useful. Its basically split into three parts. The library, adjustments and sharing. In addition if you get all the way through it you can take the Certification test and become, well certified.
Rwboyer who posts here on and off has a good site and a couple of ebooks that I found useful.
good luck -
My Bridge doesn't like gif extensions on the pictures. He cal-laps, the program re-installed on my mac, but the same problem. By gif it stops and I have to forced stop to quit the program. hen open again and the same problem appears.
jpg. or png ole but gif bridge won't replace or open or...BOILERPLATE TEXT:
If you give complete and detailed information about your setup and the issue at hand, such as your platform (Mac or Win), exact versions of your OS, of Photoshop and of Bridge, machine specs, what troubleshooting steps you have taken so far, what error message(s) you receive, if having issues opening raw files also the exact camera make and model that generated them, etc., someone may be able to help you.
Please read this FAQ for advice on how to ask your questions correctly for quicker and better answers:
http://forums.adobe.com/thread/419981?tstart=0
Thanks! -
MacBook Pro doesn't like my 3rd gen. iPod
Just got a new MacBook Pro (work-issue = no administrator password for me), which replaced a Titanium PowerBook. Tried to hook up and sync my 3rd gen. iPod for the first time, using the Firewire port of course. (Music library has already moved to new machine.)
The iPod doesn't seem to be seen by the MacBook Pro. It doesn't show up in the iTunes source list or on the desktop. The iPod goes into "Do Not Disconnect" mode, then it freezes.
I've seen other people posting with similar or same issues, but no resolution. What could be going on?
MacBook Pro Mac OS X (10.4.5)Update: I have discovered that if I connect the iPod to the Mac with the Firewire cable only, things work perfectly. If I connect thru the dock with the iPod sitting in it (like I was before), things go haywire.
So I guess the MacBook Pro likes my 3rd gen. iPod just fine. The iPod dock is what it doesn't like.
Weird. Thanks for all your thoughts.
Mac Book Pro Mac OS X (10.4.5) -
perl: warning: Setting locale failed.
perl: warning: Please check that your locale settings:
LANGUAGE = (unset),
LC_ALL = (unset),
LC_COLLATE = "C",
LANG = "en_US.utf8"
are supported and installed on your system.
perl: warning: Falling back to the standard locale ("C").
Perl doesn't like it when I have my locale set to en_US.utf8. It works fine with just en_US. Is there a fix for this?How could you set perl to a locale if that locale doesn't exist?
Maybe there are ways to encode just specific things in utf8, rather than having to change all of per's locale. If this is what you mean, then read the perldoc -
Create desktop quietly fails - doesn't like my ".portal" file
Guys,
Since SP2, we're having trouble creating a desktop to "import" our ".portal" file.
After going through the sequence of clicks, it just comes back quietly but the
desktop is not there. It only does this if I "Choose a Template". It seems that
it doesn't like something in my template file but gives no indication of what.
If I revert back to an old template file, it works. However, I also re-created
a new template file from scratch and it won't read that one either.
Any clues?
Is there some debug/logging options for Admin Portal?
Thanks,
PhilJeff,
Thanks for the reply.
The .portal file was created in workshop and workshop reads it fine.
I discovered that after deleting all my books and pages from the Admin Portal
library, it imported my .portal file successfully. I'm thinking it finds some
"Definition Label" conflict between those in the .portal file and what's in the
library.
Phil
"Jeff Mueller" <[email protected]> wrote:
>
Hi Phil - was there no error message on the console? If not, please
check the
portalServer.log file and/or wl-domain.log file for that server session.
There
should be an error message listed there. It sounds like it's most likely
bad
xml in the .portal file. Did you create the new .portal file in Workshop?
Does
it open correctly there?
Jeff
"Phil Grimm" <[email protected]> wrote:
Guys,
Since SP2, we're having trouble creating a desktop to "import" our ".portal"
file.
After going through the sequence of clicks, it just comes back quietly
but the
desktop is not there. It only does this if I "Choose a Template". It
seems that
it doesn't like something in my template file but gives no indication
of what.
If I revert back to an old template file, it works. However, I alsore-created
a new template file from scratch and it won't read that one either.
Any clues?
Is there some debug/logging options for Admin Portal?
Thanks,
Phil -
IPhone 6 plus doesn't auto rotate on homescreen
Hi All, excuse the daft name I was sick of everything being taken haha
Got the new iPhone 6 Plus for myself and the wifey, mine is fine....the wifey's today doesn't auto-rotate the icons when turned to landscape, yet it did yesterday.Rotation of springboard on the iPhone 6+ only works in standard zoom. It took me awhile to figure it out. Go to settings ----> Display & Brightness ---->Display Zoom (View) ----> Standard. It will reset the phone, but it should rotate afterwards. In addition, make sure that the autorotate is set to unlock (swipe up from the bottom of the screen to bring up the shortcut functions, portrait or rotate is the padlock symbol - must be off). Hope this helps.
-
Encore CS4 Flash output - server doesn't like file names
Apparently my ftp server for my web site does not like files with spaces in the names, but Encore seems to use spaces in some of the file names for the png files in the menus. Is there any way around this? Can I force it to replace spaces with underscores? Can I go in and manually change the links and the file names (there aren't too many). this is very annoying - how could this happen?
Thanks,
ScottIf your server doesn't like spaces in file names, it's likely due to HTML address rules. However, these files won't be linked via HTML, but through the AuthoredContent.xml file directly into the SWF playing in the Flash player, which doesn't have the same limitations as HTML.
If your server is kicking a fuss up about this, replace the single space character in the PNG filename with an underscore character (do this at file system level), then edit the AuthoredContent.xml file and replace the space character in the PNG filename with an underscore character. Save everything, and then upload the files in the same hierarchy that Encore exports.
That should do it. -
Entertainment mode console doesn't like second moni
I've got a dual-monitor setup, using an X-Fi in entertainment mode. The console doesn't like being on the second monitor. Once it is there, it goes "flaky" flickering and moving around on the display. Put it back on the first display and it works normally again. I've got .00.3, I guess I'll go checking for updates.
*bump*?also, I'm running Vista x64. Is this problem?a driver issue?Message Edited by madhartigan on 09-28-20070:56 PM
-
Hi,
I found an interesting tutorial (link) and created a working model, adapting it as needed.
So far, when I center the container sprite and rotate it, it appears to first rotate from a 0,0 registration point, instead of from its center. I've tried to changet he sprite's registration point, but so far this hasn't worked/helped. Nothing else has worked to fix this rotation problem.
I must be doing something wrong.
Here's the AS3 (to view, add to first frame of new FLA, 1024X768 stage, color black). Rotation segments below are commented as //ROTATION.:
import flash.display.Sprite;
import flash.events.MouseEvent;
import flash.events.Event;
import flash.text.TextField;
//import flash.geom.ColorTransform;
stop();
//public class bejewelled extends Sprite {
var gems_array:Array=new Array();
var aGem:Sprite;
var selectorBox:Sprite=new Sprite();
var selectorRow:int=-10;
var selectorColumn:int=-10;
var red:uint = 0xFF0000;
var green:uint = 0xFF00;
var blue:uint = 0xFF;
var yellow:uint = 0xFFFF00;
var cyan:uint = 0xFFFF;
var magenta:uint = 0xFF00FF;
var white:uint = 0xFFFFFF;
var colours_array:Array=new Array(red,green,blue,yellow,cyan,magenta,white);
var clickPossible:Boolean=false;
var score_txt:TextField=new TextField();
var hint_txt:TextField=new TextField();
var score:uint=0;
var inaRow:uint=0;
var match:Boolean = true;
var gemSize:uint = 96;
var format:TextFormat = new TextFormat();
var rotate:Boolean=false;
var container:Sprite = new Sprite(); // Create the container sprite
//var newColorTransform:ColorTransform = exitBtn.transform.colorTransform;
//newColorTransform.color = 0xff0000;
//exitBtn.transform.colorTransform = newColorTransform;
function bejewelled() {
// Game initiation
format.size = 40;
format.font = 'Arial';
// Create and style score text
addChild(score_txt);
score_txt.textColor=0xFFFFFF;
score_txt.x=gemSize*9.6;
score_txt.autoSize = TextFieldAutoSize.LEFT;
score_txt.defaultTextFormat = format;
// Create and style hint text
addChild(hint_txt);
hint_txt.textColor=0xFFFFFF;
hint_txt.x=gemSize*9.6;
hint_txt.y=gemSize;
hint_txt.autoSize = TextFieldAutoSize.LEFT;
hint_txt.defaultTextFormat = format;
// Create Gems in rows and columns
addChild(container); // Add the container to the display list (stage)
for (var i:uint=0; i<8; i++) {
gems_array[i]=new Array();
for (var j:uint=0; j<8; j++) {
do {
gems_array[i][j]=Math.floor(Math.random()*7);
while (rowLineLength(i,j)>2 || columnLineLength(i,j)>2);
aGem=new Sprite();
aGem.graphics.beginFill(colours_array[gems_array[i][j]]);
aGem.graphics.drawCircle(gemSize/2,gemSize/2,gemSize/2.07);
aGem.graphics.endFill();
aGem.name=i+"_"+j;
aGem.x=j*gemSize;
aGem.y=i*gemSize;
container.addChild(aGem);
//Center the container sprite
container.width = container.width - 10;
container.height = container.height - 10;
container.x = (stage.stageWidth-container.width)/2;
container.y = (stage.stageHeight-container.height)/2;
// Create and style selector box
container.addChild(selectorBox);
selectorBox.graphics.lineStyle(2,red,1);
selectorBox.graphics.drawRect(0,0,gemSize,gemSize);
selectorBox.visible=false;
// Listen for user input
container.addEventListener(MouseEvent.CLICK,onClick);
addEventListener(Event.ENTER_FRAME,everyFrame);
// Every frame...
function everyFrame(e:Event):void {
//Assume that gems are not falling
var gemsAreFalling:Boolean=false;
// Check each gem for space below it
for (var i:int=6; i>=0; i--) {
for (var j:uint=0; j<8; j++) {
// If a spot contains a gem, and has an empty space below...
if (gems_array[i][j] != -1 && gems_array[i+1][j]==-1) {
// Set gems falling
gemsAreFalling=true;
gems_array[i+1][j]=gems_array[i][j];
gems_array[i][j]=-1;
trace("#");
trace(i+"_"+j);
container.getChildByName(i+"_"+j).y+=gemSize;
container.getChildByName(i+"_"+j).name=(i+1)+"_"+j;
break;
// If a gem is falling
if (gemsAreFalling) {
// don't allow any more to start falling
break;
// If no gems are falling
if (! gemsAreFalling) {
// Assume no new gems are needed
var needNewGem:Boolean=false;
// but check all spaces...
for (i=7; i>=0; i--) {
for (j=0; j<8; j++) {
// and if a spot is empty
if (gems_array[i][j]==-1) {
// now we know we need a new gem
needNewGem=true;
// pick a random color for the gem
gems_array[0][j]=Math.floor(Math.random()*7);
// create the gem
aGem=new Sprite();
aGem.graphics.beginFill(colours_array[gems_array[0][j]]);
aGem.graphics.drawCircle(gemSize/2,gemSize/2,gemSize/2.07);
aGem.graphics.endFill();
// ID it
aGem.name="0_"+j;
// position it
aGem.x=j*gemSize;
aGem.y=0;
// show it
container.addChild(aGem);
// stop creating new gems
break;
// if a new gem was created, stop checking
if (needNewGem) {
break;
// If no new gems were needed...
if (! needNewGem) {
// assume no more/new lines are on the board
var moreLinesAvailable:Boolean=false;
// check all gems
for (i=7; i>=0; i--) {
for (j=0; j<8; j++) {
// if a line is found
if (rowLineLength(i,j)>2 || columnLineLength(i,j)>2) {
// then we know more lines are available
moreLinesAvailable=true;
// creat a new array, set the gem type of the line, and where it is
var lineGems:Array=[i+"_"+j];
var gemType:uint=gems_array[i][j];
var linePosition:int;
// check t's a horizontal line...
if (rowLineLength(i,j)>2) {
// if so, find our how long it is and put all the line's gems into the array
linePosition=j;
while (sameGemIsHere(gemType,i,linePosition-1)) {
linePosition--;
lineGems.push(i+"_"+linePosition);
linePosition=j;
while (sameGemIsHere(gemType,i,linePosition+1)) {
linePosition++;
lineGems.push(i+"_"+linePosition);
// check t's a vertical line...
if (columnLineLength(i,j)>2) {
// if so, find our how long it is and put all the line's gems into the array
linePosition=i;
while (sameGemIsHere(gemType,linePosition-1,j)) {
linePosition--;
lineGems.push(linePosition+"_"+j);
linePosition=i;
while (sameGemIsHere(gemType,linePosition+1,j)) {
linePosition++;
lineGems.push(linePosition+"_"+j);
// for all gems in the line...
for (i=0; i<lineGems.length; i++) {
// remove it from the program
container.removeChild(container.getChildByName(lineGems[i]));
// find where it was in the array
var cd:Array=lineGems[i].split("_");
// set it to an empty gem space
gems_array[cd[0]][cd[1]]=-1;
// set the new score
score+=inaRow;
// set the score setter up
inaRow++;
// if a row was made, stop the loop
break;
// if a line was made, stop making more lines
if (moreLinesAvailable) {
break;
// if no more lines were available...
//ROTATION
if (! moreLinesAvailable) {
if(rotate){
container.rotation+=5;
if(container.rotation%90==0){
rotate=false;
container.rotation=0;
rotateClockwise(gems_array);
while(container.numChildren>0){
container.removeChildAt(0);
for (i=0; i<8; i++) {
for (j=0; j<8; j++) {
aGem=new Sprite();
aGem.graphics.beginFill(colours_array[gems_array[i][j]]);
aGem.graphics.drawCircle(gemSize/2,gemSize/2,gemSize/2.07);
aGem.graphics.endFill();
aGem.name=i+"_"+j;
aGem.x=j*gemSize;
aGem.y=i*gemSize;
container.addChild(aGem);
container.addChild(selectorBox);
selectorBox.graphics.lineStyle(2,red,1);
selectorBox.graphics.drawRect(0,0,gemSize,gemSize);
selectorBox.visible=false;
else{
// allow new moves to be made
clickPossible=true;
// remove score multiplier
inaRow=0;
// display new score
score_txt.text=score.toString();
// When the user clicks
function onClick(e:MouseEvent):void {
// If a click is allowed
if (clickPossible) {
// If the click is within the game area...
if (mouseX<container.x+gemSize*8 && mouseX>0 && mouseY<container.y+gemSize*8 && mouseY>0) {
// Find which row and column were clicked
var clickedRow:uint=Math.floor((mouseY-container.y)/gemSize);
//var clickedRow:uint=Math.floor(e.target.y/gemSize);
var clickedColumn:uint=Math.floor((mouseX-container.x)/gemSize);
//var clickedColumn:uint=Math.floor(e.target.x/gemSize);
// Check if the clicked gem is adjacent to the selector
// If not...
if (!(((clickedRow==selectorRow+1 || clickedRow==selectorRow-1)&&clickedColumn==selectorColumn)||((clickedColumn==selectorColumn+1 || clickedColumn==selectorColumn-1) && clickedRow==selectorRow))) {
// Find row and colum the selector should move to
selectorRow=clickedRow;
selectorColumn=clickedColumn;
// Move it to the chosen position
selectorBox.x=gemSize*selectorColumn;
selectorBox.y=gemSize*selectorRow;
// If hidden, show it.
selectorBox.visible=true;
// If it is not next to it...
else {
// Swap the gems;
swapGems(selectorRow,selectorColumn,clickedRow,clickedColumn);
// If they make a line...
if (rowLineLength(selectorRow,selectorColumn)>2 || columnLineLength(selectorRow,selectorColumn)>2||rowLineLength(clickedRow,clickedColumn)>2 || columnLineLength(clickedRow,clickedColumn)>2) {
// remove the hint text
hint_txt.text="";
// dis-allow a new move until cascade has ended (removes glitches)
clickPossible=false;
// move and rename the gems
container.getChildByName(selectorRow+"_"+selectorColumn).x=e.target.x;//clickedColumn*gemSize;
container.getChildByName(selectorRow+"_"+selectorColumn).y=e.target.y;//clickedRow*gemSize;
container.getChildByName(selectorRow+"_"+selectorColumn).name="t";
container.getChildByName(clickedRow+"_"+clickedColumn).x=selectorColumn*gemSize;
container.getChildByName(clickedRow+"_"+clickedColumn).y=selectorRow*gemSize;
container.getChildByName(clickedRow+"_"+clickedColumn).name=selectorRow+"_"+selectorColumn;
container.getChildByName("t").name=clickedRow+"_"+clickedColumn;
match = true;
rotate = true;
// If not...
else {
// Switch them back
swapGems(selectorRow,selectorColumn,clickedRow,clickedColumn);
match = false;
if (match) {
// Move the selector position to default
selectorRow=-10;
selectorColumn=-10;
// and hide it
selectorBox.visible=false;
else {
// Set the selector position
selectorRow=clickedRow;
selectorColumn=clickedColumn;
// Move the box into position
selectorBox.x=gemSize*selectorColumn;
selectorBox.y=gemSize*selectorRow;
match = false;
// If hidden, show it.
selectorBox.visible=true;
// If the click is outside the game area
else {
// For gems in all rows...
for (var i:uint=0; i<8; i++) {
// and columns...
for (var j:uint=0; j<8; j++) {
// if they're not too close to the side...
if (i<7) {
// swap them horizontally
swapGems(i,j,i+1,j);
// check if they form a line
if ((rowLineLength(i,j)>2||columnLineLength(i,j)>2||rowLineLength(i+1,j)>2||columnLineLength(i+1,j)>2)) {
// if so, name the move made
selectorBox.x = j*gemSize;
selectorBox.y = i*gemSize;
selectorBox.visible = true;
hint_txt.text = (i+1).toString()+","+(j+1).toString()+"->"+(i+2).toString()+","+(j+1).toString();
// swap the gems back
swapGems(i,j,i+1,j);
// then if they're not to close to the bottom...
if (j<7) {
// swap it vertically
swapGems(i,j,i,j+1);
// check if it forms a line
if ((rowLineLength(i,j)>2||columnLineLength(i,j)>2||rowLineLength(i,j+1)>2||columnLineLength(i,j+1)>2) ) {
// if so, name it
selectorBox.x = j*gemSize;
selectorBox.y = i*gemSize;
selectorBox.visible = true;
hint_txt.text = (i+1).toString()+","+(j+1).toString()+"->"+(i+1).toString()+","+(j+2).toString();
// swap the gems back
swapGems(i,j,i,j+1);
//Swap given gems
function swapGems(fromRow:uint,fromColumn:uint,toRow:uint,toColumn:uint):void {
//Save the original position
var originalPosition:uint=gems_array[fromRow][fromColumn];
//Move original gem to new position
gems_array[fromRow][fromColumn]=gems_array[toRow][toColumn];
//move second gem to saved, original gem's position
gems_array[toRow][toColumn]=originalPosition;
//Find out if there us a horizontal line
function rowLineLength(row:uint,column:uint):uint {
var gemType:uint=gems_array[row][column];
var lineLength:uint=1;
var checkColumn:int=column;
//check how far left it extends
while (sameGemIsHere(gemType,row,checkColumn-1)) {
checkColumn--;
lineLength++;
checkColumn=column;
//check how far right it extends
while (sameGemIsHere(gemType,row,checkColumn+1)) {
checkColumn++;
lineLength++;
// return total line length
return (lineLength);
//Find out if there us a vertical line
function columnLineLength(row:uint,column:uint):uint {
var gemType:uint=gems_array[row][column];
var lineLength:uint=1;
var checkRow:int=row;
//check how low it extends
while (sameGemIsHere(gemType,checkRow-1,column)) {
checkRow--;
lineLength++;
//check how high it extends
checkRow=row;
while (sameGemIsHere(gemType,checkRow+1,column)) {
checkRow++;
lineLength++;
// return total line length
return (lineLength);
function sameGemIsHere(gemType:uint,row:int,column:int):Boolean {
//Check there are gems in the chosen row
if (gems_array[row]==null) {
return false;
//If there are, check if there is a gem in the chosen slot
if (gems_array[row][column]==null) {
return false;
//If there is, check if it's the same as the chosen gem type
return gemType==gems_array[row][column];
//ROTATION
function rotateClockwise(a:Array):void {
var n:int=a.length;
for (var i:int=0; i<n/2; i++) {
for (var j:int=i; j<n-i-1; j++) {
var tmp:String=a[i][j];
a[i][j]=a[n-j-1][i];
a[n-j-1][i]=a[n-i-1][n-j-1];
a[n-i-1][n-j-1]=a[j][n-i-1];
a[j][n-i-1]=tmp;
bejewelled();
Any help appreciated.OK, way too much code. By default, everything will rotate from top left. If you want to change that you need to change the positions of the content within the container, not the container itself.
For example if you do something like this:
var a:Sprite = new Sprite(); //container
addChild(a);
a.x = 100; a.y = 100;
var b:MovieClip = new car(); //clip from library
a.addChild(b);
addEventListener(Event.ENTER_FRAME, up);
function up(e:Event):void
a.rotation += 1;
The car added to the container will rotate about it's top left point... because that's where the container rotates about. To fix, move the car so the containers top/left is at the car's center like so:
var a:Sprite = new Sprite();
addChild(a);
a.x = 100; a.y = 100;
var b:MovieClip = new car();
a.addChild(b);
b.x -= b.width / 2;
b.y -= b.height / 2;
addEventListener(Event.ENTER_FRAME, up);
function up(e:Event):void
a.rotation += 1;
You'll notice all that changed is moving the car 1/2 it's width and height.
HTH -
MouseEvent.LocalX co-ordinates doesn't resize with sprite
I'm looking into how to create a custom sprite which the
mouse performs different actions depending which part of the sprite
it is clicked on they are:
1) Click and drag on the left edge able extends the box to
the left
2) Click and drag in the middle able to move the box round
the screen (drag and drop)
3) Click and drag on the right edge able to extend the box to
the right.
I've looked at a couple of ways to implement the context on
the rectagle. One of them is testing where the mouse clicks on the
sprite. My code for that test is this:
private function get LeftHandRegion () : Number {return 25;}
private function get RightHandRegion () : Number {return
width - 25;}
private function IsInLeftHandRegion(event:MouseEvent) :
Boolean {return (event.localX < LeftHandRegion);}
private function IsInRightHandRegion(event:MouseEvent) :
Boolean {return (event.localX > RightHandRegion);}
private function IsInMiddleRegion(event:MouseEvent) : Boolean
return (event.localX >= LeftHandRegion &&
event.localX <= RightHandRegion)
If I set my original sprite size to 300 everything works as
it should and I can perform all 3 actions correctly.
However if I then streatch my rectangle to 800 the
event.LocalX only goes upto the original 300 event though the
sprite is now bigger so my test for the right hand region fails so
I can't extend my box to the right any more.
Does any one have any ideas?I have found a solution to this problem. On the mouseup event
I remove the current resized DisplayObject from its parent.
Then I create a new DisplayObject and pass in the parameters
from the existing but resized DisplayObject.
The new DisplayObject is then added back to the parent.
Then everything works :D
Code snippet is this:
var year:YearDisplay = YearDisplay(parent);
year.removeChild(this);
var newUnitDisplay = new UnitDisplay(x, y, width, height,
_unit, _colour);
year.addChild(newUnitDisplay);
Maybe you are looking for
-
Problem in compiling with ant?
Hi, I have problem with compiling using ant ..i have build file...and properly place directories....... C:/>ant build It's giving an error as "Exception in thread "main" java.lang.NoClassDefFoundError: build" can any one help me to solve this problem
-
Releasing Blocked invoices Automatically
Hi All, During the relasing blocked invoices automatically, after entering the selcition parameters and selecting the radio button Release Automatically executed the transaction. In the output screen the system only displays the message " Blocking re
-
I have a question about the mac desktop mail app. I cannot seem to get it to work with my Yahoo mail account. Whenever I try to enter my information, a notification always opens up saying that I need a password for the POP server. Does anyone know
-
I'm curious how large of an image can Muse display. For example, I like photography sites where the images fill up a large part of the screen. From the sample sites in the Muse section of the Adobe site, I didn't see any images shown at my preferred
-
Access to Setup- Notification Methods without any Pack?
Hello, I try to configure E-Mail notification in EM GC 10.2.0.4, but it is unaccessible after deactivating all purchasable packs. ("Notification Methods" under Tab "Setup" is deactivated). Do I need to buy a Management Pack for configure and use an E