If you are working with multiple layers of MovieClips, each with their own ActionScript (trust me, with dynamic projects, you can end up in a situation where MovieClips have minds actions of their own) you might come across a situation where you need to access a variable or another MovieClip from the MovieClip that owns it (as in it’s parent) or even two or more above.  (If you need to skip all the nested MCs and access a variable on the now-depricated _root read this article)

This is actually quite easy with a method called parent, utilizing the hierarchy of your MovieClips to access variables from any number of levels away from your current execution realm.

To access a variable – let’s call it myVariable – from one level up in your tree, use this:

trace( MovieClip( parent ).myVariable );

Similarly, to access a variable two or more MovieClips up in the tree, nest the parent calls accordingly.

trace( MovieClip( parent.parent ).myVariable );

You can do this ad-infinitum to the root of the whole project if you so desire, but in this case, again, I’d recommend that you read the article mentioned above.

To access other MovieClips, the process is very much the same, except instead of a variable name, you would use a MovieClip’s Instance Name followed by the property you wanted to adjust, as such:

MovieClip( parent ).myMovieClip.visible = true;

-or-

MovieClip( parent.parent.parent ).myMovieClip.gotoAndStop( 1 );

etc.

Hope this helps someone,

Cheers,

~/A\V/

Tagged with:
 

Bit of a longer hiatus from this blog than I had imagined – Orange has kinda been taking up a LOT of time lately (I have quite a few articles that are non-tech related that need to be edited and then I will post) – but here’s an ActionScript Quickie:

If you need to work with a variable from the Main Timeline (formerly _root in AS2) in another MovieClip in the same project, you can do this by using the “root as MovieClip” property.  This allows you to load elements from what was _root into your current working MC. (If you only need to go one or two levels up, read this article)

Quick and dirty, in your new MC, you can test this functionality with the following:

trace((root as MovieClip).myVariable);

Replace “myVariable” with the variable you wish to access from the Main Timeline, of course.

Digging a little deeper, we can assign this variable to a more… suitably accessible medium by using the following (assuming that the variable type is String for this example, use the typecast that you need in a situation):

var myNewVariable:String = (root as MovieClip).myVariable;

Again, replace “myVariable” (and variations therein) with your own names.

Hope that this helps someone!

Cheers,

~/A\V/

Tagged with:
 

From time to time you might find it necessary to track the cursor when working with Flash.  Fortunately, this is fairly easy.

As with all things Flash when dealing with values, you should create the variables beforehand so as to prevent loads of errors when compiling.

Here’s the code, it uses an Event Listener:

var yCoord:Number = 0;
var xCoord:Number = 0;

stage.addEventListener(MouseEvent.MOUSE_MOVE, mouseMove); function mouseMove(event:MouseEvent){
yCoord = mouseY;
xCoord = mouseX;
} );

yCoord and xCoord would be your mouse coordinates.  This Event Listener is called on on the stage to ensure that you get the coordinates whenever the mouse moves across the stage.  In the event that you would like the mouse to be tracked only on a particular movie clip, exchange the “stage” identifier for the identifier of the movie clip you want to track the movements on.

Hope this helps someone…

/A\V/

Tagged with:
 

Today I was attempting to make a movie clip that would fade in on rollover and fade out on rollout.  The problem that I had, however, was that there are buttons placed inside this mc, and if you in turn mouse over them, it causes the whole thing to quickly fade out/in all over again – for whatever reason – making a blinking mess.

Anyway, after a rather frustrating search across google, I came across some interesting information.  There is, now, in AS3, a property called Mouse.cursor, and using it, along with event listeners, you can force the mouse cursor to be whatever you want it to be!

It has a total (that I know of) number of five different properties: ibeam, hand, arrow, button, and auto, and is formed as such:

Mouse.cursor = “ibeam”;
Mouse.cursor = “hand”;
Mouse.cursor = “arrow”;
Mouse.cursor = “button”;
Mouse.cursor = “auto”;

And you would put whichever one you need inside your rollover event listener.  Be sure to set it back to auto after you roll out, otherwise you could end up with a very confusing UI experience!

Hope this helps someone!

/A\V/

Tagged with:
 

If you, like me, set up your Bugzilla install based on IP initially (because you didn’t have the domain ready or whatever), and then you moved the Bugzilla box, either physically or electronically – either way changing your IP address – you might notice that your bugzilla only lets you go to the front page before rerouting you into blue hell somewhere – or nowhere at all.

