ActionScript 3.0 :: Access A Function Within A Function In A Parent Swf From A Loaded Swf?
Jul 29, 2010Is it possible to access a function within a function in a parent swf from a loaded swf?
View 6 RepliesIs it possible to access a function within a function in a parent swf from a loaded swf?
View 6 RepliesWell- actually, my problem is a bit more abstract than this thread's title suggests..ere's the setup:I have a parent function (called "Game") with a couple of subfunctions.There is one subfunction ("Game.prototype.spawnBonus") that, as the name suggests, spawns a Bonus Item by duplicating a movieclip.The duplicate movieclip is created on "_root"-level and has an onEnterFrame attached to it that checks whether a certain stage is met (all this works).Now the problem is, when the case is met, I need to access a subfunction of "Game" and pass it the MC's ID to fade out the Bonus Item. Like so:[AS]Game.prototype.fadeBonus =
function(number) {
// just some stuff to fade out the MC with the number
// passed through the value "number". This works well,
[code].....
I have to access a function in child swf from parent swf. This child swf gets loaded into a canvas object in parent.swf. Everything works fine but I'm unable to call any function that was in child.swf. My code is
Code:
var swf1:SWFLoader = new SWFLoader();
swf1.source = "CHILD.swf";
can.addchild(swf1);
I read on google and then I tried this in parent.swf's code
Code:
var myrequest:URLRequest = new URLRequest("CHILD.swf");
var myloader:Loader = new Loader();
myloader.load(myrequest);
canvas.addchild(myloader);
Now this one throws up a runtime error TypeError: Error #1034: Type Coercion failed: cannot convert flash.display::Loader@5934b01 to mx.core.IUIComponent.
I also tried this
Code:
var myrequest:URLRequest = new URLRequest("CHILD.swf");
var myloader:Loader = new Loader();
myloader.load(myrequest);
[Code]....
But in this case my swf does not show up at all and there are no runtime errors too!
How do I resolve this error and how do I then access the function in child.swf?
syntax for calling a function (and sending arguments) located in an external SWF from a parent SWF?
View 2 RepliesI have a swf that should be able to load another swf in runtime. Then I would like the loaded swf to call a method of the parent, loader swf, like this:
Code:
parent.closeForm;
But when I compile it, it throws this error:
1119: Access of possibly undefined property closeForm through a reference with static type flash.displayisplayObjectContainer.
I've tried:
Code:
if (parent != stage){
parent.closeForm;
}
So flash won't run this code at compile time, but it always throws that error. Here is the code of the LOADER swf:
Code:
private function loadForm():void {
var loader:Loader = new Loader()
var mRequest:URLRequest = new URLRequest(formPath);
loader.load(mRequest);
loader.contentLoaderInfo.addEventListener(Event.COMPLETE, onFormCompleteHandler);
[Code] .....
How could I write an expression that should call a function of the LOADER swf without having this compile-time error?
I'm trying to make a loaded SWF call a function that is in the parent SWF, but it is not working.In AS 2.0 I could just put something like _root.myFunction(); and it worked.But in AS 3.0 it does not work anymore.
View 3 Repliesi load in ActionScript a swf file. So far no Problem, but I didn't found a way to access one of it's functions, the best thing would be if I could access the main function in the mxml part of the swf.
Here is the code of the main-mxml file that belongs to the swf that should load and access another swf[code]...
My problem maybe a development problem is that i've a preloader file.This preloader with bulkloader load and external swf that is the index file.Now because of i'm using the preloader every stage reference in the index class like stage.stageWidth will generate a #1009 error. So my question is how can i access to the an index class function so that when the preloader's stage will resize some index sprites must will assume the new width of the stage?
View 0 Repliesi've a preloader that load an swf with bulkloader. How can i access to a function of the loaded swf?
View 3 RepliesIs there a way to call a function inside a loaded SWF file?
Basically, I have a .swf file (A) that loads another .swf file (B)...I would just like to treat B as if it was any other instance added to my class .swf "A"...
Have to recast "Loader" with the name of your .swf file class:
Loaded .swf class:
package src {
import flash.display.MovieClip;
public class LoadedSWF extends MovieClip {
[Code]....
I have followed the tutorial on gotoandlearn that builds a preloader swf to load an external swf. The problem I am having on the main timeline is that I now cannot access a function in the final external loaded swf. This worked fine when I just loaded the external swf into the main timeline but with the preloader I think I have my loader instances confused and I don't know how to fix it.
[Code]...
Like I said this worked perfectly before I tried cleaning things up with intermediate preloader swf and now its all gone pete tong (again!!) When testing this by reviewing the main timeline it cannot recognise the function killStream
I have a class Debug with a function called trace inside it which puts a TextField on the stage and outputs the text. Now I am trying to get the Debug.trace() function to do a "normal" debug trace as well from within side itself. of course this causes a recursive loop. I am trying to figure out how I can access the top level separately. I tried using namespaces such as AS3::trace but to no luck.
I know a solution is to rename my function to stop the conflict, but I would like that to be a last resort. It is being used in quite alot of places throughout my entire code so replacing it everywhere is going to be a ballache.
I have 2 functions, 1 loaded before another. Some value are determine by the other function data, but since one of it has to load before the other 1, how should I get the data that is loaded after current function?
private function wMessage():void {
Message.width=Name.width+20;
}
[Code]....
I've taken out some other unnecessary codes, but as you can see Name position is set according by the position + width of Message, but I want Message's width to be not smaller than Name
The easiest thing is if you look at my swf: [URL] Ive built a dynamic photo gallery which works from an XML database. The database contains the various gallery titles, the photo image paths and their captions.
The first page of the gallery is a thumbnail index page (lots of small preview images of the photos). The thumbnails load up one by one, they are only 1kb each but there are hundreds so takes some time. If a user clicks on one, the thumbnail movieclip is hidden with (._visible) and the photo page is shown, also with (._visible).
The problem is, the thumbnails are still being loaded in the background, so the chosen photo is not downloaded+shown until all the thumbnails have loaded. What kind of code do I need to place on the thumbnail's "onRelease" function to cancel the parent "make thumbnails" function ive made?
I've got a Vector of ViewToActionMap objects, which have following constructor:
public function ViewToActionMap(_forModule:eModule,
_forAction:eViewAction,
_toFunction:Function,
[code].....
I want to load an external swf movie into the parent one using for example the UILoader component and I want it to have access only to one object of the parent (the main swf movie). I tried sth like my_uiloader.content.parent = null, but obviously it doesn't work as the parent property is read-only.
View 15 RepliesImagine the following setup. The main swf loads a child swf.In AS2 i would simply use _parent or _root to call the desired function. How can that be done in AS3?Can this still be done? Can I call a function on the main swf from the loaded one? How about the other way around, this time, from main to loaded swf?
View 1 RepliesI'm having trouble adjusting to the way functions pass in AS3. How come when I say "this" it doesn't know I'm refering to AudioTrack?
PHP Code:
var AudioTrack:Object = new Object();
AudioTrack.myVar = "Hello";
AudioTrack.onComplete = function(){
[Code]....
new to actionScript and trying to finish my final project, and i'm banging my head on a brick wall now, my question may be easy for some pros, basically i've loaded an external swf from a button at main.swf
[Code]...
this works fine. then i'm trying to disable the button function while the swf is loaded. I add another eventListener to the same button. function disableMenu( e:MouseEvent ):void { button1.mouseEnabled = false;}
that works too. ok now comes the problem. I have a close button on my child swf("content1.swf) to close itself and returen to main swf. but I want the button on main.swf to work again. so at the close button I add another eventListener hope to enable the menu. (note this is on the child swf!)
[Code]...
I have two movies... main.swf and content.swf, and I'm trying to call a function in my main.swf from my content.swf. Here is the code..
//function in main.swf
function appear (event:MouseEvent):void{
TweenLite.to(title1, 1, {autoAlpha:1, overwrite:false});
[Code].....
I got an error message as soon as i click on close_btn. It says appear() is not a property or method.
I've created a Preloader.as class. When the preloader finishes loading, I'd like it to call a function from it's parent (the document class).This is the error I get:
Code:
1119: Access of possibly undefined property startApp through a reference with static type flash.display:DisplayObjectContainer.
[code].....
i have a swf that loads a swf that loads one swf into that one. i need the final swf (child, child) to be able to call a function on the first swf (parent)
i have tried this:
if(MovieClip(parent.parent.parent)!=null){MovieCli p(parent.parent.parent).parentFunctionCall();}
[Code].....
So, my problem, I have a Parent swf file that loads a bunch of smaller swf files. When I click on a button in one of these loaded swf files, I want to be able to call a function from the parent swf. Once called, the function manipulates things MC's within the parent swf.
View 2 RepliesI have a function (let's call it testFunction for right now ) on the actions layer in the main timeline There is a movie clip with 15 frames long in the library
i want to add a child of the movie clip on the stage, and call testFunction when it finishes playing
how can i do? i tried to call it in the child but nothing works
Or, is there any way to show child on the stage for only a period of time like 1 second and then remove it automaticly?
new to actionScript and trying to finish my final project, and i'm banging my head on a brick wall now, my question may be easy for some pros,[code]this child swf is loaded from xml. and the close button is created by using AS file. The "button1" is just on the stage of the main swf. Maybe these make some difference so i can't just point it back using (root)?Any idea how do I resolve this? Or am I not supposedd to do it this way at all?
View 2 RepliesIn actions in my .fla file I create a new object of a class (addChild) which is in an separate .as file. Now, in my .as file I want to call a function in the .fla file. This should be the parent right? So, I try parent.correct(); which does not work. I get the error #1061 (call to a possibly undefined method). However, when I do this:
var par:* = parent;
par.correct();
Everything works. Why is this?
i have a swf that loads a swf that loads one swf into that one. i need the final swf (child, child) to be able to call a function on the first swf (parent)
i have tried this:
if(MovieClip(parent.parent.parent)!=null){MovieCli p(parent.parent.parent).parentFunctionCall();}
[Code]....
I have a function in a child that I need to have executed by the parent but I can't get it to work. Does anyone know how to call the function in a child from a parent?
What I'm doing is having the parent load a few buttons and I want to re-use the button swf, but have the parent provide the text for the button.[code]...
May i know how to call child function(layer 2) in parent(layer 1)?
Layer 1 (Parent)
function changeAction():void{
changeColor();
}
This method will give me the error -> Call to a possibly undefined method changeColor.
Layer 2 (Child)
function changeColor():void{
trace("success");
}
I have a .fla file with some code in the actions panel.A bit of code calls a function in a class from the actions panel .The function in the class is run, but I want to be able to call a function in the main actions panel code from the function in that class .The class doesn't extend anything so (parent as MovieClip).function() does not work.
View 7 Replies