AS3 :: Accessing Methods In Loaded Swf

May 20, 2011

I'm loading an external AS3 SWF using the Loader class but i need to access a method inside the loaded SWF. how can i do this?

View 1 Replies


Similar Posts:


ActionScript 3.0 :: Accessing Methods In Loaded Document Class

Feb 9, 2009

I'm trying to access an init method I've set in one of my document level classes.

Container Movie loads Main Movie, which has Main.as as its document class, but I want to do a few things before I show the actual content. Here are some functions in Container.as:

Code:
public function moveLogo(e:TimerEvent):void{
loadTxt.visible = false;
var logoMoveUp:Tween = new Tween(logoCont, "y", Back.easeIn, 221, -250, 1, true);

[Code].....

If I trace e.currentTarget.content.init on my EVENT.COMPLETE callback function, I get "function Function()" like I should.

View 2 Replies

ActionScript 3.0 :: Accessing Superclass Methods On An Externally-loaded SWF?

Jul 27, 2009

I'm trying to set up a large project that has a "shell" application that preloads and eventually displays a bunch of SWFs as a "slideshow". Each SWF could be authored by different people but will reference a base document class so they exhibit consistent behaviour. One of these behaviours is to be able to localise the slideshow into different languages. Since each SWF could have a different number of textfields that need to be localised embedded into their main timeline, the SWFs each must declare their stage instances in their document class. In order to implement the common functionality (such as a "localiseText()" method), I have decided to package all common functionality into a superclass (what I'm calling "Base Class" in this example) and using a subclass as each slide's document class.

This Example:This is a simple example I set up because in my actual project my compiler was throwing a coercion error when I tried to cast the Loader.content as my external class. The structure of this example is the following:

+ loader.fla : this is the main "shell" application.
+ SWFLoader.as : the Document Class for loader.fla
+ external_1.fla : this is the external SWF file that will get loaded and displayed

[code]....

I've set it up this way because a hypothetical external_2.fla might have different public variables to declare its stage instances so would need a separate implementation of ExternalBase (presumably External2.as).

The code (in reverse):

base/ExternalBase

[code]....

This just sets up the localiseText() method which is used in this example to change the contents of the text field. Since we don't know the name of the text field in the particular slide's timeline, we have to ask for it from the subclass' implementation of getLocalisableTextField(). We declare an abstract function here that needs to be overridden in the implementation.

[code]....

View 11 Replies

Methods Of Accessing/loading External SWF's?

Apr 20, 2010

What are some methods of accessing/loading external SWF's aswell as there variables inside them. I've been using URLrequest and loader methods no luck yet.

View 1 Replies

ActionScript 3.0 :: Accessing Methods And Properties Via GetChildByName

Dec 2, 2007

I seem to be having a bit of a problem here. I'm generating a load of class instances using the following code:

