Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
Discussion GroupsGeneralPHPASPPerlColdFusionFlashHTML, CSS, ScriptsBrowsers

Webmaster Forum / Flash / Flash Actionscript / February 2007



Tip: Looking for answers? Try searching our database.

is this possible?  generic-locate children swf

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
sabin_black - 27 Feb 2007 02:10 GMT
I have several questions about actionscript and everything and anything will
help me out a lot.  Here they are:

From javascript (for questions 1-3)
1) is there a way to iterate through objects in a swf file?  For example, if
the swf has children swfs or some control that I want to target, I want to be
able to iterate through the objects and find that object.  I want to be able to
find children swfs and access the values in the children swfs, and I need this
to be generic so that it will work with any swf out there (with of course a
version requirement).
2) is there any way that I can get information about an object, such as its
name, current rect, etc.  Also if it's like a jpg or a swf, can I get the URL
that it's pointing to?
3) is there a generic way to pass actionscript code into a swf file and tell
it to evaluate it (something like the eval() call in javascript)?  When I say
generic, I mean for every single swf file out there (of course with a version
limit if needed).

Say I have 1.swf file that embeds another 2.swf file (for questions 4-5)
4) From the actionscript in 1.swf, can I iterate through objects in 2.swf?
(this is basically question #1 from a different perspective)
5) From the actionscript in 1.swf, can I get information about objects in
2.swf? (this is basically questions #2 from a different perspective)

6) If you don't know or if it's not possible to do any of the things in 1-5,
do you know any other way to do it, where the only condition is that the input
file is a random swf that a flash developer can make?

Even if you don't know the answer for sure, but you have a guess that  will
still help.  Thanks for reading this post.
kglad - 27 Feb 2007 02:43 GMT
from javascript and from another swf open at the same time by the same user (or
another swf opened at any time by the same user) you can cause actionscript
functions/code to execute.  

with actionscript you can iterate through every object/variable in the swf and
you access to all the methods and properties of objects/variables inherent in
the objects'/variables' class.

you cannot pass code to a swf file and execute that code.
sabin_black - 27 Feb 2007 18:27 GMT
How would I go about doing any of this?  From what I've researched, it seems
like there is no generic way to do this, since the SWF must have explicitly
stated that a function is callable externally.  This would help me out because
this seems like the first sign of hope since I started my project.
kglad - 27 Feb 2007 19:00 GMT
you don't need to know anything about the contents of the swf but you have to
know the swf's file name or you can't access it.  

once you know the file name you can load it into a _level or target movieclip
in a master swf.  the master swf will contain the code to iterate through the
objects of the loaded swf.  

the file name can be entered by a user with an input textfield or the browse
method of the filerefence class or, if you are creating a jsfl application, the
user can apply your application to their swf.
sabin_black - 27 Feb 2007 20:00 GMT
ok cool.  So from what I'm understanding, I can only iterate through the
objects IF I create my own master SWF that embeds the generic swf?  Meaning,
there is no way that I can create javascript code that can directly query for
all loader objects or whatnot from a generic SWF.

Ok but this might sound very amateurish (since I don't know anything about
actionscript, and this was more of a last resort kind of solution), how do I
iterate through all swf loader objects in the generic swf file?

Thanks for your patience and replies.
kglad - 27 Feb 2007 20:31 GMT
no, javascript can't access a swf unless the swf calls the javascript which
wouldn't meet your needs.

you can create a swf that contains:

loadMovieNum("someoneElsesSWF.swf", 1);
preloadI = setInterval(preloadF, 100);
function preloadF() {
    bl = _level1.getBytesLoaded();
    bt = _level1.getBytesTotal();
    if (bl>0 && bl>=bt) {
        clearInterval(preloadI);
        findAssetsF(_level1);
    }
}
function findAssets(tl) {
    for (obj in tl) {
        if (typeof (tl[obj]) == "movieclip") {
            // tl[obj] is a movieclip.
            findAssets(tl[obj]);
        } else if (typeof (tl[obj]) == "object") {
            // tl[obj] is a button, textfield or object
            // you can probably determine which by further testing.
        } else if (typeof (tl[obj]) == "function") {
            // obj is a function defined in tl
        } else if (typeof (tl[obj]) == "string" || typeof (tl[obj]) == "number" ||
typeof (tl[obj]) == "boolean") {
            // tl[obj] is a variable
        }
    }
}
sabin_black - 28 Feb 2007 18:44 GMT
Thanks kglad.  This was very helpful!
kglad - 28 Feb 2007 19:21 GMT
you're welcome.
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2009 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.