Member Avatar for iamthwee

Does anyone know how to set the reference points on a movieclip programatically?

Im loading images (xml driven) but was wondering how to set the reference points through code in actionscript 3.

Any ideas?

Hmm, this is something that's stumped me recently too.
I've been messing around with importing Inkscape .svg's into AS3, but the registration point of the .svg's are always at 0,0 (top left), whereas I usually want the registration point to be at the centre of the graphic.

For now, I've resorted to shifting everything in my .svgs so that the centre of the image is at the top left of the canvas. Which works ok for .svg images, but that won't work for .jpg or any other bitmap/raster images.

Not sure if there's a way of setting a transform or something......I don't know. The Flash IDE's allow you to set the registration point for any type of object and most of the stuff available in the Flash IDE is also accessible via actionscript, so I would imagine there must be a way of doing it, but I gotta say I'm still searching for it!

As ever, if I come up with anything I'll post it here!

Cheers for now,
Jas.

Aha, This looks like the sort of thing I was expecting:

mc.transform.matrix = new Matrix(1, 0, 0, 1, -regx, -regy);

That should allow you to set the registration point of a movie clip. At least according a poster at the page on the following URL:
http://www.kirupa.com/forum/showthread.php?t=245159

Not tried it out yet. Will get back to you when I have!

Cheers for now.
Jas.

Member Avatar for rajarajan2017

Please find the attachment for an sample application to change the registration point in AS3.0.

Also have a look at here for the same in AS2.0:
http://www.darronschall.com/weblog/2003/09/dynamic-movieclip-registration-with-as2.cfm

Member Avatar for iamthwee

Thanks jas and raj. Raj I think that is exactly what I need but at the moment I want to get the other stuff to work.


What I am trying to do is create a slideshow which displays three images loaded from an xml file. When you click next it should shift the three images to the right. The same with the back button

I want the movieclips to be stored in an array but can't figure how to do this? So I can reference the mouseover and display the item names in a dynamic text field underneath. Here is my attached code.

Any help would be great. Please ask questions if you are unclear.

I'm afraid I'm out of this one...Looks as though your file was made with CS4 which I don't have! I've got a .swf decompiler on my work pc that should allow me to decompile it to a flash CS3 compatible .fla or pure AS3/flex. I'll have a go at that tomorrow morning, unless raja posts something in the meantime!

Cheers for now,
Jas.

commented: Next time I'll compile it for AS3... +11
Member Avatar for iamthwee

Guys don't waste your time i got something else.

But i need help with the code...will post it tomorrow.

Member Avatar for rajarajan2017

Please find the attached source.

I have done these things in your file:
Added a declaration: var mcNames:int;
Generating MovieClip Names: mc.name=String(mcNames++);

Button Handler2 on MouseOver:

TweenLite.to([B]mvc[evt.target.name][/B], 1, { scaleX:0.6, scaleY:0.6, ease:Elastic.easeOut});
txtDisp.text = disp[evt.target.name].toString();

In the above code, I utilized the array for tweening, so it denotes you have already pushed the movieclips, Right!
and directly given the name of that movieclip into disp.

Now check, it will give you all the rollover effects and also the text relevant to that.

Thats it!!!

commented: *likes* +11
Member Avatar for iamthwee

Thanks for the help guys. Jason, I will consider saving my code in CS3 next time so you can get a chance to look at it LOL.

Raj that was definitely useful to know however, I ended up buying a slider component for about $6 and used it for the stuff I'm doing.

Member Avatar for rajarajan2017

COOL!!!

Thanks for the help guys. Jason, I will consider saving my code in CS3 next time so you can get a chance to look at it LOL.

Heh heh, bit of a moot point now...Looks like our one and only Windows (XP pro) machine at home has finally given up the ghost and died...I spent many hours last night trying to ressurect the damn thing, but to no avail. Part of the problem appears to be with Windows, a few files used during boot/windows startup have corrupted, looks like one or more of the device drivers have gone a bit wonky. It also looks as though the hard drive has almost completely packed up too (old age!). There are no viruses or malware on there, so no foul play is suspected. I think the corruption is due to the HD's old age.

I managed to get most of our important docs off of it, but as the PC is really old, I'm thinking of perhaps putting a new drive in and slapping linux on there, I've had enough of Windows and the constant need for updates, patches and workarounds!
It noticeably slowed down after service pack 2 was installed on it, and after service pack 3 it was even worse. So I think linux will run a lot better on the tired old thing. We'll be able to get things done a lot faster on it without windows!

So it looks like I'm gonna be doing all of my flash dev stuff 100% in Linux from now on. Inkscape for .svg graphics, gEdit for writing AS3 code (no code completion, but hey!) and the Flex SDK with my own little wxWidgets based graphical frontend; a simple compiler hooking into the tools in the SDK ATM, but I intend to eventually turn it into a full flashdevelop-like IDE complete with code editor, completion, highlighting etc etc.

Speaking of Flashdevelop, that will be the only drawback to not having Windows....No Flashdevelop :( . I can live without the flash IDE, but no Flashdevelop... :(

On the upside I've also discovered a new open source flash IDE, similar to flashdevelop in many ways, but a little more stripped back and simplified.

An open source AIR application called AirMiniBuilder ( http://code.google.com/p/minibuilder/ ), a lightweight, cross-platform IDE for flash development.
You need the latest stable version of the flex SDK, plus java and the adobe AIR runtime installed in order to install and run it.

It's still in alpha, so very much a work in progress, but I like what I've seen so far. I've had a brief play with it in Windows (before our Windows PC died!), but I haven't tried it in *nix yet. It's got code completion and a basic built-in project template.

I've a feeling that plans for my own IDE may end up being discarded in favour of this! (As long as I can get it working on *nix that is!)

So it looks like use of any Adobe Flash IDE is completely out of the question for me for now.

Cheers for now,
Jas.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.