Set mc._x property value from an array

FLASH

    Next

  • 1. loadmovie with swf and jpeg
    Hi, i have a problem with a loadmovie : this.pinceau.loadMovie("suzuki/vol1.swf"); ------------> Work this.pinceau.loadMovie("suzuki/image3.jpeg"); ------------> Don't Work I saw nothing in the forum, can someone explain me why it's not working with jpeg image? Thanx
  • 2. A COMPONENT WITHIN A COMPONENT? ?4 A FLASH GOD
    Hi! ok close. no..i want when you press button 1 to load movie1.swf INTO the Movieclip_1 that the accordion component calls from the Main Timeline. im afraid i am not making myself clear. lemme try again. the scrollpane component lies WITHIN Movieclip_1 on frame 1 . Again, Movieclip_1 is called by the Accordion Component on the Main Frame. SO when i want to edit Movieclip_1, i have to edit it from the library (with me so far?) The scroll component (which lies INSIDE of Movieclip_1 on frame 1) calls a movieclip Scrollbuttons_mc. Scrollbuttons_mc contains 6 buttons. ALSO if i have to edit Scrollbuttons_mc i have to do it from the library. Each of these buttons is assigned and LoadMovie Action. to load up an external movie. lets say...Movie1.swf NOW...what i need is for Movie1.swf to load INSIDE of Movieclip_1 on ITS timeline and NOT the main timline in which the accordion component lies So that when the accordion component is previewed, the movie DOES NOT load in the mainframe where the accordion lies, but rather inside of Movieclip_1 THANKS SOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOO MUCH FOR THIS. if you can figure this out you are flash GOD!
  • 3. Launch a pdf file using getURL
    Within my flash movie I have a button that launches a pdf file through the browser using getURL . It works great on a Mac but on a PC the pdf is launched within the same browser window as my swf. How do I get it to launch in a new window or automatically launch Acrobat Reader.
  • 4. How to turn 1000000 into 1.000.000?
    Im creating a swf where users enter some numbers to be processed in a formula, but the results always show huge numbers like 168460123184, making them hard to read, so I want to find a way to add a "." (a dot) every 3 numbers, so they would be easier to read... and I dont have a clue of how that can be done :( thanks! PS: I chose to use dots instead of commas cos here in Brazil we use dots to separate hundreds from thousands and so on....

Set mc._x property value from an array

Postby Jason McIver » Mon, 26 Sep 2005 09:32:58 GMT

Im trying to import x and y points from a external file ("getDevices.txt") and 
use them to position a new MovieClip from the library in a loop.
 I know I could be using _root.attachMovie("box", "box_mc"+i, 110+i, 
{x:something, y:something});
 I've just been playing with this all day and tried many different methods, but 
still no luck. I think my problem may be in the setup of the array and not how 
its presented to _root["box_mc"+i]._y
 Because if I create a new array like ypos = new Array(20, 40); it worked

 The Actionscript code (Cant seem to find any tags, so I just used Quote)
 //get devices and loop through
 var mydevices:LoadVars = new LoadVars();
 mydevices.load("getDevices.txt");
 var ypos = [];
 mydevices.onLoad = function() {
         for (i=0; i<2; i++) {
                 //ypos = new Array([this["y"+i]]); //How is this different as 
oppose to the next line?
                 ypos.push([this["y"+i]]);
                 trace(ypos);
                 _root.attachMovie("box", "box_mc"+i, 110+i);
                 _root["box_mc"+i]._y = (ypos);
         }
 };

 I get the values 400 and 200 in the output screen, but need help assinging 
them to the objects x and y position.

 This is the contents of the text file

  &NumofDevices=5&animal0=cow&y0=400&x0=-50&animal1=horse&y1=200&x1=300
 Any ideas? where are the AS tags in these forums?
 -Jason.:confused;


Re: Set mc._x property value from an array

Postby NSurveyor » Mon, 26 Sep 2005 10:04:40 GMT

Try this:



 //get devices and loop through
 var mydevices:LoadVars = new LoadVars();
 mydevices.onLoad = function() {
         for (i=0; i<2; i++) {
                 var x = parseFloat(this["x+i]);
                 var y = parseFloat(this["y+i]);
                 _root.attachMovie("box", "box_mc"+i, 110+i,{_x:x,_y:y);
         }
 };
 mydevices.load("getDevices.txt");


Re: Set mc._x property value from an array

Postby Jason McIver » Mon, 26 Sep 2005 10:22:21 GMT

Thanks Mate that worked! I had clean it up a bit, here is the working code if 
anyone else wants it.

 for (i=0; i<4; i++) {
 	var x = parseFloat(this["x"+i]);
         var y = parseFloat(this["y"+i]);
         _root.attachMovie("box", "box_mc"+i, 110+i, {_x:x,_y:y});
 	}
 Ill have to look at what "parseFloat" actualy does now.
 -Jason.:cool;


Re: Set mc._x property value from an array

Postby NSurveyor » Mon, 26 Sep 2005 10:35:36 GMT

parseFloat converts a string into a number (can be decimal)

Re: Set mc._x property value from an array

Postby NSurveyor » Mon, 26 Sep 2005 10:35:50 GMT

And you're welcome.

Similar Threads:

1.Troubles with tweens after changing mc._x property

2.Setting _x and _y properties on a loaded Movie

Title says it all. How can i set _x and _y properties to a loadedMovie? 

Thanks for helping.

3.Setting and remembering _x _y of MC

So, Im able to store the x, y position of a dragable mc in a var but how do I 
set the position of XMc when a user goes back to that screen? I need XMc to 
remember where it last was(I have that) and go there when you enter frame(I 
dont have that).




 XMc.onPress = function() {
 	XMc.startDrag("");
 	XMc.gotoAndStop(2);
 };
 XMc.onRelease = function() {
 	XMc.stopDrag();
 	XMc.gotoAndStop(1);
 	myX = _xmouse;
 	myY = _ymouse;
 	XmyXY = String(myX)+","+String(myY);
 	trace (XmyXY);
 };

4.setting default property value in custom componenty

I'm trying to build a custom component using Flash MX 2004. basically it's an 
enhanced version of the label component. Everything seems to work fine except 
when trying to set default text or assigning a text value  in the "properties" 
window (the field displays in the properties window, but any value typed into 
it does not appear during movie playback). Currently, the text can be seen only 
in authoring mode, not when the movie plays. The only way for the text to 
displayed during playback is to set it up through code. Does anybody know what 
I'm doing wrong? .as file content follows.

 class CustomComponents.FormFields.lblFieldLabel extends MovieClip {
   private var objFieldLabel:MovieClip;
   private var strText:String = "";

   
     function lblFieldLabel() {
 	    init();
     }

 	
 	public function init():Void {
 		
 	}
 	

 	public function get displaytext():String {
 	    return strText;
 	}
     
 	public function set displaytext(val:String):Void { 
 	    strText = val; 
             objFieldLabel.text = strText + ":";
 	}
 		

 }

5._x & _y of mc relative to stage and not parent mc

Good Morning all,

 I?m trying to get the _x and _y of a movieclip relative to the stage where 
said movieclip is nested inside several others, which have been dynamically 
rotated. 

 I?m hoping there is an easy way to get this rather then taking the route of 
reverse engineering the position and rotation of each parent movieclip in order 
to calculate it.

 Thanks in advance

 Will 


6. Controlling an mc timeline with a mc._x

7. change mc's rgb values using array?

8. Setting values in an array



Return to FLASH

 

Who is online

Users browsing this forum: No registered users and 61 guest