Create New Object With Dynamic Path Name
I am trying to parse a xml doct which is an unknown number of levels deep, to create an Object.
As I recursively parse each element, if it hasChildNodes, I add the element to an array, named 'elementStack'. As I create each sub-object, I need to put it in the correct place, something like:
_root.course[elementStack.join(".")] = new Section(id, title, rolloverHintText, durationMinutes);
Sadly, however, this does not work. Neither does
elementStack.join("][")
The result I'm after is either:
_root.course["m1"]["m1s2"] = new Section... or _root.course.m1.m1s2 = new Section...
Urm, do I need 'eval' - tried that too, to no avail.
Please help... many thanks in advance
Nik
FlashKit > Flash Help > Flash ActionScript
Posted on: 07-06-2001, 07:02 AM
View Complete Forum Thread with Replies
See Related Forum Messages: Follow the Links Below to View Complete Thread
Move Object Along DYNAMIC Elliptical Path
I'm working on a flash version of Grand Theft Auto. I got a level laid out that you can drive across and where you can encounter AI. The AI works in the sense that it is able to make decisions at intersections. I also get the AI to move at their own speed BUT with the displaying of turning at intersections arises a problem.
The ai needs to calculate its own path from start of the turn to the end, taking into account its starting direction and the direction to end at. I thought about solving this by simplifying the turn to a quarter-circle but then the code wouldn't work for intersection with roads at an arbitrary direction.
so the AI basically needs to calculate the path from A to B with the code supporting any direction of road A and B.
Perhaps an elliptical path could provide the solution but I haven't found a way to calculate the direction of such a path at any one position.
any ideas? thanks
Create The Text Field With Relative Path
If I load txt a want to create text field and the assign the loaded vars to my txt field.
I can create the text field with absolute path _root.createTextField , but I would like to create this with relative path, how can I make it?
Now it works so:
Code:
//*********** LOAD VARIABLES ****************
myVars = new LoadVars ();
myVars.onLoad = function (success)
{
if (success)
{
trace ("variables from txt file loaded FRAME 3!");
// create text for menu ABSOLUTE PATH
_root.createTextField ("menu1_txt", getNextHighestDepth (), 17, 15, 90, 18);
//
menu1_txt.text = this.var_menu1;
menu1_txt.border = true;
menu1_txt.selectable = false;
menu1_txt.setTextFormat (myTF_fmt);
menu2_txt.text = this.var_menu2;
menu3_txt.text = this.var_menu3;
menu4_txt.text = this.var_menu4;
menu5_txt.text = this.var_menu5;
menu6_txt.text = this.var_menu6;
menu7_txt.text = this.var_menu7;
menu8_txt.text = this.var_menu8;
menu9_txt.text = this.var_menu9;
}
Create The Text Field With Relative Path
If I load txt a want to create text field and the assign the loaded vars to my txt field.
I can create the text field with absolute path _root.createTextField , but I would like to create this with relative path, how can I make it?
Now it works so:
Code:
//*********** LOAD VARIABLES ****************
myVars = new LoadVars ();
myVars.onLoad = function (success)
{
if (success)
{
trace ("variables from txt file loaded FRAME 3!");
// create text for menu ABSOLUTE PATH
_root.createTextField ("menu1_txt", getNextHighestDepth (), 17, 15, 90, 18);
//
menu1_txt.text = this.var_menu1;
menu1_txt.border = true;
menu1_txt.selectable = false;
menu1_txt.setTextFormat (myTF_fmt);
menu2_txt.text = this.var_menu2;
menu3_txt.text = this.var_menu3;
menu4_txt.text = this.var_menu4;
menu5_txt.text = this.var_menu5;
menu6_txt.text = this.var_menu6;
menu7_txt.text = this.var_menu7;
menu8_txt.text = this.var_menu8;
menu9_txt.text = this.var_menu9;
}
Create A Fading Trail Along A Motion Path?
Hi
Does anyone know how to create an effect where you can create the effect of a trailing line along a path.
For example say i wanted a particle orbiting a sphere. As the particle(s) move along motion paths, they leave a fading trail which is weaker in alpha further away from the particle.
This effect can be seen in action in the 2advanced intro animation for logic design
Object Path
I am trying to get at an object regardless of how deep it is in a Movie.
Code:
focus = new Object();
focus.onSetFocus = function (oldfocus, newfocus){
TT = [new_focus + "TT"];
TT.displayToolTip();
}
I am trying to display a tooltip when the focus is put inside of a text field. It doesn't work when I add the "TT" to the end of the name. I am pretty sure that it is a String and that is why I can't access an object by that name. Any ideas?
Path To Object
dear there is a problem with me..
i made a flash file...
on the main stage a clip named "one " and in this clip one more clip named "two" and in this clip i have an instance name pic and i want to make it invisible at any time but i didt not get path to that instance.
thanx if u guide me..
innocent 4 nu
Help With Object Following A Path
arrite i checked kirupa tuts and its not there so i want to noe how du u get an object to follow a path using the guide layer....
i read tuts in 2 books but didnt understand..
maybe u guyz coud send me a link or explain how its done....
i am newbie to this
Object Path
Is there a way I could progmatically make a Object that I have written figure out its own path to its self. Or is there anyway I can figure out a Objects current location with-in a movie clip? This would really be great! Thanks a head of time.
Object Path Help?
Is it possible to have a object path changed due to the value of a variable?
eg.?
Code:
ClipNumber = 10
_root.ClipMC.[ClipNumber].Stuff = "This is stuff"
What Im asking is, can a value in a path be equal to that of a variable?
Is so, how?
Help With Object Following A Path
arrite i checked kirupa tuts and its not there so i want to noe how du u get an object to follow a path using the guide layer....
i read tuts in 2 books but didnt understand..
maybe u guyz coud send me a link or explain how its done....
i am newbie to this
Object Path
Is there a way I could progmatically make a Object that I have written figure out its own path to its self. Or is there anyway I can figure out a Objects current location with-in a movie clip? This would really be great! Thanks a head of time.
How To Create A Relative Path For Flash Video On A CDROM
Hello - I need to distribute a web site to a client on a cross-platform Hybrid CDROM so that they can edit and make adjustments. This website also includes 2 flash videos that need to be included on the CDROM.
My problem is this: I encoded the video in the Flash Encoder app and brought them into the main Flash app for conversion into swf files. I also used the media controller parameter to add a control skin to the movies. I now have 2 swf files associated with the flv video file, and I understand that all 3 of these must stay together for the video to work properly. The video plays correctly along with the controller skin on my Mac however only the controller shows up but no video on the CDROM. I believe that this has something to do with absolute vs. relative file paths for the video flv file to the swf controller file.
I do not know how to change this path - I know "where" to change it within the controller parameter options box but do not know what syntax exactly to place here. How do you specify a relative path here? When I try to do it I get an error saying that the flv file cannot be found.
I am trying to use the following syntax: /video/welding.flv where video is the name of the folder and welding is the name of the file. I have done numerous Google searches on this subject and stil cannot find an answer, so any help is appreciated.
Create Object Within Object, Dynamically?
Howdy,
I'm creating a firework show. The main timeline creates rocket objects nicely. When it's time for the rocket to explode, creating projectiles in the Rocket object in the same way as the main timeline, it does NOT work dynamically. I can only seem to get it to work in a static way. Here are some examples:
main timeline (works great!):
Code:
this["rocket" + rocketInt] = new Rocket();
this["rocket" + rocketInt].name = "rocket" + rocketInt;
addChild(this["rocket" + rocketInt]);
rocketInt++;
in Rocket (does not work):
Error: ReferenceError: Error #1056: Cannot create property projectile0 on xx.xx.fireworks.Rocket. This error occurs even if all but the first line is commented out.
Code:
this["projectile" + _projectileInt] = new Projectile();
this["projectile" + _projectileInt].name = "projectile" + _projectileInt;
addChild(this["projectile" + _projectileInt]);
_projectileInt++;
in Rocket statically (works, but no fun):
Code:
var projectile0:Sprite = new Projectile();
projectile0.name = "projectile0";
addChild(projectile0);
The last example does exactly what I need it to... but The number of projectiles could be anywhere from 1 to 50. I'd hate to do all that in a non-dynamic way.
Is there any hope?
Thank you much for the assist.
Drag An Object On A Path?
I made a button. Put the button in a movie clip. Now i want to attach the movie clip to a swirly path. Then i want to make it so it is draggable. I'm not sure how to do this. Can someone please offer some assistance.
Thanks in advance!
Flash MX - Object Following A Path
Hi all
Has anyone any examples of a movieclip object that follows a path on screen?
Say I have drawn an 'S' or similar line shape, I now want an arrowhead object to follow the path. I'd then like to be able to change the speed of the arrowhead so it has difficulty in following the path accurately. I'd like to use the example to make a car go around a corner along a path for multi-lane traffic.
Thanks for any help and advice.
Controlling Object On Path
hi,
I currently have an object/character but I need to make it move along a particular path using on key (up, down, left, right).
Now thing is it has to be a path that can be easily adjusted or moved. So using a line or a physical path (instead of coding coordinates) would probably be my best bet.
This problem has been bothering me for a bit. Does anyone have a good solution or ever had to accomplish the same sort of thing?
Thanks.
Dragging An Object Along A Path
i am trying to create a flash executable which is similar to a circular slide rule. there are three wheels of different diameters. the middle one doesn't move. the two outside ones do. i want to be able to allow users to drag the two outside wheels (along a circular path). the idea is something like this (http://www.hpmuseum.org/loga.jpg).
how difficult is this to do? i'm a low-to-medium level user of actionscript...
thanks.
jim
Shared Object Path
Hi,
I am having trouble controlling the placement of my shared object files and was hoping that someone could point out where I going wrong!?
The location that my files are ending up at is:
C:Documents and Settings<user>Application DataMacromediaFlash Player#SharedObjectsBMCK8GF8localhost#SmartLea rning
And the code I am using is:
// Set name of file to be saved
User = "LiteracyKS3Users";
// Set path where file to be stored
var my_so = SharedObject.getLocal("SmartLearning/LiteracyKS3/Users/"+User, "/");
// List data to be stored
my_so.data.savedNameArray = userNameArray;
my_so.data.savedIDArray = userIDArray;
my_so.data.savedIDcnt = userIDcnt;
// Save data and remove local info
my_so.flush();
delete my_so;
I have a few questions:
1. How do I get my SmartLearning folder to be located in the FlashPlayer folder?
2. Why does my SmartLearning folder have a # added?
3. Why is '#SharedObjectsBMCK8GF8localhost' added when I don't specify it?
I hope someone can help?!
Many thanks in advance
Ol
[F8] Dragging An Object On A Path
Ok I have tried this a lot of ways and I can't seem to get it to work. I need to be able to limit a dragged object to a path. All I need is to be able to drag an object like a slider back and forth horizontally. I am using it for a game there will be four points on that slider and when the object hits one of those points it does different things.
Object Path To String
Hi all,
I've been looking for a nifty function to convert the path of an Object to a String, but with no luck.
Example:
items.item[2].name //Object type
to...
"items.item[2].name" //String type
Anyone seen one?
Thanks
Nick
Dragging An Object On A Path
Hi,
i was wondering if it was possible to drag an object on a curve.
Maybe on a sinusoidal one.
I was using startDrag().
But then I created a mc with a "timeline engine" (3 frames, one with the init condition, the second with the thing to do every time, and the third one that is a looper to the second frame).
I was seeing also that many people are doing this with listeners.
Do I have to go this way?
thanks
Finding Path Of Object
Hi,
Let's say i got this piece of coded within some nested functions
Code:
var loadListener:Object = new Object();
How do i go about finding the path to that object (e.g. in the form _level0.something.something)?
Thanks!
XML Object's Target Path
I'm new to ActionScripting, and I'm stuck.
I have an XML object which is created inside a method of a class. When the XML file loads, I would like XML.onLoad to call another member of said class, but I'm not sure how to do so, since onLoad is a method of the XML object, and I don't know how to get the target path of the method which created the XML object.
I hope that makes sense.
here's a sample of the code, which has been simplified a bit:
newGraph = new GraphClass("data.xml");
newGraph.loadXML();
//////////////////
GraphClass = function (datafile) {
this.datafile = datafile;
}
GraphClass.prototype.loadXML = function () {
this.dataFile = new XML();
this.dataFile.onLoad = function (success) {
if (success) {
/******************
here, i would like to call the method GraphClass.prototype.sayHello() from the instance newGraph
but I can't type "this.sayHello()" since "this" is refering to
dataFile, not newGraph
******************/
}
};
this.dataFile.load(this.datafile);
}
GraphClass.prototype.sayHello = function () {
trace("Hello");
}
If someone could tell me how to call sayHello() from the GraphClass instance newGraph, I would be a very very happy little programmer.
thanks in advance for at least trying to decypher my code, I hope it's not too confusing!
Movable Object Following A Path?
Hello, I have a question. I'm not sure flash can even do this. I think it can be done using javascript, but I don't know even less about that. Is there a way to make say, an object that follows a path that can be picked up and resume the path when released? Like a bug that crawls along, that can also be picked up and resume the specified trail when let go. I've had no luck finding an example of this happening in any tutorial. Its always one or the other.
Thanks in advance.
Object Won't Follow Path
Working on Classroom in a Book Flash CS3 Professional (p 77 for those who have it)
I drew a looped path for my rocket to follow, but
my rocket won't follow the path, it just flies from the beginning point to the end point
I checked orient to path, sync and snap
Any ideas?
One Object Following The Mouse AND A Path
Alright, I'm trying to design my very first flash website, to date I've been using a photoshop/imageready and HTML combo and I need something new. So, I bought Flash MX 2004, and thus my question regards AS 2.
My problem is, I want an object to follow a path (like a motion guide) but I want its X position to be determined by the mouses X position. This is to be this way so that no matter where your cursor is (it will be hidden) the object following the path and your mouses X position will be the same. I tried to just make a motion guide and then use the following AS but it did not work.
onClipEvent (enterFrame) {
myRadians = Math.atan2(_root._ymouse-this._y, _root._xmouse-this._x);
myDegrees = Math.round((myRadians*180/Math.PI));
_root.yChange = Math.round(_root._ymouse-this._y);
_root.xChange = Math.round(_root._xmouse-this._x);
_root.xMove = Math.round(_root.xChange/10);
this._x += _root.xMove;
this._rotation = myDegrees+90
Mouse.hide();
}
That is just modified AS from a tutorial I read. It makes the object follow my mouses X position and rotate according to specific degrees (makes it more interesting). The problem is that I need the objects Y value to be a set value along a curved line. And I have no idea how to do this. I was reading something about the path follower class but thats way above my head. So is there an easier way to do this? Or could someone explain how I would go about using the path follower class in such a manner? Thank you, imagiu(s)!
Object Follow Path
Can anyone help me to figure out how to make an object follow a path. For instance - I want to make a square move on the path of a circle. Thank you.
Drag Object Along The VA Path
Hi,
I'd like to have some graphic object which is possible to drag along the VA path.
I've tried something to do but no success. The path is a random up-down hills.
Exactly like the Motion guide does it.
Maybe some solution: put some object on the motion guide, create some possition
sniffer, apply position to the drag-object.... but there's the problem how to obtain
the direction of the drag... even when I use Beziere curve, the right direction still persists...
Any idea ? thx
Path Of A Display Object
I'll start with an AS2 analogy. In as2, a trace of an object will display not only its name, but also its absolute path from _root. Is there an equivalence in as3? I have tried describeType, and getQualifiedClassName. It's really helpful to know where you are when adding and removing child.
Darg Object On The Path
i want creat dragable object that move on the path that no a H line or V line
4example : a arc path volume
thanks
AI Graphics Imported Into Flash Create Clip Path Folders
AI graphics imported into Flash create folders named "Clip Paths" and parts of the graphics are contained in this as symbols. Can anyone tell me what is happening here and how to import graphics from AI that can the be broken apart and animated in Flash?
HELP Need To Retrieve Absolute Path To An Object...
Hello all
I need to retrieve a string with the absolute path to an object.
Lets say i have an instance
myObj = new Object();
then, i want to know the absolute path to myObj...
how can I do that?
I need a string with the absolute path (i.e. "_level2.myObj") to pass it to a host application with FSCommand, but I canīt find a way....
please heeeeeeeeeeelp!!!!!!
Using A Movie Name As Part Of An Object Name(?) Path(?)...huh?
I am trying to use a movie name as part of an object name(?) path(?) so i can use a different line from a text file in each of several instances of this movie.
right now i'm using this in a movie on the main timeline and it works but i have to use a different movie for each "record" in the text file but this works:
// var res1 == 1|1|OPEN|1|A|Size:125x125|Cost: $199,999|
// which comes from a text file and was
// previously used in the "root" timeline
lotInfo = new array ();
lotInfo = _parent.res1.split("|");
selectedLot = "Lot "+lotInfo[0];
selectedPlan = "Plan "+lotInfo[1];
etc. etc.
I am going to be using several instances of this movie and was hoping to use the names of the instances (res1, res2, res3 etc.) to call different lines from the text file.
something like this (except this doesn't work)
movieName = _name;
//which does trace res1 like it should
lotInfo = new array ();
lotInfo = _parent.movieName.split("|");
//this is the line where i don't know what i'm doing
selectedLot = "Lot "+lotInfo[0];
selectedPlan = "Plan "+lotInfo[1];
etc. etc.
no matter how i try to insert the "_name" variable into the
lotInfo = _parent.movieName.split("|");
line, the array comes back undefined. Is what i'm trying to do possible? Big thanks for takin a look at this and biiger thanks if you have any ideas.
Orienting A Draggable Object To A Path
I have a minor problem, I need to orient an object to a drag path. for instance I have a imagae that is focused on a central point and would like to to drag it around a circle whilst always focussing in on the center of the circle. Is there any way to do this.
Thanks in advance for any help
Making An Object Follow A Particular Path
Hey everyone
Does anyone know how to making an object in a movie follow a particular path?
Heres what im trying to do,
I have to globes and I want a spark to orbit round the globes, activly following the lines that i set out
is there anyway i can make this happen?
Projector: Shared Object Path On PC
Hi,
I am a Mac guy and have created a projector file containing a shred object. I know where it is on Mac. I have searched threads here to see if I can get information how it is stored on a PC. However, that did not help, since the folders indicated like C:WINDOWSApplication Data.... did not exist. The shared object is definitely stored but I did searches for names of files etc and I can't find it. PCs are like black boxes for me.
Thanks for any help.
How Can I Find The Full Path Of An Object?
My goal is to give an object a property whose identifier is the fully qualified path of another object, but I can't find any way to do that for anything but movieclips.
Anyone know how to do this? I considered writing something like this:
function getPath (target):String {
if (target == _root) {
return String(target);
} else {
return getPath(target._parent)+"."+String(target);
}
}
But I'm not certain if object references like that will convert to strings like I want them to.
Another question I had on the side was how do I reference objects whose paths I have in string form?
Anybody Know How To Make An Object Follow Set Path?
i think the title speaks for itself, im sure its really simple but there are no tutorials on it that i found and flash help is no.. help..
all i want is my MC to follow a path...
thanks a billion
imitator
Any Way To Make An Object Drag To A Path?
I have searched and searched for a way to do this, with no luck. I want to build an interactive gearshift/lever object, which would move along a path shaped like so:
Code:
| | |
| | |
-----------------
At the top of each vertical section would be a menu option, and the lever would move up and down the verticals and across the horizontal.
I know that startDrag() can only constrain to rectangles. I did find one script on Actionscript.org that constrained a draggable button to a curve, but it was extremely complicated algebra and geometry and I didn't understand the code at all.
The only idea I had was this:
1. Start the gearshift at the top left
2. If the gearshift is moved to the intersection of the left vertical and the horizontal, call stopDrag() on the vertical constraint and do a startDrag() with a horizontal constraint.
3. When the gearshift gets to the middle vertical, call stopDrag() and do a startDrag() with another vertical constraint.
4. Repeat ad infitum
The problems are - I couldn't figure out how to code this, and it forces the user to use the lever in a specific order, which breaks the concept. Is there any way to do this at all? Maybe using duplicateMovie or something like that? Thanks very much for your help.
[F8]Path Independant Object Referencing
Is it possible to reference objects in flash independent of their path. I am using flash as an interface for an external system. The external system used channel messages (1-10000) that I wish to tie to buttons. The buttons may exist on any form within a movie so connecting each incoming channel message the appropriate button in code will be very time consuming. If I could just address the appropriate button via it alias irrespective of its path then I could simply alias my buttons B1 - B10000 and use a simple function to connect the channel message to the button. Any suggestions?
Thanks in Advance
Append Path To Object Using Variable
I would like to do something like this
for ($i = 0, $i < 10, $i++){
_root.object1.object($i).text = "object"+$i;
}
And this would allow me to modify 10 text objects on the stage and insert the text object1, object2, object3, etc.
The part i don't know how to do is in bold and itallics.
Thanks Guys!
Drag Object Along Custom Path
Hey there everyone! I easily did a tutorial on draggable objects with targets and everything, but things just got a bit complicated. For my purposes, I need a "gearshifter". So that means I need a draggable object, which is on a custom path. If anyone has any code that could do that, or has any idea how to do it (or even if it's possible), then please post. Help greatly appreciated.
Thanks everyone!
Using Path Class: Move Object To 50%?
Yesterday I asked how to find the midpoint of a curved line and I was pointed to the excellent Path class:
http://www.kirupa.com/forum/showthread.php?t=224668
But I'm still stumped. I can trace the current location of an object to see that it's x percent of the way through the line, but I want to calculate in the other direction. I want to be able to say "put this object at 50% and put this other object at 75%".
I'm sure this is possible, but I'm not understanding how in the docs. Anyone have experience with this?
Thanks,
Jon
Drag An Object Along The Elliptical Path
Hi
I want to drag an object along elliptical path.
Example :
I am having Sun (Graphic) in the center of the stage, User need to drag the earth(Graphic) around the sun in the elliptical path.
Can any one suggest any way to archive this...
Thank you
Thanigaivel
Navigating An Object Path, Using A Variable
lets say I have a variable like this:
Code:
var pathName = "section2";
Then I have an object called "book". "book" is the parent of other objects named:
section1, section2, section3 and section4.
I want to apply a gotoAndStop() to section2 inside the book object. But instead of typing it the normal way:
Code:
_root.book.section2.gotoAndStop(2);
I want to use the variable pathName for this. Like so:
Code:
_root.book.pathName.gotoAndStop(2);
This is obviously not working, how can I use a variable as part of an object path navigation?
Thanks in advanced I hope someone here can help me !!! cheers
Getting Local Shared Object Path?
Is there any way to actually retrieve the shared object local path. For Example if you had a variable such as var mySO:SharedObject = SharedObject.getLocal("XMLData", "/"); would there be a way to do something like mySO.getPath where it would return something like "C:Documents and Settings[userName]Application DataMacromediaFlash Player#SharedObjectsWKBNWUMElocalhostXMlData.s ol" ??
How Do You Create A Looped 'conveyor Belt' Effect With Objects On A Motion Path?
I am trying to efficiently create the following looped effect: a bunch of shapes constantly following a motion guide (a closed circle). Basically the object could be a conveyor belt or something else.
http://i75.photobucket.com/albums/i302/Cablestein/dfg.jpg
I want to avoid having to do it the old-fashioned way of multiplate layers and symbols. I do not want to see the triangles skip or jitter while moving along either.
Is there an obvious way to do this with action script? Some way to simply start with a single symbol and motion guide, then applying some script (copy-paste).
Edited: 01/19/2007 at 12:03:41 PM by KOunapuu
MX: Retrieve The Absolute Path To An Object Variable...
Hello,
i cannot see a way to obtain a stirng with the absolute path to a variable...
If i go like:
myObj = new Object();
myObj.myVar = "Hello";
then, i would like to retrieve the full absolute path to the variable myVar. I know I could simply type "_root.myObj.myVar" But I am building a Class which must find the absolute path by itself....
And it must be a string because i have to send it to a host application via a FSCommand.
If i go with "myObj.toString()" I only get the datatype of the object...
For a MovieClip itīs ok to use the "myMovieClip._target"
but i cannot find anything similar for an Object or a variable....
Got any idea?
thanks
Pippo
|