attachMovieClip() issue

  • (2 Pages)
  • +
  • 1
  • 2

15 Replies - 8534 Views - Last Post: 09 March 2007 - 01:24 PM

#1 girasquid  Icon User is offline

  • Barbarbar
  • member icon

Reputation: 108
  • View blog
  • Posts: 1,825
  • Joined: 03-October 06

attachMovieClip() issue

Posted 06 March 2007 - 02:33 PM

I have some code that is supposed to attach 'candleflames' to the main stage every so many seconds. This is the code that I'm using to attach a candleflame:
attachMovie('candle','flame' + candleDepth, candleDepth);	
	trace(this['flame' + candleDepth]._x);
	trace(this['flame' + candleDepth]._y);


However, I need to be able to modify the attached movieclip's _x and _y values; when I trace them, they only appear as "undefined". Does anyone know what might be causing this?

Thanks,
Girasquid

Is This A Good Question/Topic? 0
  • +

Replies To: attachMovieClip() issue

#2 theRemix  Icon User is offline

  • D.I.C Regular

Reputation: 15
  • View blog
  • Posts: 440
  • Joined: 19-October 05

Re: attachMovieClip() issue

Posted 06 March 2007 - 02:53 PM

View Postgirasquid, on 6 Mar, 2007 - 02:33 PM, said:

I have some code that is supposed to attach 'candleflames' to the main stage every so many seconds. This is the code that I'm using to attach a candleflame:
attachMovie('candle','flame' + candleDepth, candleDepth);	
	trace(this['flame' + candleDepth]._x);
	trace(this['flame' + candleDepth]._y);


However, I need to be able to modify the attached movieclip's _x and _y values; when I trace them, they only appear as "undefined". Does anyone know what might be causing this?

Thanks,
Girasquid


when you use attachmovie, there is no way to get/set the loaded movie's values like _x or _y on events.

look up MovieClipLoader class

use that instead.

http://brajeshwar.co...ClipLoader.html

to get you started
Was This Post Helpful? 0
  • +
  • -

#3 girasquid  Icon User is offline

  • Barbarbar
  • member icon

Reputation: 108
  • View blog
  • Posts: 1,825
  • Joined: 03-October 06

Re: attachMovieClip() issue

Posted 06 March 2007 - 03:19 PM

View PosttheRemix, on 6 Mar, 2007 - 02:53 PM, said:

there is no way to get/set the loaded movie's values like _x or _y on events.


I am not setting _x and _y on an event, I am only setting it after I have called attachMovieClip(). The following piece of code works in a different part of the movie:

attachMovie('candle','flame' + candleDepth, candleDepth);
	this['flame' + candleDepth]._x = candleXPosition*40;
	this['flame' + candleDepth]._y = candleYPosition*50;


Was This Post Helpful? 0
  • +
  • -

#4 CyanBlue  Icon User is offline

  • D.I.C Head
  • member icon

Reputation: 6
  • View blog
  • Posts: 156
  • Joined: 01-September 06

Re: attachMovieClip() issue

Posted 06 March 2007 - 03:22 PM

I think I am missing something... If you define the _x and _y of the attached movieClip, it should default to 0 and 0 not undefined... What are you not telling us, girasquid??? ;)
Was This Post Helpful? 0
  • +
  • -

#5 girasquid  Icon User is offline

  • Barbarbar
  • member icon

Reputation: 108
  • View blog
  • Posts: 1,825
  • Joined: 03-October 06

Re: attachMovieClip() issue

Posted 06 March 2007 - 03:28 PM

In the second piece of code, it does do that, but in the first it doesn't. There are no other areas where I fiddle around with the _x or _y, but if you can think of some piece of code I might have missed that you need to see, I'll put it up.
Was This Post Helpful? 0
  • +
  • -

#6 pioSko  Icon User is offline

  • still.dreaming
  • member icon

Reputation: 23
  • View blog
  • Posts: 1,888
  • Joined: 06-June 03

Re: attachMovieClip() issue

Posted 06 March 2007 - 04:10 PM

since you're giving _x and _y positions from a variable, where do you define those candleXPosition and candleYPosition variables??
Was This Post Helpful? 0
  • +
  • -

#7 girasquid  Icon User is offline

  • Barbarbar
  • member icon

Reputation: 108
  • View blog
  • Posts: 1,825
  • Joined: 03-October 06

Re: attachMovieClip() issue

Posted 06 March 2007 - 04:19 PM

View PostpioSko, on 6 Mar, 2007 - 04:10 PM, said:

since you're giving _x and _y positions from a variable, where do you define those candleXPosition and candleYPosition variables??

They're defined in the same frame, outside of any functions.
Was This Post Helpful? 0
  • +
  • -

#8 CyanBlue  Icon User is offline

  • D.I.C Head
  • member icon

Reputation: 6
  • View blog
  • Posts: 156
  • Joined: 01-September 06

Re: attachMovieClip() issue

