AFQ (Another Flash Question)
- Started
- Last post
- 20 Responses
- SteveJobs
not about the Gordon variety mind you...
ok, riddle me this...
there's this process i have of importing a png file into my library, dropping it into an mc, then dropping that mc into another mc and finally dropping that mc into yet another giving me somewhat of a 3 level deep object. this procedure allows me to 'see' this png file via any of the movieclips...
(don't ask)
now, my question is, how do i do this action via actionscript? maybe this is something simple i'm completely overlooking but i can't figure it out...
thanks!
- SteveJobs0
also, to further elaborate, if the first mc i created was called mc1, the second mc2 and the third mc3 then i could use the following syntax:
mc3.mc2.mc1._property
or
mc3.mc2._property
or
mc3._propertymaybe this makes more sense?
anyway, i need to create this structure at runtime.
- lvl_130
it seems as if you could either call _parent._parent._parent or you could just call your _root.instancename.instancename...
right?
- Solid0
The first movie clip (mc1) - the one that holds the .png - needs to be created manually within flash.
Then with actionscript you can use the
createEmptyMovieClip()
function to create mc2 and mc3. Then use attachMovie to attach mc1 to mc2.
- SteveJobs0
right, but how do i create that relationship at runtime?
all i will have is an image i've loaded using loadClip at loadtime, then i need three mc's that can be referenced as
mc3.mc2.mc1 where mc1 is the root mc which contains the loaded image.
- SteveJobs0
Solid, that makes sense, and i guess i could use a jpeg to load even the image into an mc created at runtime using createEmptyMovieClip, and then atttach the other 2 mc's after?
- Solid0
Check this out:
http://pastebin.coconut.se/?id=4…
- Solid0
Did that work?
- SteveJobs0
not yet. i think i'm not doing this right. still workin at it...
btw, thanks for your help!
- SteveJobs0
i think what's tripping me up is when i call attach movie at the end (assuming i have my mc w/loaded png in library), i don't know the correct arguments...
mc2.attMov(a,b,c);
a=mc in library
b=?
c=_root.getNextHighestDepth
- SteveJobs0
guess just an arbitrary name?
- Solid0
yes - 'b' can be any name you choose - make sure to put quotes around it as it should be a String.
- Solid0
btw 'b' also needs to be a unique name so that doesn't conflict with other mc's
- SteveJobs0
ok, i got it now... thanks for your help!
- Solid0
Glad everything worked out ;)
- Solid0
One more thing - in your example you have:
mc2.attMov(a,b,c);
a=mc in library
b=?
c=_root.getNextHighestDepthYou should use:
c=mc2.getNextHighestDepth
to avoid potential probs down the road.
- SteveJobs0
hmmm, thought it was working, but it's not....
just one last question if you're still around:
dup=_root.attachMovie("mc","mc...
dup.mc._x=100;
dup.mc._y=100;this code works. 'mc' is a movieclip in the library. i picked this code up somewhere, but never found any mention of it in the flash help regarding the dup.mc._property notation.
is this only available through attach movie? what if my movieclip isn't stored in the library? attachMovie can only access mc's from the library, correct?it's late and i'm tired... should probably wait until tomorrow to tackle this one... :(
- SteveJobs0
hey, here's a good example of my question:
http://livedocs.macromedia.com/f…
read nanodusts entry:
"the problem w/ attachmovie is that one must have a link identifier (in linkage panel) in order to attach it. there is no way (that i know of) to attach a *dynamically* created clip - either by duplicateMovieClip or createEmptyMovieClip. and there is no way to move a movieclip around the timeline by assignment, as far as i can tell."
is this still true? anyone? anyone? beuller? beuller?
- Solid0
Take a look here:
http://pastebin.coconut.se/?id=4…
- Solid0
Also, did you
1/ did you check "Export for Actionscript" and
2/ "Export in First Frame"
for the movieclip you wish to attach in the library?
FYI right-click on the movieclip in the library and select "Linkage"
- SteveJobs0
the code i posted worked and i realize why now:
dup = _root.attachMovie("mc", "mc"+1, depth);
dup.mc._x=100;
dup.mc._y=100;attachMovie is actually putting an instance of "mc" inside the new moveclip, "dup".
that is why you can reference "mc" properties like _x and _y using dup.mc._x
this may or may not have been the intent of macromedia, but i found the code, it worked and i'm just assuming as i found no documentation on this 'feature'.
anyway, i finally solved the problem by creating a 3-level heirarchy and then creating a duplicate of the grandparent and using dup.parent.child._property notation to get the desired effect.
lovely, eh?
anyway, thanks for your help Solid. coding at 2:30am obviously isn't as easy w/out a few cans of RedBull. :D
goodnight!