maxpersons=25;
for (var i:Number=1;i<=maxpersons;i++)
{
var person:Person = new Person;

[Code].....

OK. I then need to run through each of them and check for a collision with an object from the main stage (called redDot), which I pass to a method (called doDamage) within the class. I'm using the following code:

for (i=1;i<=maxpersons;i++)
{
if (game.getChildByName("person"+i).hitTestObject(red Dot))
{
game.getChildByName("person"+i).doDamage(redDot);
}
}

I keep getting an error saying "1061: Call to a possibly undefined method doDamage through a reference with static type flash.displayisplayObject."!

It just won't work. I've tried altering the code to:

game["person"+i].doDamage(redDot);

but I get an unexpected trace output saying "TypeError: Error #1010: A term is undefined and has no properties."

View 6 Replies

ActionScript 3.0 :: Accessing MovieClip Methods From A Class?

Oct 17, 2009

Here is the situation:I have created a movieClip named "tp_crack" on the timeline and created its class using linkage called "tp_crack".The tp_crack mc is like a small rectangle which breaks in 3 seconds when it is played.I have a seperate class in which I have used tp_crack to create many instances of tp_crack going by the names: cracked1","cracked2" etc.These instances are present in another movieClip (this time created within the class) called "crackContainer".Now I have added the following code to check for hitTest of those cracked1,2,3...... with a spaceship.The hitTest works but flash does not recognize the pieces as movieClips and does not play them as required, instead it gives me an error saying:1061: Call to a possibly undefined method play through a reference with static type flash.displayisplayObject.

for (var i:uint=0; i<crackedPieces; i++) {
if (crackContainer.getChildAt(i).hitTestPoint(Spacesh ip.x,Spaceship.y+(Spaceship.height/2),true)) {

[code].....

View 4 Replies

AS3 :: Flash - Accessing Object Methods Given As Value In Dictionary?

Nov 17, 2011

So I am writing a program which uses Dictionary to store objects. For example

var dictionary:Dictionary=new Dictionary();
var myObject = new myObject(var1, var2, var3);
dicionary["key"]=myObject;

where var1, var2, and var3 are simply means of assigning values to variables in myObject.can I access values or functions that are found in myObject? In myObject class I have some getters and setters. Can I use a getter to get the value of var1 for example.

dictionary["keys"].getVar1()?

View 1 Replies

ActionScript 3.0 :: Accessing Properties And Methods Of External SWF

Oct 2, 2011

I can't access the props and methods of an external AS3 swf after it's loaded by Main.as. Here's a very simplified version of the code for Main.as (the calling swf):

Code:
package{
import flash.display.Sprite;
import flash.events.Event;
import flash.net.URLRequest;
import flash.display.Loader;
public class Main extends Sprite{
private var imgLoaded:Boolean = false;
[Code] .....

View 5 Replies

ActionScript 3.0 :: Accessing Global Variables In Functions/Methods?

Jun 2, 2011

Which of the following is better in terms of performance/effectiveness?

public var a:int = 0;
public function Addition():void {
a += 5;

[code].....

View 7 Replies

ActionScript 3.0 :: Call Methods Of A Loaded SWF?

Feb 13, 2008

I've written a pre-loader for my game, it uses Loader, URIRequest and LoaderInfo to display a bytes left/total counter as the main game SWF loads - this all works fine.

However what then happens is that the main SWF constructor is called, so the game starts running "in the background" while the pre-loader finishes off.

I moved the 'start game' code from the constructor into a different function but I'm now left with the issue of how can I actually tell the main game SWF to start?

You can't do loader.content.go() (where go() is the function I want to call).

How can I access methods of a loaded SWF? Or is there another way? I tried dispatching a custom Event from the pre-loader, but the game SWF just never heard it - but is this the right way to go about things?

I really want to pass some bits of data from the pre-loader into the main game SWF too, but until I can figure out how to make them both talk I'm totally stuck! Is there a way the game SWF could reference any variables set by the preloader?

View 9 Replies

Actionscript 3 :: Can't Access Methods Of Loaded Swf File

Nov 14, 2011

I can't seem to access anything from a loaded swf file. I can, however access parent variables/methods from inside the loaded swf file.

var ldr:ProLoader;
function loadExternalSWF():void {
ldr = new ProLoader();

[Code]....

This just gives me the error:

TypeError: Error #1010: A term is undefined and has no properties.

EDIT: wrapperMC is just an empty movie clip instance that I've created and positioned on the stage to load the external movie into.

View 1 Replies

Flex :: Access The Public Properties And Methods Of A Loaded SWF

Mar 18, 2011

How would you go about calling the public properties and methods of a SWF you load in actionscript?

I have been using stackoverflow for years to answer my programming questions so I wanted to give back by writing a guide to an issue I had a lot of trouble figuring out. This is my first user guide so tell me if there is anything I can do to improve it.

View 3 Replies

Professional :: Access Methods From/to Parent And Loaded Child Swfs?

Sep 14, 2010

Imagine 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 Replies

ActionScript 3.0 :: Accessing A Loaded Swf?

Jun 1, 2011

I'm using this code to bring in another swf into a movieClip called "movieLoader":
 
var myLoader:Loader = new Loader();
movieLoader.addChild(myLoader);
var urlMovie:URLRequest = new URLRequest("movie1.swf");
myLoader.load(urlMovie);
 
The movie loads just fine, but how do I access it?
 
I tried:trace(movieLoader.totalFrames);
 
and it just gave me "1".  I know the movieclip has more than 1 frame.What do I do to access the swf called "movie1.swf" I just brought into that movieClip?

View 4 Replies

ActionScript 3.0 :: Accessing Another Loaded SWF?

Oct 13, 2010

So I want to access another loaded SWF. How can I have ChildA talk to Child B? All are external SWFs.

[Code]...

View 1 Replies

ActionScript 3.0 :: Accessing Loaded External Swf?

Mar 30, 2009

I am using a zoom component which i purchased recently to load different external swfs on different button clicks. But instead of loading separate external swfs I would like to load a single swf and go to frame labels - "one", "two", etc. - I've been reading about casting the external swf as a movie clip, but I am confused how this would work with the code I have at the moment.

var image:String="introlocal.swf";
function loadContent () {
var myLoader:Loader = new Loader();

[code].....

View 1 Replies

ActionScript 3.0 :: Accessing The Url From Which A Swf File Has Been Loaded?

Jan 6, 2009

finding the url of the swf filefrom which it has been loaded? The purpose of the url is, I amloading some flv files using relative path. I just want to achievethe same by appending the relative path to the parent swf url fromwhere the parent was loaded. I am a newbie to AS3

View 5 Replies

ActionScript 3.0 :: Accessing A Variable Loaded From Another Swf?

Sep 15, 2008

I have a problem accessing a variable loaded from another swf. Actually the variable is a singeltone class, which needs to be initialized.It has structure presented in the last part of the message.The project has the following structure:

- main.swf - this loads all the other swf files and is their holder.

- assets.swf - contains some common elements and initializes the SingleTone class

- interface.swf - contains some interface elements and needs to use the SingleTone class

- all the three swf files have access to a common class structure, where the SingleTone class is defined.

Now, the problem I have is accessing the SingleTone class from the interface.swf file. If I try to send the SingleTone.singleTone. property parameter to the class I get "Type coercion failed: cannot convert from ClassName@.. to ClassName". If I try to access the SingleTone class directly from the interface.swf file i get "Cannot access a property or reference of a null object...". Both errors I get seem logical:

- if I send a parameter, I send the reference to that object, but the interface.swf file does not have access to the assets.swf domain;

- if I try to access the SingleTone class directly from the interface.swf file, I get the null error because the class is not initialized over the interface.swf domain.

Is there any work arround? I know a simple solution may be to initialize the variable over the interface.swf domain, but what if there is a variable that can only be instantiated in the assets.swf? Can I access that variable from another swf, or can I change the ApplicationDomain?

View 1 Replies

ActionScript 3.0 :: Accessing Webcam From Loaded Swf?

Nov 14, 2010

I am trying to load swf file with Loader class into AIR application. The broblem is that the loaded swf can not access web cam (it can when I run it standalone). Is there any security settings I have missed.
 
AIR loader code:
loader = new Loader(); loader.name = "moduleLoader";loader.contentLoaderInfo.addEventListener(Event.COMPLETE,

[Code]....

View 3 Replies

ActionScript 3.0 :: Accessing A Class From A Loaded SWF

Nov 23, 2011

In Flash Professional, I drew a shape, converted it to symbol, linked it to class Symbol1 (extends MovieClip) which is generated at run-time, and saved the SWF file as shape.swf.
 
Now my main application wants to load shape.swf and create multiple instances of Symbol1 but I get ReferenceError when trying to access the class Symbol1.
 
Below is my main application's code. Errors thrown are mentioned in comments.
  
public class MovieClipTest extends Sprite
{
public function MovieClipTest()
{

[Code]...

View 11 Replies

Flex :: Accessing Root Of Loaded Swf?

Mar 4, 2012

I have a SWf application built in flex 4. One part of the application relies on accessing a public variable ("step1") set at the application root, and is accessed with

var app:Object = FlexGlobals.topLevelApplication;
trace("step one is "+app.step1);

This, while not optimal, has worked fine. Now, hoever, I need to load this entire application into another application, and I can't figure out how to access my step1 variable any longer.I have been loading the swf into the new parent application like so:

public var myLoader:Loader = new Loader();
public var pizzaContainer:UIComponent = new UIComponent();
private var myUrl:URLRequest = new URLRequest("chickensoup.swf");

[code]......

View 1 Replies

ActionScript 3.0 :: Accessing Variables In A Loaded Swf

Jul 1, 2009

I am creating a flash program to open other flash programs (load swf files), and change their textfields to my own extended textfield class. This is to capture all text written to screen using a textfield object. Here is what I am doing:

1. If a textfield has been created, the event is captured

2. I want to replace the textfield with my own class extending textfield

*3. Any further access to the original textfield for value changes can be captured, and would update the replaced extended textfield object

The problem is if in their original code, at sometime, the text value of textfield is changed (mainly through textFieldObj.text = some_value) , I don't know how to capture this event.

This cannot be captured by event.CHANGE which requires the user input (ie: keyboard strokes) into the actual text field and changing the text through the code: textFieldObj.text = some_value does not trigger the event.

Here is a simplified example:

// FlashMovie.fla START -------------------------------------------
// any DisplayObjects (such as a created textfield) created will be captured
// by ChildAdded()
this.addEventListener(Event.ADDED, ChildAdded);

[Code]....

View 0 Replies

ActionScript 2.0 :: Accessing Button In A Swf That Is Loaded On To Another Swf

Jul 22, 2009

I have a movie called crime_scene.swf that is loaded onto another swf.

Code:
this.createEmptyMovieClip("myContainer", 1);
var mclListener:Object = new Object();
mclListener.onLoadInit = function(target_mc:MovieClip)

[Code]....

It seems like it's not working. I tried just myContainer.evi_1.onRelease and _level1.evi_1 but nothing seems to work.

View 2 Replies

ActionScript 3.0 :: Accessing Functions From A Loaded SWF?

Jun 30, 2010

I have a file which loads a series of SWFs. It loads one, allows it to play to completion, then stops. Right now, it will just wait for the user to press a button and select the next one. However, I need it to play them sequentially. Is there any way for the SWFs which get loaded to access the functions which control the SWF loading?

View 4 Replies

ActionScript 3.0 :: Accessing MC Children By Name On Loaded SWF

Jul 14, 2010

Im loading SWFs into my AS3 application. My SWFS are all the same and contain this structure:

root
-item
--color
--overlay

When i load up a SWF file into AS3, This is analogous to the root. So i can say:

[Code]....

I have tried everything i can think of to access this second depth by instance name. Whats wierd is that MovieClip(loadedSWF.item).numChildren returns 2. So Flash knows that theres 2 MovieClips inside of item.... But it just cant reference them by instance name. Since loadedSWF.item works, i assumed that loadedSwf.item.color would work too.

EDIT: I seem to be able to access the MC via getChildAtIndex(0); However this isnt ideal because it create a rule for the designer that he must follow a layering order. Id prefer to do it by name.

View 0 Replies

ActionScript 3.0 :: Accessing A Class From A Loaded SWF?

Nov 23, 2011

In Flash Professional,I drew a shape, converted it to symbol, linked it to class Symbol1 (extends MovieClip) which is generated at run-time, and saved the SWF file as shape.swf.Now my main application wants to load shape.swf and create multiple instances of Symbol1 but I get ReferenceError when trying to access the class Symbol1.Below is my main application's code. Errors thrown are mentioned in comments.


ActionScript Code:
public class MovieClipTest extends Sprite[code].............

View 3 Replies

Actionscript 3.0 :: Accessing Variables Of A Loaded SWF?

Jan 12, 2011

I'm having a SWF call functions from another SWF loaded in the first one with the Loader class. There are no problems as long as the target SWF does not contain any TLF TextFields created on stage by authoring time interface. As soon as I place a dynamic textfield on the stage of the loaded SWF, the main SWF (the loader) fails to call any of the functions within the SWF that is being loaded.Static text does not seem to present problems and neither do TextFields created via ActionScript.Also, is it possible to access variables of the parent SWF?

View 2 Replies

ActionScript 2.0 :: Accessing Variables In A Loaded .swf?

Dec 5, 2003

I am having a problem accessing variables in a loaded flash movie.

As my understanding goes (someone please correct me if I am wrong), if I load a flash movie into a parent movie (i.e. 'loadMovie("myMovie", emptyClip);'), I should be able to access the loaded movie's variables using dot-syntax.

As an example, say I have two movies: MainMovie.swf, and SubMovie.swf. SubMovie.swf contains a (global) variable called someText. After loading SubMovie into an empty movie clip called "emptyClip", MainMovie.swf should be able to access the aforementioned variable by saying "emptyClip.someText", right....? Well, when I try this I keep getting an undefined value for the variable.

View 7 Replies

ActionScript 2.0 :: Accessing Contents Of Loaded SWF?

Mar 25, 2006

I loaded an external swf into flash using loadMovie. The loaded movie has a hidden button which does some actions. How can I, by clicking on a button on flash execute the actions of the button which exists on the loaded swf?

View 1 Replies

ActionScript 2.0 :: Accessing Functions In Loaded Swf

Sep 8, 2008

I'm sorry if this has been answered 1,000 times, but I am so confused with everything!! In the main timeline of my movie, I have a container movieclip called "content". I want to load an external swf into content, and then access the functions in that swf. I can load it no problem, but I can't for the life of me figure out how to access the functions, I can't seem to find it anywhere!

View 3 Replies







Copyrights 2005-15 www.BigResource.com, All rights reserved