PDA

View Full Version : if (_level1._currentframe == "frame_label") question


jamesbooth
02-28-2006, 02:31 PM
I hope this is a very easy question to answer, im a designer and im having a go with some coding, but so far its not comming along as i wish.

I have a main site.swf which i have loaded 3, pic1.swf, pic2.swf and pic3.swf into it, using the tutorial from here.

then on each of the pic?.swf's i have added a button so that once clicked will animate the pic?.swf's down and out of the way of the ones infront or behind.

but the code i have come up with doesnt seem to work. i was hoping that some one could try and help me sort out my huge problem.

pic1.swf is on _level3 // at the top
pic2.swf is on _level2 // in the middle
pic3.swf is on _level1 // at the bottom

this is on the button from the middle layer pic2.swf

on(press)
{
if (_level0._level1._currentframe == "up")
{
_level0_level1.play();
}

if (_level0._level3._currentframe == "up")
{
_level0._level3.play();
}

}



on the pic?.swf files there is a preloader one frame one which plays to frame 5 which is called "up" where the image is visible. then there are another 5 frames to a stop(); command where the image has moved back to a hidden position.

JEBoothjr
02-28-2006, 02:43 PM
Hey! There's only room for 1 James Booth on this board! :) JK!

I would try to get away from using levels and instead use MovieClips to load you swf's into.

Using your current code though, I'm not sure why you have "_level0._level1._". Just access it with _level1

Also, I'm not positive, but I think _currentframe returns a number. I don't think you can access the label.

jamesbooth
02-28-2006, 02:51 PM
hello james,
so if i loaded them all into different mc's on different layers, how do i get the pic?.swf's to play only if they are on frame 5?

JEBoothjr
02-28-2006, 03:23 PM
First, you wouldn't load them onto different layers.

Here's a simple example:

I have an empty clip onscreen called clip1_mc that we will load "minor.swf" into.


var mclListener:Object = new Object();
mclListener.onLoadInit = function(target_mc:MovieClip) {
target_mc.play(); //Do anything here, since it's loaded. We'll just play it.
};
var image_mcl:MovieClipLoader = new MovieClipLoader();
image_mcl.addListener(mclListener);
image_mcl.loadClip("minor.swf", clip1_mc);


Anytime after it's loaded, we can access the frame of minor.swf as clip1_mc._currentframe

later you can just use


if(clip1_mc._currentframe == 5){
clip1_mc.play();
}


There are better ways to structure this, but I'm not sure how your project is set up.

jamesbooth
02-28-2006, 04:13 PM
to make things a little easier i'll show you what sort of thing i was trying to achieve,

http://www.suburbdesign.co.uk/

if you click on the work samples on the side the images all load into the left one at a time. do you know how that was done?

JEBoothjr
03-01-2006, 02:41 PM
The way I would do that, would be to have an XML file with a separate node for each of the menu items and within each of those nodes, a node for each image.

When you click on a menu item, it will grab that particular XML node and create a cue of images to load. Then, create a container MovieClip which will house each of the images. Each image is loaded into a new empty MovieClip within the container and is placed below the previous, offstage. When each image icon is clicked, the position of the container is tweened along the Y.

Let me know if that helps you out.

jamesbooth
03-01-2006, 04:22 PM
yes and no,
no besause i have no idea what you said
and
yes because ive decided im out of my actionscript league.

thank you very much tho