Posted 07 March 2007 - 07:04 AM

Can you do this and paste the output???
attachMovie('candle', 'flame' + candleDepth, candleDepth);
trace("candleDepth = " + candleDepth);
trace("candleXPosition = " + candleXPosition);
trace("this['flame' + candleDepth]._x = " + this['flame' + candleDepth]._x);
trace("this['flame' + candleDepth]._y = " + this['flame' + candleDepth]._y);
this['flame' + candleDepth]._x = candleXPosition * 40;
this['flame' + candleDepth]._y = candleYPosition * 50;
trace("this['flame' + candleDepth]._x = " + this['flame' + candleDepth]._x);
trace("this['flame' + candleDepth]._y = " + this['flame' + candleDepth]._y);

Was This Post Helpful? 0
  • +
  • -

#9 girasquid  Icon User is offline

  • Barbarbar
  • member icon

Reputation: 108
  • View blog
  • Posts: 1,825
  • Joined: 03-October 06

Re: attachMovieClip() issue

Posted 07 March 2007 - 08:08 AM

Sure, the output is:

candleDepth = 5
candleXPosition = 7
this['flame' + candleDepth]._x = 0
this['flame' + candleDepth]._y = 0
this['flame' + candleDepth]._x = 280
this['flame' + candleDepth]._y = 50
candleDepth = 6
candleXPosition = 0
this['flame' + candleDepth]._x = 0
this['flame' + candleDepth]._y = 0
this['flame' + candleDepth]._x = 0
this['flame' + candleDepth]._y = 250


Was This Post Helpful? 0
  • +
  • -

#10 CyanBlue  Icon User is offline

  • D.I.C Head
  • member icon

Reputation: 6
  • View blog
  • Posts: 156
  • Joined: 01-September 06

Re: attachMovieClip() issue

Posted 07 March 2007 - 09:24 AM

Now I am confused... Where is the undefined???
Was This Post Helpful? 0
  • +
  • -

#11 girasquid  Icon User is offline

  • Barbarbar
  • member icon

Reputation: 108
  • View blog
  • Posts: 1,825
  • Joined: 03-October 06

Re: attachMovieClip() issue

Posted 07 March 2007 - 01:14 PM

View PostCyanBlue, on 7 Mar, 2007 - 09:24 AM, said:

Now I am confused... Where is the undefined???

The undefined shows up on THIS code's _x and _y values:
attachMovie('candle','flame' + candleDepth, candleDepth);	
	trace(this['flame' + candleDepth]._x);
	trace(this['flame' + candleDepth]._y);


This post has been edited by girasquid: 07 March 2007 - 01:14 PM

Was This Post Helpful? 0
  • +
  • -

#12 CyanBlue  Icon User is offline

  • D.I.C Head
  • member icon

Reputation: 6
  • View blog
  • Posts: 156
  • Joined: 01-September 06

Re: attachMovieClip() issue

Posted 07 March 2007 - 01:57 PM

I don't think I understand the whole thing... :(
Was This Post Helpful? 0
  • +
  • -

#13 girasquid  Icon User is offline

  • Barbarbar
  • member icon

Reputation: 108
  • View blog
  • Posts: 1,825
  • Joined: 03-October 06

Re: attachMovieClip() issue

Posted 07 March 2007 - 04:50 PM

View PostCyanBlue, on 7 Mar, 2007 - 01:57 PM, said:

I don't think I understand the whole thing... :(


Yeah, I can't figure it out either. The second piece of code I showed you that uses attachMovie() is the same as the first: I just copied and pasted the line with attachMovie() on it. But it doesn't work for some reason.
Was This Post Helpful? 0
  • +
  • -

#14 red01  Icon User is offline

  • D.I.C Head
  • member icon

Reputation: 12
  • View blog
  • Posts: 204
  • Joined: 08-May 06

Re: attachMovieClip() issue

Posted 07 March 2007 - 05:45 PM

View PosttheRemix, on 6 Mar, 2007 - 02:53 PM, said:

when you use attachmovie, there is no way to get/set the loaded movie's values like _x or _y on events.

look up MovieClipLoader class

use that instead.

http://brajeshwar.co...ClipLoader.html

to get you started


You can set any property on a movieclip as you attach it by using initObject available to attachMovie

eg

attachMovie('candle','flame' + candleDepth, {_x:20, _y:50, _alpha:80})

positions the attached movie at 20,50 with an alpha of 80
Was This Post Helpful? 0
  • +
  • -

#15 CyanBlue  Icon User is offline

  • D.I.C Head
  • member icon

Reputation: 6
  • View blog
  • Posts: 156
  • Joined: 01-September 06

Re: attachMovieClip() issue

Posted 08 March 2007 - 02:22 PM

Why don't you create a sample file that described your problem and upload it somewhere so that we can all save time and effort??? ;)
Was This Post Helpful? 0
  • +
  • -

  • (2 Pages)
  • +
  • 1
  • 2