Home Tutorials Forums Articles Blogs Movies Library Employment Press Buy templates

Go Back   ActionScript.org Forums > ActionScript Forums Group > ActionScript 2.0

Reply
 
Thread Tools Rate Thread Display Modes
Old 12-18-2007, 03:46 PM   #1
cangeceiro
Registered User
 
Join Date: Oct 2006
Posts: 8
Default how to use depths with dynamic clips

Im currently working on building a revolving image ticker type system with flash. but im having a few issues.

the issue im stumped on is depth swapping in flash. I have a for loop that dynamically creates copies of a movie clip i have in my library based on data pulled from a drupal/amfphp services setup. The clip has 2 text fields, the mx.loader component, and a button. . This being the first time i have worked with depths, im really not sure where to even begin to get this to work right. ideally i want to mouse over one of the instances of the clip and it come to the front.

this is my first time working with remoting and depths, so i could be going about this all wrong.

here is my code.

first frame
Code:
import mx.remoting.*;
import mx.rpc.*;
import mx.utils.Delegate;
import mx.remoting.debug.NetDebug;

var gatewayUrl:String = siteRoot + "/services/amfphp";
var imagePath:String = "files/imagecache/flash_image/";	
var view:Service = new Service(gatewayUrl, null, "views", null, null);

infoTxt.text = "Loading....";

NetDebug.initialize();

getView('flash_feed','onResultSuccess',['title','path','teaser','field_flash_rotation_image']);

function onResultSuccess(re:ResultEvent){
	var oTicker:Object = re.result;
	var xpadding:Number = 400/oTicker.length;
	var z:Number = 0;
	var countDown:Number = oTicker.length;
	var counter = countDown;
	
	for (i = 0; i < oTicker.length; i++) {
		if (i == 0) {
			alphaVal = 100;
		} else {
			alphaVal = 50;
		}
		
		trace("Path:" + oTicker[i].path);
		trace("Counter:" + counter);
		
		imageClip = this.attachMovie('imageClip','image' + i, counter, {
					_x:0,
					_y:0,
					_alpha:alphaVal,
					xpadding:z,
					titleText:oTicker[i].title,
					teaserText:oTicker[i].teaser,
					path:oTicker[i].path,
					imageHolder:siteRoot + imagePath + oTicker[i].field_flash_rotation_image[0].filepath
		});
		imageClip.onEnterFrame = updateClip;
		z=z+xpadding;			
		counter = countDown-1;
	}
}

function getView (viewName:String, handler:String, fields:Array, arg:Array) {
	var pc:PendingCall = view.getView (viewName, fields, arg);
	pc.responder = new RelayResponder (this, handler, "handleRemotingError");
}

function handleRemotingError (fault:FaultEvent):Void {
	NetDebug.trace ({level:"None", message:"Error: " + fault.fault.faultstring});
}

function updateClip() {
	this.titleTxt.text = this.titleText;
	this.teaserTxt.text = this.teaserText;
	this.imageLoader._x = this.xpadding;
	this.gotoBtn._x = this.xpadding;
	this.imageLoader.contentPath = this.imageHolder;
	this.infoLoaded = imageLoader.getBytesLoaded();
	this.infoTotal = imageLoader.getBytesTotal();
	this.percentage = Math.floor(this.infoLoaded/this.infoTotal*100);
    infoTxt.text = percentage+"%";
    if (percentage>=100) {
         delete this.onEnterFrame;
         //infoTxt._visible = false;
    }
}
button in image_clip from library

Code:
on(release) {
	getURL(path);
}

on(rollOver) {
	trace("Rollover start:" + _parent.getDepth());
	titleTxt._visible = true;
	teaserTxt._visible = true;
	trace("Rollover after:" + _parent.getDepth());
}

