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


Similar Posts:


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

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

IDE :: Accessing Library Of Externally Loaded Swf?

Jan 17, 2010

I have a swf file which contains in its library couple pictures. After it is loaded using preloader I would like to be able to create couple instances of them and add them to the stage

If I use swc approach and import it in library path I can not preload it but instancing is very simple i.e

Code:
public var pic:Pic1 = new Pic1();

and that's it, I can add it then to stage then.

How to access them when doing it with swf and loader class?

View 1 Replies

ActionScript 3.0 :: Superclass Logging Its Subclass Methods?

Feb 25, 2011

I have an abstract superclass which has around 300 subclasses. I would like to log when certain methods on this parent are called, and I'd like to know the name of the subclass thats making the call. Is there any way to do this without rewriting all my subclasses to explicitly pass their names upwards to the parent's logging method? E.g., let's say I have a superclass Foo with a method writeLog(str). Foo has a subclass called FooBar, which calls super.writeLog("hello"). Can writelog just inherently figure out that a FooBar called it, without the need to rewrite everything so that we have to call super.writeLog("hello", "FooBar") ???

View 1 Replies

ActionScript 3.0 :: Air 1.0, Externally Loaded SWF Accessing Camera

Jan 21, 2011

I am building a touch screen kiosk Air App using Flash CS3 and Air 1.0.
 
I have my application downloading external SWFs for different advertisements, one of which will need access to the webcam built into the kiosk.
 
By itself, the advertisement accesses the camera just fine, however Camera.getCamera() returns null when it the SWF loaded into the kiosk app. Both the main kiosk app and the advertisement app are compiled using Air 1.0.
 
It appears that I'm getting a security sandbox violation, however I'd like to avoid completely rewriting my app using the sandbox bridge architecture just so one of my ad pieces can access a webcam.
 
Does anyone have any suggestions or know of any work-arounds for allowing webcam accesss from within an embedded SWF in Air?

View 1 Replies

Accessing A Class From An Externally Loaded Flex SWF?

Apr 23, 2011

Using Flex 4, I have created an SWF that has the following code:

