Jump to content
Search Community

Swapping Depth w/ Content Display?

soupking test
Moderator Tag

Recommended Posts

Hi GreenSock,

 

Pardon me if this s a straight AS3 question not related to LoaderMax. I used LoaderMax to import some images. Now I have them in arrays and I'm trying to swap depths.

 

I'm trying

swapChildren(_aImages[1], _aImages[3])

 

Trying to trace:

trace(_aImages[1].depth);
trace(_aImages[1].name.depth);

 

I have no idea what is going on. Do I need to swap movieclips instead of content displays? I'm in a button event so I don't even know how to parent the situation if need be. Really boggled.

 

Thanks for any feedback.

Link to comment
Share on other sites

what are the results of your traces?

 

can you confirm that a_images[1] targets your ImageLoader?

 

its hard to give any real assistance without seeing how the array is built or how you added the Loaders to the displayList.

 

 

can you post more code or a simplified set of files that exhibits the problem?

Link to comment
Share on other sites

Hi Carl,

 

Here's as larger picture of the code I'm dealing with:

 

function iCompleteHandler(event:LoaderEvent):void {
       // set initial menu button to on
_aMenu[0].gotoAndStop(2);
  	var currentCaption:String = _aCaption[1];
var lastClicked:MovieClip = menu_mc.feature1_mc;

function over(evt:MouseEvent):void 
{
	if(evt.currentTarget!=lastClicked){
		evt.target.gotoAndStop(2);
	}
   }
   function out(evt:MouseEvent):void {
	if(evt.currentTarget!=lastClicked){
		evt.target.gotoAndStop(1);
	}
   }   
function clicked(evt:MouseEvent):void {

	/* SWAP DEPTHS
	/* timer kill/reset
	*/

	switch (lastClicked.name)
	{
		case "feature1_mc":
			stringInQ = _aCaption[0]
			caption_mc.caption_txt.text = stringInQ.toUpperCase();
			_aImages[0].getDepth();
			//setChildIndex(_aImages[0], numChildren - 1);
			break;
		case "feature2_mc":
			stringInQ = _aCaption[1]
			caption_mc.caption_txt.text = stringInQ.toUpperCase();
			//setChildIndex(_aImages[1], numChildren - 1);
			break;
		/*case "feature3_mc":
			stringInQ = _aCaption[2]
			caption_mc.caption_txt.text = stringInQ.toUpperCase();
			break;
		case "feature4_mc":
			stringInQ = _aCaption[3]
			caption_mc.caption_txt.text = stringInQ.toUpperCase();
			break;*/
	}
   }

menu_mc.feature1_mc.buttonMode = true;
menu_mc.feature1_mc.useHandCursor = true;
menu_mc.feature2_mc.buttonMode = true;
menu_mc.feature2_mc.useHandCursor = true;
menu_mc.feature3_mc.buttonMode = true;
menu_mc.feature3_mc.useHandCursor = true;
menu_mc.feature4_mc.buttonMode = true;
menu_mc.feature4_mc.useHandCursor = true;

menu_mc.feature1_mc.addEventListener(MouseEvent.ROLL_OVER, over);
menu_mc.feature1_mc.addEventListener(MouseEvent.ROLL_OUT, out);
menu_mc.feature1_mc.addEventListener(MouseEvent.MOUSE_UP, clicked);
menu_mc.feature2_mc.addEventListener(MouseEvent.ROLL_OVER, over);
menu_mc.feature2_mc.addEventListener(MouseEvent.ROLL_OUT, out);
menu_mc.feature2_mc.addEventListener(MouseEvent.MOUSE_UP, clicked);
menu_mc.feature3_mc.addEventListener(MouseEvent.ROLL_OVER, over);
menu_mc.feature3_mc.addEventListener(MouseEvent.MOUSE_OUT, out);
menu_mc.feature3_mc.addEventListener(MouseEvent.MOUSE_UP, clicked);
menu_mc.feature4_mc.addEventListener(MouseEvent.ROLL_OVER, over);
menu_mc.feature4_mc.addEventListener(MouseEvent.MOUSE_OUT, out);
menu_mc.feature4_mc.addEventListener(MouseEvent.MOUSE_UP, clicked);

function menuItemSelect(selectNum:Number)
{

}
}

 