on(rollOut) {
	trace("Rollout start:" + _parent.getDepth());
	titleTxt._visible = false;
	teaserTxt._visible = false;
	trace("Rollout after:" + _parent.getDepth());
}
cangeceiro is offline   Reply With Quote
Old 12-18-2007, 04:26 PM   #2
xxneon
MCL -- FTW
 
xxneon's Avatar
 
Join Date: Dec 2006
Location: Amish Country, PA
Posts: 7,175
Send a message via ICQ to xxneon Send a message via AIM to xxneon Send a message via MSN to xxneon Send a message via Skype™ to xxneon
Default

try this in your rollover code..

this.swapDepths(10000);

that will most-likely push that specific clip to the front on rollover..
__________________
Always optimizing...
xxneon is offline   Reply With Quote
Old 12-18-2007, 04:38 PM   #3
cangeceiro
Registered User
 
Join Date: Oct 2006
Posts: 8
Default

Quote:
Originally Posted by xxneon View Post
try this in your rollover code..

this.swapDepths(10000);

that will most-likely push that specific clip to the front on rollover..
nope, this didnt work. the button that has the roll over code is apart of the clip that is being dynamically generated. im not sure if this makes a difference. also worth noting....I tried _parent.swapDepths(10000); as well and the depth for each object originally starts at -16384 and after rolling over the first time it goes to 10000, but all instances stay at that even with roll out code that should be reverting it.
cangeceiro is offline   Reply With Quote
Old 12-18-2007, 04:46 PM   #4
xxneon
MCL -- FTW
 
xxneon's Avatar
 
Join Date: Dec 2006
Location: Amish Country, PA
Posts: 7,175
Send a message via ICQ to xxneon Send a message via AIM to xxneon Send a message via MSN to xxneon Send a message via Skype™ to xxneon
Default

well no two objects can have the same depth .. so you need to make sure your targeting the right movieclip so your swaping the depths right..

if your getting a negative depth .. then your targeting something that was added manually..

your depths for the attached movieclips should be positive.. make if you sent a compressed fla we can see what your doing ..

also when you attach code to button instances like you are .. the buttons scope is its parent .. so if you do a trace(this); inside the on(rollover) it should return the name of the parent movieclip that it resides in..
__________________
Always optimizing...
xxneon is offline   Reply With Quote
Old 12-18-2007, 04:55 PM   #5
cangeceiro
Registered User
 
Join Date: Oct 2006
Posts: 8
Default

Quote:
Originally Posted by xxneon View Post
well no two objects can have the same depth .. so you need to make sure your targeting the right movieclip so your swaping the depths right..

if your getting a negative depth .. then your targeting something that was added manually..

your depths for the attached movieclips should be positive.. make if you sent a compressed fla we can see what your doing ..

also when you attach code to button instances like you are .. the buttons scope is its parent .. so if you do a trace(this); inside the on(rollover) it should return the name of the parent movieclip that it resides in..
AH HA!!!! your explanation of the parent/child relation between clips is what i needed. i had a line on the rollOut that was setting the depth wrong, and i was trying to access the wrong element.
cangeceiro is offline   Reply With Quote
Reply


Thread Tools
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Trouble with dynamic removal of movie clips mordred58 ActionScript 2.0 3 06-01-2006 06:40 PM
Text in MC not displayed when put to Dynamic? SebCH Simple Stuff (Newbies) 4 01-13-2006 04:34 PM
Movie Clips Order Luigi Vercotti ActionScript 1.0 (and below) 2 02-27-2004 11:32 AM
dynamic fading on duplicated movie clips stebennettsjb ActionScript 1.0 (and below) 19 01-05-2004 10:14 PM
removing dynamic movie clips nomaeswonk ActionScript 2.0 3 01-03-2004 06:18 PM


All times are GMT. The time now is 09:01 PM.


Powered by vBulletin® Version 3.8.4
Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.
Ad Management plugin by RedTyger
Copyright 2000-2009 ActionScript.org. All Rights Reserved.
Your use of this site is subject to our Privacy Policy and Terms of Use.