PDA

View Full Version : referencing a movie clip object?


notsotrickyricky
08-09-2008, 09:38 PM
I have a panorama I am working on and I am trying to reference the individual movie clip objects that make up the panorama and assign them to a variable.

Each movie clip consists of a jpg with part of the view. I have enabled linkange correctly and I have assigned instance names.

I would like to use a variable to track the x & y coords of the current clip by changing the value of the variable that represents the current loaded clip.
Something like this:
var currentMovie = new Object();
currentMovie = "part1_mc";

then in other pieces of code:
x = currentMovie._x

etc. But when I trace currentMovie it always says undefined?
I can't set the value in the same timeline because it will constantly reset
the value of currentMovie to the starting movie so I have the definition set in an actions layer inside the main movie clip.

Can someone explain to me or show me the proper way to create such a variable and to reference it later?

DiamondDog
08-09-2008, 10:39 PM
I think the problem is, you're assigning currentMovie a string value when you really want to make it a movie clip.

Try this
var currentMovie = new Object();
currentMovie = part1_mc; // without quotation marks


I'm not sure, but you may even need to cast that object as a movie clip

var currentMovie = new Object();
currentMovie = MovieClip(part1_mc); // without quotation marks

notsotrickyricky
08-10-2008, 01:12 AM
I think the problem is, you're assigning currentMovie a string value when you really want to make it a movie clip.

Try this
var currentMovie = new Object();
currentMovie = part1_mc; // without quotation marks


I'm not sure, but you may even need to cast that object as a movie clip

var currentMovie = new Object();
currentMovie = MovieClip(part1_mc); // without quotation marks


Hmmm just tried both those methods and declared them in the same timeline even and they both returned undefined when I ran a trace?

this is the code I used:
var curMovie = new Object();
curMovie = MovieClip(part1_mc);

this is really baffling me? I am tryin to make one movie clip load as I reach the end of another forming a panorama? Do you know how I might go about this?

atomic
08-10-2008, 03:42 AM
DD posted AS3.0 code...

Assuming you have a part1_mc on stage with that instance name, this works...

var currentMovie:MovieClip = part1_mc;
trace("The movie clip: "+currentMovie+"'s current x coordinate is: "+currentMovie._x);

That said, don't see where you're going with that, to solve your pano scroller problem?

notsotrickyricky
08-10-2008, 06:04 AM
First I must say thank you for your responses. I have posted several questions concerning this project and you have helped me alot!

That said, the reason I am trying to find a way to access the movieclips in the manner I have presented in this thread, is to hopefully be able to control them through actionscript. (at which I am very new)

In another post in which I posted my fla to a site and sent you the addy you told me to that my image was too big and had to be broken into pieces no longer than 2880 pixels each.

So I have done that and now I'm trying to do what you termed in your response as "tagging" one movieclip to the end of the preceding one.

But I really have no clue how to go about that. So this is my attempt at getting access to the clip via script and then I am going to try to develop some code to manipulate the movieclip pieces to display properly in a scrolling panoramic view.

Again I thank you for you efforts, but what you showed me in this thread doesn't work in my set up.

In in frame 1 of a layer named "action" layer in my panorama.fla is where I am defining the variable "curMovie". Then trying to use it in an empty movieclip that is being used to control the panning. The empty movie clip is instance named "control" The control movieclip has two layers. "right" and "left".
each layer consists of 3 coded frames. The "right" layer code exists in the first 3 frames (frames 1-3) "left" layer code exists in the next 3 frames, frames 4-6)
The code in frames 1 & 4: stop();
The code in frames 3 & 6: gotoAndPlay(2) or (5) depending on which timeline(right or left)
The code in the frames 2 & 5 is: NOTE (zInc is just a variable used to increment the speed.)