LoaderMax brings in DisplayContent, but I don't know how to access it's depth. When I try getDepth it says GreenSock doesn't understand.

 

ReferenceError: Error #1069: Property getDepth not found on com.greensock.loading.display.ContentDisplay and there is no default value.
at Function/()

 

Which is fine, so I have to convert it to a MovieClip of some kind?

 

Not sure what I'm left to do to flip the image upon button event.

 

Know what I mean? :)

Link to comment
Share on other sites

a few things.

 

getDepth() and .depth are not part of AS3 of LoaderMax.

 

managing the stacking order of objects in AS3 is a bit different than as2 but far better.

 

if _aImages[0] actually does reference a ContentDisplay or any DisplayObject there are a few things you can try test

 

addChild(_aImages[0]) //this should put the image on the top of everything else.

this assumes your images are not in some other container. you didn't show what you are putting in your array or how you are adding your items to the DisplayList so I have no idea where they are or how to target them. by chance if you loaded them all into a parent clip you would do:

 

imagesHolder_mc.addChild(someInstance) to move someInstance to the top.

 

to figure out the depth of a clip you would use getIndex()

 

 

check

http://help.adobe.com/en_US/FlashPlatfo ... #addChild()

 

and read about every method that uses the word Child or Index.

 

I think you have a good idea about how these things work, but you need to figure out where the images/ContentDisplay objects are before you can move them around.

 

try

 

trace(getIndex(_aImages[0])) somewhere in your code after the images load.

 

if you can get addChild and getIndex to work, then you should be able to test

 

swapChildren(someImage, anotherImage)

Link to comment
Share on other sites

Ohhhhhhkay okay,

 

addChild(_aImages[0]) //this should put the image on the top of everything else.

this assumes your images are not in some other container. you didn't show what you are putting in your array or how you are adding your items to the DisplayList so I have no idea where they are or how to target them. by chance if you loaded them all into a parent clip you would do:

 

imagesHolder_mc.addChild(someInstance) to move someInstance to the top.

 

to figure out the depth of a clip you would use getIndex()

 

So, I think I'm getting it more now. Yes, you're absolutely right. depth commands aren't in the ContentDisplay properties model. If this wasn't so esoteric I'd just search online. :lol:

 

Before I had this:

 

queue.append( iLoader = new ImageLoader("_images/"+xml.feature[i].@url, {
												name:xml.feature[i].@name,
									  			container:container_mc										  			
											  }) 
					 );
// array image by name
_aImages.push(iLoader.content);

 

Which loaded them into the container_mc, but they're not instanced on the stage as "depthable" (let's say) until I write something like container_mc.addChild(_aImages) in a loop or something. Right?

 

Cuz I thought that somewhere in the fancifulness of the loader that it added them to the stage without my knowing. That's where I'm off-base huh? I just need to addChild().

 

If I'm getting this right, I should have this down shortly. I'll give it a shot. Thanks a bunch Carl. Without all the help from all you guys, I'd never get this thing built. :lol: It's just that I understand that it's hard to help people sometimes because what is "obvious" can vary quite extensively.

 

EDIT:

I think you have a good idea about how these things work, but you need to figure out where the images/ContentDisplay objects are before you can move them around.

 

Yes, you're right on the money. However, I can't get getIndex(_aImages[0]), getChildIndex(_aImages[0]), or indexOf(_aImages[0]) to work.

 

I also tried them inversely as well because it gave parenting issues and all I can get trace(container_mc.getIndexOf()); but the rest gives me errors:

 

trace(container_mc);

for (var q:Number =0; q<4; q++)
{
	container_mc.addChild(_aImages[q]);
	trace(getChildIndex(_aImages[q]));   //ArgumentError: Error #2025: The supplied DisplayObject must be a child of the caller.
	trace(indexOf(_aImages[q])); //Error #1180: Call to a possibly undefined method indexOf.
               trace(_aImages[q].indexOf());   //Error #1069: Property indexOf not found on com.greensock.loading.display.
}

 

This ContentDisplay just won't budge into being a stage object with a depth. Grrr. I guess I'll keep plugging away. I just don't know what I can find online as demo info. I can get an MC to show up easily. I feel like this shouldn't be so difficult, you know?

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...