This is because the configuration of Bugzilla is based off of a customizable URLbase (for security or some other important reason that I care too little about to follow up on) and if that URLbase is an IP address, such as http://123.456.789.100/bugzilla (No, that link doesn’t work.  Stop clicking it.), and your box is now located at, say, 987.654.321.001 (That’s not a real IP either.  Don’t bother trying.), you’ll need to change this URLbase – either to your new IP address, or – maybe you’d like to show some initiative (I know I didn’t!) – even an actual URL!  The only problem is…  that setting is in the administration area, and you can’t get there unless your URLbase is correct.  Damn those Catch-22’s.

Logically, this means we need to hand-edit the configuration file.  Unfortunately, it isn’t exactly labeled “configuration_files_VIM_me_to_fix_URLbase_problems.conf.”  Fortunately, I know where the file is.  Unfortunately, I’m no longer in a sharing mood.   Fortunately, I’m joking. Unfor….  Ok, I’ll stop.  Just please, please put down the gun…

Alright – you calm and relaxed again?  Good.  Alright – so, open up your Terminal Application (whichever that may be for your particular flavor of *Nix), and get yourself to the bugzilla root.  (Mine, for example, is in /var/www/bugzilla/)  Once you’ve gotten there, the rest is exceedingly easy.  navigate to the folder “data” and Vim (or vi, or kate or whatever) the file params.  You shouldn’t even need to sudo it.  Inside, you will find an actual alphabetical list of all the bugzilla parameters!  How amazing is that?  Page down to the U’s, find urlbase, and change it accordingly.  :wq (or…  well, you should know how to save and quit your favorite text editor) and simply log into your bugzilla – problem solved!

I’ll actually answer questions you might have on this one.  Or on bugz in general, should i know the answer, so feel free to ask.

Tagged with:
 

Take Better Screenshots in OSX

Almost everyone needs to take a screenshot now and again – be it for obtaining assistance with tech support or just showing off your latest layer in that sick photoshop doc you’re working on.

Granted, if you are working on a sick photoshop document, you probably already know all this.

(more…)

Tagged with:
 

Whew that’s a long title.

Basically, i have a string that I have hashed out – for storage in a database.  It looks like this:

Name#123#345#456#678#789#

Now, the problem is – I need to get the first value from this string – before the first ‘#’ – but it could be of completely variable length.  This poses a problem – if all sections were of a set length this would be far easier.  Not to mention that the string as a whole could have a variable number of segments.

The solution – as I have found – is to use a nasty looking string in PHP to parse it out.  For the sake of this example, let’s call our nasty string up there $toParse.

<?php $name = substr($toParse, 0, strpos($toParse, "#")); ?>

This will, in turn, set the variable $name to ‘Name’.

Now – let’s say that I need to actually parse all of these sections.  This is also quite easy to accomplish.. We just execute this, plus one more bit – recursively.

<?php
$workingString = $toParse;
//While we still have some string left
while ($workingString != ""){
$name = substr($workingString, 0, strpos($workingString, "#"));
//Remove the previous entry and the previous hash
$workingString = substr($workingString, (strpos($workingString, "#")+1));
//Do whatever you intend to do with your $name result
}
?>

And… That’s pretty much it.

Tagged with:
 

Remember those of you who found this site purely by accident – this site is mostly for my own use.

That said – here for my reference – the Bash commands that I end up using most often with the php exec(); command or in the shell – here in case I forget them… again. (I can remember what everyone ate at my last job interview, yet I have trouble remembering simple shell commands… odd.)

Use sudo as needed!
(more…)

Tagged with:
 

The other day a good friend of mine asked me what the number equivalent of drwxr-xrwx was.

Most people who are up to their arms in Bash everyday know how to compute this – but for everyone else the Terminal App in most Debian/BSD based operating systems display the permissions in alpha – yet kind of require that you change the permissions using number notation.

To compute this, it’s actually really simple – so long as you understand binary. 

Each subset of three letters can be assigned a binary value – 4, 2, 1.  For Example:

rwx r-x rwx
111 101 111
421 401 421

Then, computing in standard binary fashion, compute the  value, in this case, 4+2+1 = 7, 4+0+1 = 5, 4+2+1 = 7.

Put these all together, add the chmod command (and, in some cases the all too awesome sudo) and we get:

$ sudo chmod 757 filename.txt

Any questions? =)

Tagged with:
 
Pro Palma Deus Unus