x = getProperty(_root.part1_mc, _x);
if (x > -2616) {
zInc = zInc + 1
setProperty(_root.part1_mc, _x, x - 3 - (Math.round((zInc / 100) * (1 + (zInc / 300)))));

and this in the other:
x = getProperty("_root.part1_mc", _x);
if (x < 0) {
zInc = zInc + 1
setProperty("_root.part1_mc", _x, x + 3 + (Math.round((zInc / 100) * (1 + (zInc / 300)))));


that is the code in the "control" movie clip.
I have the control clip placed on it's on layer in the main .fla file.

The only other part is the navButtons layer. I have a right and left scroll button on the screen.
and here is the code for the buttons:

on (rollOver) {
tellTarget ("control") {
zInc = 0;
gotoAndPlay(2); // or (5) depending on the button
}
}
on (rollOut, dragOut) {

tellTarget ("control") {
gotoAndStop(1); // or (4) depending on the button
}
}

Using the control clip is something I saw on the internet that successfully scrolls the picture across left or right.

At first I tried this using just one picture which was 13,000 pixels long and it worked locally (which I stil don't understand?) but when I tried to load the swf into a browser or in the kiosk it wouldn't work. (wouldn't load the picture - the scrolling still worked)

To be repeating myself, you pointed out my error of using a picture too big for flash to deal with in a different thread and this is where I am at now. So the problem now for me is in "tagging" the successive movieclips making up the panorama to the end of the preceding one?

atomic
08-10-2008, 07:18 AM
I'm waisted tonight, and going to bed...

But if you upload your current .fla - the previous one doesn't hold the sliced up pictures - I'll have a look in the morning, and set it up for you, and/or maybe even suggest an easier & better scrolling script...

notsotrickyricky
08-10-2008, 08:10 AM
I'm waisted tonight, and going to bed...

But if you upload your current .fla - the previous one doesn't hold the sliced up pictures - I'll have a look in the morning, and set it up for you, and/or maybe even suggest an easier & better scrolling script...

That is totally awesome! I so appreciate your efforts on my behalf!
The new fla is at http://www.coreyscorner.com/panorama.fla
I'll check back tomorrow as well.

notsotrickyricky
08-10-2008, 10:04 PM
[QUOTE=atomic;776499]I'm waisted tonight, and going to bed...

HEY! I finally figured it out! and it was so simple! I just positioned ( as you alluded to) part2_mc in relation to the x coordinate of part1_mc works fine now. (once I figure out the splice coords, but that isn't too hard!) Thanks for all the help you have offered and if you have a simpler idea I would still be interested in seeing it! :)

atomic
08-10-2008, 11:45 PM
Grrrrrrrrrrrrreat! ;)

notsotrickyricky
08-11-2008, 12:05 AM
WELL that only went well for a short time? I can position part2_mc but once it reaches the limit it stops playing. I am messing with making curMovie = to part2_mc and which resets the x coord but so far it isn't working???

what a day eh!

atomic
08-11-2008, 03:40 AM
I'm having a hard time trying to extract your large .jpg... Can you provide a link to download it, so that I can slice it up?

notsotrickyricky
08-11-2008, 04:07 AM
I'm having a hard time trying to extract your large .jpg... Can you provide a link to download it, so that I can slice it up?

I took a short Olympics break :) Here's the link for the original .jpg in one piece. http://www.coreyscorner.com/HRtest.jpg

One thing to note: I will be adding buttons where the dots are located if you can avoid splittin on those points it would help but if that is not possible I'll find a way to work my buttons around it!

I'm not sure why the scrolling for me stops when I change the values of curMovie to part2 since the x coords revert to 0 it shouldn't be a length issue. But I will keep forging ahead best I can. :)

Thanks so much for continuing to assist me with this.

atomic
08-11-2008, 07:45 AM
How's this for starters?

http://rapidshare.com/files/136459630/ricky.swf.html

notsotrickyricky
08-11-2008, 11:16 AM
How's this for starters?

http://rapidshare.com/files/136459630/ricky.swf.html

That looks awesome! Can I get the fla?
I managed to get mine going all the way to the right but it keeps stopping on me on the way back!

Been up all night trying to get that fixed! :)

Looks like you didn't have to break it into pieces!

atomic
08-11-2008, 03:42 PM
It's sliced up in 5 slices and what you see there are .gifs not .jpgs. Couldn't output .jpgs for some reason, but it should be possible...

I'll clean up the .fla and post a link to it in a while...

atomic
08-11-2008, 05:20 PM
Here's the link to the .fla...

http://rapidshare.com/files/136559788/ricky2.fla.html

notsotrickyricky
08-11-2008, 10:50 PM
Here's the link to the .fla...

http://rapidshare.com/files/136559788/ricky2.fla.html

Thank you atomic for your assistance!
I just woke up from a nap and figured I''d check here.
The method you used is much better than what I was doing. I was still getting some small slow downs when I switched pieces which is how I was traversing them one piece at a time.
I added my buttons, swapped out the pics for pngs, and a few other minor tweaks to fit my main.fla and theme and it works wonderfully!

If there were a rating system on this forum I would definitely offer my vote!
Here's the look when I finished. There isn't much difference, just figured I'd show you how it came out so here's the link: :)http://www.coreyscorner.com/panorama.swf

Best Regards,

atomic
08-12-2008, 01:29 AM
Grrrrrrrrrreat! ;)

The only rating system is my Paypal account!

Just kidding! Glad it worked out for you!

Now, does (will) it work on the kiosk?