<fx:Script>
<![CDATA[
import mx.events.FlexEvent;
import com.Index ;
protected function start(event:FlexEvent):void

[Code]...

View 1 Replies

ActionScript 2.0 :: Accessing Movieclips In Externally Loaded .swf

Aug 10, 2009

I am a newbie to AS 2.0..I only have basic actionscript 2.0 knowledge."I have one main .swf file and several external .swfs which I am loading through this code.[code]Now my problem is that I would like to access one "close_mc movieclip" in ourGroup.swf ...so that clicking that clip, I can exit the externally loaded .swf from the main .swf file."

View 3 Replies

ActionScript 3.0 :: Accessing Buttons On Externally Loaded SWF

Feb 22, 2012

I have loaded an external swf into loaderTopBanner. It works to manipulate that, but not the individual buttons within it. (e.g. btn_Home, btn_Info)
loaderTopBanner.btn_Home.alpha = 0;

View 2 Replies

ActionScript 3.0 :: Accessing Stage Of Externally Loaded Swf?

Jul 22, 2009

I am loading an SWF created in Flash CS4, using the 3d translation tool.The SWF is being loaded into an application being build in as3 in flex builder 3.I can manage to load the movie however the stage has disappeared. All of the objects that exceed the boundaries of the (banner) remain visible instead of being cropped by the stageI attempted to mask the swf before publishing which did not work, and I attempted to programmatically assign a mask once it was imported which also did not work.None of these options threw errors, in most cases they either had no effect whatsoever or the movie simply disappeareI've read numerous posts on this and the answers always seem to be vague.Based on my research I need to access the stage properties of the SWF being loaded, but am unsure how to go about it.Do I need to compile the movie, export a swc and add it to the build path for the project?Do I HAVE to use a document class for the SWF I want to load in order to access it?Do I need to add anything else to the source or build path for the project in Flex Builder?

View 5 Replies

ActionScript 3.0 :: Accessing Properties For An Mc In An Externally Loaded Swf?

May 24, 2010

I am trying to set a couple of properties (specifically width and height) for an mc within an externally loaded swf but am having bigtime troubles. Keep getting the 'Error #1010: A term is undefined and has no properties'. The code is attached below. I have tried to figure this out and searched for solutions but could not resolve this myself.

import flash.display.MovieClip;
import flash.display.StageAlign;
import flash.display.StageScaleMode;

[code]......

View 1 Replies

ActionScript 3.0 :: Accessing Parent Variables In Externally Loaded Swf?

Jun 24, 2009

here's what I have (simplified to only show necessary code):

Main Timeline:
var currentItem:String = 'applesauce';
(then some code to load an external swf)

[Code].....

View 1 Replies

ActionScript 3.0 :: Accessing Document Class Of An Externally Loaded Swf With AS3

Aug 5, 2010

I have loaded one swf externally in my main class. and there is one button in loaded swf suppose its name submit_btn. i have to do that when i click on submit_btn, this loaded swf should be removed. what is the code for that

View 1 Replies

Actionscript 3.0 :: Accessing Library Items From An Externally Loaded SWF?

Aug 11, 2009

I'm slowly working my way through AS3, and have a question about how to do this. In as2, you could just load a swf file, then use attachMovie("itemLibraryLinkageName");. I know in AS3 you have to use addChild() to add items to the display list, but how would you go about adding the library items to the stage from an externally loaded swf in AS3? I've tried:

Code: Select allvar library:MovieClip;
var loader:Loader = new Loader();
loader.contentLoaderInfo.addEventListener(Event.COMPLETE, onComplete);[code].......

View 2 Replies

ActionScript 3.0 :: Flash - Accessing Classes From Externally Loaded Swf's?

Apr 30, 2011

I have a document class which links to several classes, one of which adds a container onto the stage and loads external .swf's into it.Q: How do I access the various classes loaded in the document class from the external swf timeline?For instance, when you click a button in the loaded swf it changes the soundtrack from the soundtrack class. I have tried dispatchevent from the external swf timeline, but I still can't seem to get it to work. Is this supposed to work, or should I be doing something different?

View 1 Replies

ActionScript 3.0 :: Accessing Variables And Functions From Externally Loaded Nested Clip?

May 23, 2009

How would you go about accessing a function or variable from a parent clip if the clip accessing has been loaded using the Loader() constructor in AS3?

View 1 Replies

ActionScript 3.0 :: Accessing Vars In SuperClass From SubClass?

Jun 12, 2005

So, how would you create a class that can access a variable in the class where the subClass was created(superclass), I realise this might be unclear so in example

PHP Code:
package {import flash.display.MovieClip;public class Main extends MovieClip {public va demoString:Strin = "TEST";public static var newClass:SubClass;public function

[code].....

View 12 Replies

ActionScript 3.0 :: Accessing Vars In SuperClass From SubClass

Feb 24, 2012

So, how would you create a class that can access a variable in the class where the subClass was created(superclass), I realise this might be unclear so in example

[Code]...

View 14 Replies

Actionscript 3 :: Access A Superclass's Superclass In Flex?

Jan 17, 2011

I'm trying to override a subclass's method but I think I need access to the superclass one higher up in the hierarchy. So I'd like to do something like super.super.methodName();

FYI, the actual problem I'm trying to solve should be explained by my code below:

public class A extends UIComponent{
override protected function keyDownHandler(event:KeyboardEvent):void{
super.keyDownHandler(event);

[Code]....

If I use the class A's KeyDownHandler method, you will see that remove() is called regardless. However, the docs state that I need to call UIComponent.keyDownHandler whenever I subclass UIComponent. Of course this works for the first subclass, but not that subclass's subclasses.

I realise that I could put the functionality all into A with something like if(this is B){...} but that seems to me to be a hack.

View 2 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 2.0 :: Preloading Flashvars - Ensure That All The Content Being Loaded Externally Is Loaded Before The Transition Plays?

Aug 30, 2005

I am in the process of building a site for an Architect... Jamie Fobert Architects (projects) I am useing transitions between the projects and am loading details/text and images externally through flashvars, php and a mySQL database. Within my transitions I have a a preloader on the forst 2 frames the code is as follows (taken from a Voetsjoeba tutorial):

[Code]....

This works pretty well if the content is within the .swf, but when it is loaded externally it doesnt preload it at all. Does anyone know how I can adapt/improve this preloader? or somehow ensure that all the content being loaded externally is loaded before the transition plays?

View 2 Replies

ActionScript 3.0 :: Accessing Externally Defined Variables?

Aug 22, 2009

Here is the problem:I have 2 external as3 files in a "com" folder next to the FLA within which i am working. The first of these ( "Main.as") is the document class. The second ("events.as") contains variable definition "myVar:Number = 0" which i want to be able to access and change inside Main.as. I am sure that this is possible, but i can't get it working (flash very keeps pointing out that I have made an error. Specifically that old classic: "1046: Type was not found or was not a compile-time constant: myVar." which has puzzled me since the dawn of time.

View 3 Replies

ActionScript 2.0 :: Externally Loaded Swf Does Not Stay Loaded?

Feb 16, 2006

I am loading an externally loaded swf that uses a mask to transition in. When the user clicks a different button I am doing a gotoAndPlay that goes to a mask that "unloads" the content (it doesnt actually unload the info is just outside of the mask area. As soon As I jump to that section the movie is no longer loaded and just shows the container clip that I had created for it. The Container Clip is never changed and is the same throughout the whole process. The only thing that changes is the mask animation.I have tried both loadClip and loadMovie but no luck on keeping the clip loaded.

EDIT - I have narrowed it down. When I change the mask movieclip the movie unloads for some reason. Is there a way I can keep it loaded?

View 2 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







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