Can Loaded Swfs Reference Static Methods Of Container.swf?
Hello, I have a Container.swf that is responsible for loading in other Content.swfs. I defined a Container.as file as the document class for Container.swf, and created a few static methods that I want to have available for the Content.swfs. I figured that after a Content.swf is loaded, I could just reference those methods like so :Container.myStaticMethod("var1", "var2");but I am getting a compile time error which I understand fine, but wasn't expecting it, since it wasn't thrown with AS2.1120: Access of undefined property GroundI also tried Stage.myStaticMethod("var1", "var2"); which yields pretty much the same result.Do I need to import my class Container.as class in each of my content.swfs?Thanks in advance
KirupaForum > Flash > ActionScript 3.0
Posted on: 09-27-2007, 03:55 PM
View Complete Forum Thread with Replies
See Related Forum Messages: Follow the Links Below to View Complete Thread
Static Methods Vs. Instance Methods And Memory Usage
Hello all, I'm pretty green to OOP (at least "real" OOP) and am trying to wrap my tiny little brain around something. I understand the difference between static and instance methods in the practical sense, i.e. how the static modifier affects a method for in a class. What I'm not 100% on is memory usage and whether I should even care. Here’s my specific scenario for context:
I am creating a package for list generation, rendering and editing, there are a number of classes in the package; Item, PlainList, EditableList and DragDropList. At a minimum, one of the list constructors is passed a target movie (where to draw the list), itemName (symbol name for Item constructor) and dataList (data items for Item constructor). There is also an EventDispatcher that fires "onInitList", "onInitItem", "onSelectItem", etc. These lists could be hundreds of items long and contain sub-list instances. So, long story there could be thousands of list/item instances at a time.
The majority of methods (in pretty much all classes) could be written as static by simply passing the target instance. For public methods, I would make lightweight wrappers that call the appropriate static method, for example:
Code:
class PlainList {
public function PlainList( target:MovieClip, itemName:String, dataList:Object, margin:Number, xOffset:Number, yOffset:Number, rows:Number ){
//bunch'o'code here
}
public function draw( type:String ){
if ( type == "grid" ) PlainList.drawGrid( this );
else PlainList.drawList( this );
}
private static function drawGrid( pl:PlainList ){
//bunch'o'code here
}
private static function drawList( pl:PlainList ){
//bunch'o'code here
}
}
As I understand it, if I use static methods, the method is instantiated only once for the class and there is only one pointer to it. If I were using instance methods each method is uniquely instantiated with it's own memory space and pointer for ever instance of the class. Given that there could be thousands of class instances at a time each with 20-30 methods, does the technique described above make sense? Will I be saving memory? Is this bad OOP? And finally, although right now I am using AS2 in Flash 8, I will be updating to Flash 9 ASAP, any implications regarding AS3? For example, usage of the "protected" and "final" modifiers? Thanks.
Using Same Class Name In Container And Loaded SWFs
I have an application that is structured as a master SWF X which loads in a variety of children SWFs using the Loader class. It displays each child SWF within a viewport in the master SWF: a simple design.
I typically create a top-level class named "Application" for every SWF I build. The contents of the Application class is completely different from SWF to SWF, it's just the same name for the top-level container within each particular SWF.
Now I am finding in AS3 (which I have only migrated to recently), that when I load up a child SWF in the master SWF, what appears in the viewport is NOT the child SWF, but instead another copy of the master SWF. It's as though it locates the class name when running the child SWF and reuses the Application reference to mean the a new copy of the master.
I was able to fix it by renaming the child's Application class to a variant ("Application_06"). But it will be trickier if there happens to be some little helper class in the child SWF which happens to share the same name as a class in the master SWF -- which is very likely to occur. Isn't there a way to run an SWF within another such that they don't pay attention to the internal class names of the other SWF?
Static Properties And Loaded Swfs
I communicate between different swfs using static variables and functions. I'm running into an issue when testing the file locally the swf's that the main swf loads in can't access the static variables the main swf set. I'm pretty sure it's because when I test the main swf is in the authoring environment and the other swfs are being loaded from "localhost" so they are in different domains technically. Is this because they are in seperate application domains when I'm testing? When I load them all in the browser through localhost it works fine but then I lose all the debug functionality and convenience of the built in player.
Any ideas on a work around for this would be very helpful. Thanks.
Reference To _root From Loaded SWFs
If I have an SWF load one more SWf in it (let's say in level1) and level1 SWF has reference to _root from it's code, where will it actually refer, to _level0 root or to _root of level1?
Thanks
Static Methods
i made a public static function in my class so i can call it from the timeline, in it i make a instance of a class. but then the instance is counted as static apparently and won't let me run addChild or my methods
Static Properties And Methods
hi all,
i am a newer to as2.0. i was trying to under stand the static proprties and methods.i read that static properties are related to class or instances of that class. can any body make it clear.
i cant make out the diffrence very clearly.
examples will be very much helpful.
can anybody guide me.
thanx in advance.
medais
[AS3] Enforcing Static Methods
I'm stuck.
I have IBinaryEncoder and IBinaryDecoder interfaces that are implemented by my codec classes. The codec classes are all-static classes with two public methods:
• public static encode(source:BinaryFile):ByteArray
encode() is enforced by the IBinaryEncoder interface.
• public static decode(source:ByteArray):BinaryFile
decode() is enforced by the IBinaryDecoder interface.
Is it possible to enforce public static methods in AS3? The compiler shouts at me when I try to declare a static method in an interface.
Error 1061 While There's No Static Methods
Hi again Kirupa,
Once again i have a problem, now wit objects
i'm develop a project and the code of the main class i very bulk
But i've isolate my problem and here i'm here ... beging for help
first i have one simple class, with this class i have no problem
Code:
package {
import flash.events.*;
import flash.display.Sprite;
public class TooltipProblem extends Sprite{
public function TooltipProblem():void{
createSomeObject();
}
private function createSomeObject(){
var button:Sprite = new Sprite();
button.graphics.beginFill( 0 );
button.graphics.drawRect( 0, 0, 100, 40 );
button.graphics.endFill();
button.x = 100;
button.y = 40;
button.addEventListener( MouseEvent.MOUSE_OVER, onButtonOver );
button.addEventListener( MouseEvent.MOUSE_OUT, onButtonOut );
addChild( button );
}
function onButtonOver( e:MouseEvent ):void{
var t:ToolTip = new ToolTip();
t.show( 'test content' );
}
function onButtonOut( e:MouseEvent ):void{
trace(e.target);
}
}
}
here i'm creating a simple rectangular, and assign to it a 2 events, one for MOUSE_OVER, and one for MOUSE_OUT
from onButtonOver function, i've create new tooltip instance
now i have another class who's must to create the tooltip.
Code:
package {
import flash.display.Sprite;
public class ToolTip extends Sprite {
public function ToolTip():void {
//some settings
}
public function show( content:String ):void {
trace( 'content', content );
}
}
}
and when i compile this, i recieve an error like this:
HTML Code:
1061: Call to a possibly undefined method show through a reference with static type ToolTip.
why ? please help me to figure this out, i'm pulling my hair for 5 hours ... and i have no idea why is this problem, i've read the forum threads, and other forums, google the problem but ... couldn't find a solution.
Quick Question About Static Methods
Are static methods innately slower than instance methods? I have been using static methods heavily in a project I'm working on and was just worried that maybe instance methods would be faster... anybody know for certain?
thanks!
Object Communication , Methods,events,broadcasters,dispatchers.. My Ever Static Probs
Hello Gary,
I am not completly clear about object coomunication.
Would it be possible for an object from a private class to communicate via methods calling with another object
also to be instantiated from a private class?
Please explain.
Actually, what does the private modifier does regarding classes?
Can I have communication between static classes?
Where can I learn more about object communication in As?
Another thing: why does the Singleton uses the static modifier? Every instance of the SingletonClass will
hold the same for that static holder, but if there is never more than one instance of it why do we need it
to be hold the same for every possible instance.
Also, what could be the use of using the private modifier for a class? What could a private class be used for?
What about a private static class?
please explain and clarify me and us all.
Thanks,
Daniel Alexandre
ps. It would be great if one Guru out there could do a tutorial or/and a video on the subject. The Flash community would thank you!
Static Function Call Through Type Reference
I'm attempting to call a static member function of a class without instantiating it via a type reference as returned by getDefinitionName.
Code:
var typeRef:Class = getDefinitionByName(__class) as Class;
var width:int = typeRef.getWidth();
This isn't working, I'm getting a syntax error:
1061: Call to a possibly undefined method getWidth through a reference with static type Game.GameLogicisplayObject
I've googled quite a bit and I'm not seeing anything relating to this, is this even possible?
1119: Access Of Possibly Undefined Property OverState Through A Reference With Static
package {
import flash.display.*;
import flash.events.*;
public class SimpleButton extends Sprite
{
public function SimpleButton()
{
var button:SimpleButton =new SimpleButton();
button.x=20;
button.y=20;
button.upState= createCircle (0x00ff00,15);
button.overState =createCircle (0xffffff,16);
button.downState =createCircle (0xcccccc,15);
button.hitTestState =button.upState;
button.addEventListener(MouseEvent.CLICK,handleCli ck);
addChild(button);
}
private function createCircle(color:uint,radius:Number):Shape{
var circle:Shape=new Shape();
circle.graphics.lineStyle(1,0x000000);
circle.graphics.beginFill(color);
circle.graphics.drawCircle(0,0,radius);
circle.graphics.endFill();
return circle;
}
private function handleClick (event:MouseEvent):void{
trace("Mouse clicked on the button");
}
}
}
//
1119: Access of possibly undefined property upState through a reference with static type SimpleButton.
1119: Access of possibly undefined property overState through a reference with static type SimpleButton.
1119: Access of possibly undefined property downState through a reference with static type SimpleButton.
1119: Access of possibly undefined property upState through a reference with static type SimpleButton.
1119: Access of possibly undefined property hitTestState through a reference with static type SimpleButton.
help......what's wrong?
1119: Access Of Possibly Undefined Property Event Through A Reference With Static Typ
Hi,
I just try the code below but I received the error message.
Is anybody who can help me?
Many thanks in advance.
import flash.events.*;
import flash.media.Sound;
import flash.media.SoundChannel;
var soundReq:URLRequest = new URLRequest("sound10.mp3");
var sound:Sound = new Sound();
var soundControl:SoundChannel = new SoundChannel();
var resumeTime:Number = 0;
sound.load(soundReq);
sound.addEventListener(Event.COMPLETE, onComplete);
function onComplete(event:Event):void
{
play_btn.addEventListener(MouseEvent.CLICK, playSound);
stop_btn.addEventListener(MouseEvent.CLICK, stopSound);
}
function playSound(event:MouseEvent):void
{
soundControl = sound.play(resumeTime);
pause_btn.visible = true;
pause_btn.addEventListener(Mouse.Event.CLICK, pauseSound);
play_btn.visible = false;
play_btn.removeEventListener(MouseEvent.CLICK, playSound);
}
function pauseSound(event:MouseEvent):void
{
resumeTime = soundControl.position;
soundControl.stop();
play_btn.visible = true;
play_btn.addEventListener(Mouse.Event.CLICK, playSound);
pause_btn.visible = false;
pause_btn.removeEventListener(MouseEvent.CLICK, pauseSound);
}
function stopSound(event:MouseEvent):void
{
soundControl.stop();
play_btn.visible = true;
play_btn.addEventListener(Mouse.Event.CLICK, playSound);
pause_btn.visible = false;
pause_btn.removeEventListener(MouseEvent.CLICK, pauseSound);
}
pause_btn.visible = false;
1061: Call To A Possibly Undefined Method GotoAndStop Through A Reference With Static
i have two movieclips on the stage called button1 and button2 and inside them have 3 frames for different states of the movie
for (var i:Number = 1; i <= 2; i++)
{
this["button" + i].addEventListener(MouseEvent.MOUSE_OVER, mouseOn);
this["button" + i].addEventListener(MouseEvent.MOUSE_OUT, mouseAway);
}
function mouseOn(e:MouseEvent):void
{
var butName:String = e.target.name;
butName.gotoAndStop(3);
//this.button1.gotoAndStop(3); -- this line works
//trace(butName); -- this = button1 or button2 depending on which one i roll over
}
function mouseAway(e:MouseEvent):void
{
var butName:String = e.currentTarget.name;
butName.gotoAndStop(1);
}
//get this error: 1061: Call to a possibly undefined method gotoAndStop through a reference with static type String.
i have tried having this.butName.goto.... but cant see whats wrong.
im pretty sure this is me being thick as ive only been using this a coulple days.
any help grateful.
1119: Access Of Possibly Undefined Property Redbutt Through A Reference With Static T
Hi!
I'm trying to add an addeventlistener (click) for a movieclip within a movieclip which is in the library. And this movieclip is supposed to be loaded on stage with a click from another button which is on stage from beginning.
I get "1119: Access of possibly undefined property redbutt through a reference with static type Class."-errors and can't figure out what's wrong, the movieclip is correctly spelled and exported to actionscript but it won't work if it's not on stage.
What's wrong?? please help a guy stay sane!! Thanks!!
button.addEventListener(MouseEvent.CLICK, laddaKlippigen);
testing.redbutt.addEventListener(MouseEvent.CLICK, laddaKlipp);
function laddaKlipp(e:MouseEvent){
var v_minText:MovieClip = new test();
v_minText.name = "i_text";
stage.addChild(v_minText);
}
function laddaKlippigen(e:MouseEvent){
var v_loText:MovieClip = new testing();
v_loText.name = "i_loText";
stage.addChild(v_loText);
}
Access Of Possibly Undefined Property Through Reference To Static Type Flash.
Hi guys, well I've created a slide show. Only problem is that I keep getting error messages which say "access of possibly undefined property through reference to static type flash." or they say "access of undefined property.."
I did a bunch of research and my situation doesn't change whether I use Action Script 2 or 3. In the example its three. I've made number buttons which are supposed to allow you to go through the slide show. I'd hugely appreciate any suggestions.
You can see the slideshow here:
http://paragon-nj.com/slideshow.html
and the fla:
http://paragon-nj.com/slideshow.fla
Currently I'm using this code with one, two and three being the butttons:
one.onRelease=function(){
gotoAndPlay(90);
}
two.onRelease=function(){
gotoAndPlay(175);
}
three.onRelease=function(){
gotoAndPlay(260);
}
Loading Swfs Into A Container
I am trying to load various swf into one container (instancename:holder).
In As2 i used to declare a variable, change its properties via buttons and load the swf using the MovieLoaderClass into the holder clip.
what is cool about this is the fact that when you load a different movie or a website category, firstly the exisiting movie exits and then the new is loaded which leads to smooth transitions.
i used the MovieLoaderClass heavily which doesn't work in AS3.
loading a swf in AS3 is straight forward but cannot seem to get my head around loading swf via a variable
How To Open Links To Swfs In A Container
I would like to be able to click on a link in a dynamic text menu and have it open in a container file:
on (release) {
// get page
setProperty ("../button" add n, _visible, false);
location = eval("link" add n);
getURL ("" add location, "_blank");
}
On the line getURL ("" add location, "_blank"); you'll see the standard _blank, _self etc in the second set of quotes for loading in links from a dynamic text file list. BUT what I want to do is load an swf file into a container and have it play, instead of opening a new window. Is this possible?
Loading Next And Previous SWFs Into A SWF Container
Hi
I have up until now been using scenes or very large single swf file for movies, however I have been looking at using the unload swf function but to say I am a little confused is an under statment... Prehaps if I state my needs someone could give me some help or point me to a helpful tutorial or example that has already been done!!...
I have a top level SWF that has a graphical 'TV' Screen and two buttons, Next and Previous. I have 9 other swf files that need loading in 3 ways:
1. Automatic .. First plays then when end of swf1 is reached then swf2 plays.. so on and so on..
2. Press the Next button which loads in the 'next' swf
3. Previous Button that loads the 'previous' swf..
I have found a couple of examples that do bits of this but Im sure there must be something out there that hits everything and probably stuff I havent thought of...
Any help much apprieciated..
Steve
Loading Multiple Swfs In A Container
Hello Guys
Coming from a java background,I am struckwith flex/actionscript probs.My requirement is pretty simple for actionscript developers But i dont know how to start.I need to have multiply swfs in a master container.I wish to know what the child swfs should extend.How can i resize the child swfs in the master container.please suggest.
Loading Swfs In To Container Within Master Swf
I am having a problem loading an swf into a movie that itself is loaded into a master swf.
In other words I have a map (called "downtown.swf") of a town that when you click on a building, another swf ("rosettas.swf") containing address information is loaded into a container using:
but1.onPress = function () {
_root.createEmptyMovieClip("container",1);
loadMovie("rosettas.swf","container");
container._x = 1250 ;
container._y = 850 ;
}
that works.
However, I downloaded a zoomable map ("zoom.swf") which loads the downtown.swf into a container itself and then allow you to zoom in and out of the map. When I click on the building in downtown.swf (which has been loaded into zoom.swf and it iturn into "test.html") the button is active but rosettas.swf does not load, or if it does then it is in the wrong level, so cannot be seen.
I know this is a question of paths and levels so I put all the files in the same folder to eliminate any strange path issues. Still Nothing.
I realise that the _root call in the code in downtown.swf which I pasted in to this thread is no longer root, since it has been loaded into zoom.swf.
Does anybody have a clue as to a solution? I am willing to send files to somebody who could help me.
By the way "zoom.swf" also has this line of code in it
containerForZoom._lockroot = true;
Thanks in Advance.
1119: Access Of Possibly Undefined Property BigC Through A Reference With Static Type Flash.display:DisplayObjectContain
I am working on a script that enables the user to move items around on the screen. They do this for several trials. On each new trial I would like the items to return to their original positions. When I try to make it do that, I get the error indicated in the title above. I cannot seem to refer to those items. I have been trying getChildByName, but that does not seem to be working. The problem is in the trial function.
Any help would be appreciated.
Russ
Attach Code
import flash.display.MovieClip;
import flash.display.DisplayObjectContainer;
//EXPERIMENT SETUP
//Var declaration and Init
var myFormat:TextFormat = new TextFormat();
myFormat.size = 12;
myFormat.font = "Arial Bold";
var targetFormat:TextFormat = new TextFormat();
targetFormat.size = 14;
targetFormat.font = "Arial Bold";
var bigC:MovieClip = new MovieClip();//bigC holds all the stimuli
var sodaA:Array = ["Charming", "Cheerful", "Coca Cola", "Daring", "Diet Coke", "Diet Dr. Pepper", "Diet Mountain Dew", "Diet Pepsi", "Down to Earth", "Dr. Pepper", "Fanta", "Honest", "Imaginative", "Intelligent", "Me", "Mountain Dew", "Outdoorsy", "Pepsi", "Reliable", "Spirited", "Sprite", "Successful", "Tough", "Upper Class", "Up to Date", "Wholesome"];
var dataA:Array = new Array();
var randA:Array = [];
var trialNum:int = 0;
var bigTargetC:MovieClip = new MovieClip();
var targetC:MovieClip = new MovieClip();
var targetTF:TextField = new TextField();
//Randomize targets
for (var ii:int = 0; ii<=sodaA.length; ii++) {
randA.push(ii);
}
shuffle(randA);
function shuffle(a:Array) {
var p:int;
var t:*;
var ivar:int;
for (ivar = randA.length-1; ivar>=0; ivar--) {
p=Math.floor((ivar+1)*Math.random());
t = randA[ivar];
randA[ivar] = randA[p];
randA[p] = t;
} //end for
} //end shuffle
//Set up stimuli
for (var i:int=0; i<sodaA.length; i++)
{
var sodaC:MovieClip = new MovieClip();//these are the objects we move around
var sodaTF:TextField = new TextField();//contains the text for the object
bigC.addChild(sodaC);//adding the soda object to bigC
sodaC.addChild(sodaTF);//Adding the text to each soda object
sodaC.name = sodaA[i];//give the soda object the name as the next label in sodaTF
sodaC.y= 27*i +50;
sodaC.buttonMode = true;
sodaTF.text = sodaA[i];//Text is the same as the name of the soda object.
sodaTF.setTextFormat(myFormat);
sodaTF.selectable = false;
DisplayObjectContainer(stage).addChild(bigC);//show bigC and its contents on the stage
sodaTF.width = 140;
sodaTF.autoSize = TextFieldAutoSize.LEFT;
sodaC.addEventListener(MouseEvent.MOUSE_DOWN,startDragging);
sodaC.addEventListener(MouseEvent.MOUSE_UP,stopDragging);
} //end for
Next_mc.addEventListener(MouseEvent.CLICK, getCoords);
trial();
function trial():void//Create and place stimuli list and target item
{
for (var i:int=0; i<sodaA.length; i++)
{
DisplayObjectContainer(stage).bigC.getChildByName(sodaA[i]).x = 0;
DisplayObjectContainer(stage).bigC.getChildByName(sodaA[i]).y = 27*i +50;
//getChildByName(sodaA[i]).y = 27*i +50;
//DisplayObjectContainersodaC.name = sodaA[i];
//sodaC.x = 0;
//sodaC.y= 27*i +50;
}
targetTF.setTextFormat(targetFormat);
targetTF.text = sodaA[randA[trialNum]];
targetTF.x = 545;
targetTF.y = 365;
targetTF.autoSize = TextFieldAutoSize.CENTER;
bigTargetC.addChild(targetC);
targetC.addChild(targetTF);
DisplayObjectContainer(stage).addChild(bigTargetC);//show bigC and its contents on the stage
};//end function trial
function startDragging(event:MouseEvent):void { //Enable drag and drop
event.currentTarget.startDrag();
}
function stopDragging(event:MouseEvent):void {
event.currentTarget.stopDrag();
}
function getCoords(event:MouseEvent):void { // Calculate Ratings based on x and y
for (var j:int=0; j <sodaA.length; j++) {
var xDist:int = Math.pow(bigC.getChildByName(sodaA[j]).x - 545, 2);
var yDist:int = Math.pow(bigC.getChildByName(sodaA[j]).y - 365, 2);
var dist:int = Math.sqrt(xDist + yDist);
var rating:int = 4;
if (dist > 338) {
rating = 4;
} else if (dist > 255 && dist <=338) {
rating = 3;
} else if (dist > 173 && dist <= 255) {
rating = 2;
} else if (dist > 91 && dist <= 172) {
rating = 1;
} else {
rating = 0;
}
dataA.push(randA[trialNum], j, rating);
}
trace(dataA);
//for (var i:int=0; i<sodaA.length; i++)
//DisplayObjectContainer(stage).removeChild(bigC);
trialNum ++;
trace ("trialnum is" + trialNum);
if (trialNum <= sodaA.length) {
trial();
}
else {
//write dataA to an external file and name that file
gotoAndStop(2);
}
}//end Program
Loading Swfs With Custom Classes Into A Container (MX)
Hi all,
I've got built myself a movie which contains the Class "square", which is a movieclip that has several prototype definitions.
On it's own, this works just fine (you can see it here http://www.s-j-t.co.uk/flashkit/squares.swf), however when i load this swf into another container movie, all stops working and the clips that are scattered over the stage normally, don't get defined.
I've checked through and set all the variables and functions to be defined within the swf (.i.e. paths are with _root), so in theory it's self-contained but this doesn't seem to make a difference.
I've got a feeling this is about variable scope...or maybe cross definitions of function and variable names...
Any pointers on where to start debugging this would be a massive help...
cheers!
Loading External Swfs Into A Sized Container
I am wondering how I should load the external swfs into the centre stage w/o loading the whole movies. I understand a bit abt using the container to fetech the external swfs for download. However I am not sure how to make the external swfs download into the sized container.
You can take a look at my illustration diagram so that you can understand what I mean.
I appreciate it if you can give me some advice. Thanks!
How To Reference A Loaded Swf, When Loaded Inside A Loader Component?
I am trying to control a movie (swf) that I loaded into the flash loader component. I have two files: preloader.swf and movie1.swf.
Preloader.swf has the Flash component from mx.controls.loader.
I have given this component the instance name "myLoader".
Once preloader.swf is called, it loads movie1.swf.
Movie1.swf has a button that controls the frame of a mc played within movie1.swf. When I test the movie1.swf without loading it into the preloader component, the button works as expected. However, when I load movie1.swf into the preloader.swf, it doesn't control the play of the mc.
#This is the AS I attached to button in movie1.swf when I am loading movie1.swf into the preloader.swf. Which DOESN't work.
_root.myLoader.mc1.gotoAndPlay(10);
#This is the AS I attached to button in movie1.swf when I am playing movie1.swf WITHOUT loading it into the preloader.swf. Which DOES work.
_root.mc1.gotoAndPlay(10);
I can't seem to figure out how to reference the loaded movie in the preloader.
Any help would be appreciated.
Thanks!
Loading Multple External .swfs Into One Main Container
I have a home page that calls one main .swf file. And within this container, it calls 5 other .swf files. The problem is that when the page is loaded, not all .swf files show up. Sometimes 1 will not load, sometimes 2 will not load, sometimes they all load and sometimes none of them load. There is no pattern as it varies each time the page is loaded. Is there some sort of limitation to what .swf files can load. Any help would be greatly appreciated.
Run Methods From A Loaded Swf?
after a swf has been loaded and i try to run methods from it or return movieclips... like
myMovie.loadedSWFSprite.test();
it just says....
1061: Call to a possibly undefined method test through a reference with static type flash.display:Sprite.
Syntax For Frame Reference In External SWFs
sorry to be a pest yall - but im just trying to figure this stuff out...
what is the syntax for referencing frame labels in an external SWF?
if i have a frame labeled "endframe" in an external swf - like EXTERNALSWF1.swf
and i want to put an action in my main.fla like
if FrameLoaded ("endframe") {
gotoAndPlay (1); }
- how do i tell the main.fla that i am referring the frame named "endframe" in the EXTERNALSWF1.swf and not just any other external movieclip or the main.fla timeline ?
would it be some thing like
ifFrameLoaded ("flash/external swfs/externalsSWF1.swf","endframe") {
gotoAndPlay (1); }
ellare
Syntax For Frame Reference In External SWFs
sorry to be a pest yall - but im just trying to figure this stuff out...
what is the syntax for referencing frame labels in an external SWF?
if i have a frame labeled "endframe" in an external swf - like EXTERNALSWF1.swf
and i want to put an action in my main.fla like
if FrameLoaded ("endframe") {
gotoAndPlay (1); }
- how do i tell the main.fla that i am referring the frame named "endframe" in the EXTERNALSWF1.swf and not just any other external movieclip or the main.fla timeline ?
would it be some thing like
ifFrameLoaded ("flash/external swfs/externalsSWF1.swf","endframe") {
gotoAndPlay (1); }
ellare
How To Call Methods Of A Loaded SWF?
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?
Please help.
Calls Methods From A Loaded AS2.0 SWF?
i found this example
http://actionscript.org/forums/showp...0&postcount=13
which works GREAT for 3.0 swfs,.... but how do you do it with 2.0 swfs?
also is there a way to communicate the other direction? with 3.0 and/or 2.0 swfs.
it would be nice to set sort of like _global functions somehow that the embedded swfs can call from the main swf.
ty in advance!
Accessing Methods In Loaded Swf
hi
i am making a site that loads the news page from a different swf as it works on a different xml. Now throughout the site whenever user changes the page i reset a scroll bar. i am not able to do it for the news section as its being loaded from a different swf. is there any way of doing it.
Thanks in advance
chandings
How To Call Methods Of A Loaded SWF?
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?
Please help!
Loading External Swfs Into Externally Loaded Swfs.
ive got some buttons on my main timeline that im using to load external swfs into an empty mc. the buttons are coded with the following:
on(release){
if(_root.currMovie == undefined){
_root.currMovie = "1";
emptyMC1.loadMovie("1.swf);
} else if (_root.currMovie != "1") {
if (emptyMC1._currentframe >=
emptyMC1.midframe) {
_root.currMovie = "1";
emptyMC1.play();
}
}
}
1.swf also has some buttons that load external swfs into a second empty mc. those buttons are coded with the following:
on(release){
if(this.currMovie == undefined){
this.currMovie = "2";
emptyMC2.loadMovie("2.swf");
} else if (this.currMovie != "2") {
if (emptyMC2._currentframe >=
emptyMC2.midframe) {
this.currMovie = "2";
emptyMC2.play();
}
}
}
1.swf loads into emptyMC1 ok, and 2.swf loads into emptyMC2 ok.
when i press any of the buttons on the main timeline, the outro animation of 1.swf plays correctly, but the outro animation of 2.swf does not. is there a way to the buttons so that the emptyMC's unload sequentially?
Global Stage Reference Problems When Loading SWFs
Hi there, I have built an application using an animation class called Boostworthy from Ryan Taylor www.booostworthy.com, it works great and has smooth animation and my published swf runs great.
My problem is that when I load this swf into another one it won't run and I get the error:
//Renderer (WARNING) :: startEnterFrame :: Unable to add a listener to the enter frame event because a global stage reference does not exist.
The animation classes require that I add a global stage reference and I have added that in my main App class that is the document class in my animation swf like this:
ActionScript Code:
import com.boostworthy.core.Global;Global.stage = stage;
This works fine when the swf runs on its own but when I load it into another movie I get the error mentioned above. I've tried setting this reference in different classes (my animation swf uses a number of classes) but no dice. I think that I might need to pass a reference to the stage from the top-level movie to the animation swf though I don't know how to do this.
I have tried like this:
ActionScript Code:
//code on top level movie var myApp:App = new App(this);//code inside App class (main class used for animation)import com.boostworthy.core.Global; public function App(mc:MovieClip){ Global.stage = mc.stage }
but I get the same error message
I'm really stuck with this and I need to solve it as I have a project on that requires me to load my swfs into others.
Any help really, really appreciated!
Thanks in advance,
Schm
Can A Loaded Swf Call Methods Of Its Parent?
My main application Document Class, Main.as, loads a new movie swf with a loader. ("external.swf" class External.as).
Can External call public methods of the main application class?
How do you address that class?
Calling Methods Of A Loaded Flex Swf
Hi all!
I'm loading a swf made in pure Flex from a pure ActionScript project. The Flex swf implements an interface. I load that swf and then I try to call a method of the loaded Flex swf but it doesn't work.
This is the Flex swf that I'm loading:
Code:
<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" implements="IApp" layout="absolute">
<mx:Script>
<![CDATA[
public function init():void
{
trace( "INIT OK!!" );
}
]]>
</mx:Script>
</mx:Application>
This is the interface IApp:
Code:
package
{
public interface IApp
{
function init():void;
}
}
And this is how I load the Flex swf in the ActionScript pure project and try to call the init method:
Code:
package {
import flash.display.Loader;
import flash.display.MovieClip;
import flash.display.Sprite;
import flash.events.*;
import flash.net.URLRequest;
import flash.text.*;
public class PruebaGS extends Sprite
{
public var URL:String = new String( "FlexSWF.swf" );
public var loader:Loader;
public function PruebaGS()
{
loader = new Loader();
loader.contentLoaderInfo.addEventListener(Event.COMPLETE, completeHandler);
loader.load( new URLRequest(URL));
}
public function completeHandler( evt:Event ):void
{
var movie:IApp = evt.target.content as IApp;
movie.init();
}
}
}
The problem is that evt.target.content is of type _FlexSWF_mx_managers_SystemManager so it cannot be converted to IApp.
Does anyone know what is the problem?
Thanks!
Help: Call Methods Or Dispatch Events From Loaded Swf?
OK, I must be massively missing something. I want to do the following, using a best practices method:From MAINSWF create a Loader
Loader loads SUBSWF.swf, which contains buttons, code (AS3), etc
have buttons or code in SUBSWF.swf call a method or dispatch an event to MAINSWF. Really any way to get a message of any kind to MAINSWF will be fine.
I can't for the life of me figure out how to do it, because: I cannot trace up the displayObject chain from within Loader. The tree dies at Loader when I try to traverse upwards from SUBSWF.swf. So I cannot call the equiv of this.parent.parent.doStuff();
I can't get custom events to propagate up from SUBSWF.swf to MAINSWF. It's as if there is an event "firewall" within Loader. See my related post for info.
I'm sure someone has figured this out. Any help is much appreciated.
Thanks,
dseeley
XML Loaded In Container =no Work
Hi all,
I`m trying to load a XML mc into a container mc. It works fine when I simply load the xml mc into the a different level, butit won`t when I use a container file.... e.g.
_root.loader.loadMovie("menu.swf"); // loader is the container mc
any ideas?
thanks,
m.
Swf Loaded In Container Won't Work
Hi all,
I built a variation of Comic Geeks easing menu system (http://www.actionscript.org/resource...tem/Page1.html) which works fine just by itself.
After loading it into a Container of my main movie, the buttons refuse to function though.
Since I'm not a pro my best guess is that it might have to do with the actionscript?
Most likely the _root reference or the coordinates of the loaded movie don't work, but it doesn't react at all.
I'd apreciate any help on this.
Here's the code from the loaded movie:
//during the time the movie loads, we set the current
//position of the content at 0,0; thus showing the
//HOME section of the site.
onClipEvent (load) {
_x = 0;
_y = 0;
div = 5; //This value just determines the speed
//the transistions.
}
//Here we constantly check for new values of
// _x and _y. These values are determined by endX and endY.
//We divide the difference by div to have an value that
//continues to change until the equation is true.
//Try changing the 'enterFrame' with 'Load' to see the
//difference. You would then have to click on a button
//several times before the transistion completes.
onClipEvent (enterFrame) {
_x += (endX-_x)/div;
_y += (endY-_y)/div;
//We then use the onRelease method to determine the
//new values of endX and endY. This is a new feature
//in Flash MX.
_root.home.onRelease = function() {
endX = 0;
endY = 0;
};
_root.works.onRelease = function() {
endX = -700;
endY = 0;
};
_root.skills.onRelease = function() {
endX = -1400;
endY = 0;
};
Many thanks!
AS Not Working When Loaded Into Container..
This code fades in a sound when the movie starts, and fades out when it reaches a specific frame. On its own, it works perfectly. The issue is when I try to view the page with the main holder SWF, which loads the separate SWF sections in with a container. I can't see why it wouldn't work when loaded. There are 3 other sounds on the page that work perfectly even when viewed from the container.
My entire site is done except this sound issue, so any help would be greatly apprecaited.
Quote:
cityLoop = new Sound(cityLoopMc);
cityLoop.attachSound("city");
cityLoopVolume=0;
cityLoop.setVolume(cityLoopVolume);
fadeIn01=1
cityLoop.start(0,999);
onEnterFrame = function () {
//Fade In
if (fadeIn01==1) {
cityLoop.setVolume(cityLoopVolume);
cityLoopVolume=cityLoopVolume+1;
if (cityLoopVolume>99) {
fadeIn01=0;
}
}
// Fade Out
if (fadeOut01==1) {
cityLoop.setVolume(cityLoopVolume);
cityLoopVolume=cityLoopVolume-3;
if (cityLoopVolume<5) {
cityLoop.stop("city");
fadeOut01=0;
}
}
}
Calling Method From AS2.0 Loaded Swf In As3.0 Container Swf
Hi,
i m updating my e-learning course player project with Flash cs3 and AS3.0. the old version of course player is developed in As2.0. which load cousre swf files .
it is working fine Flash8 As2.0.
the new course player load course swf. the loaded course swf on a specifec frame call a method like this
_level0.setButton(2) method from course player;
The setButton(parameter) method defination is in new courser player. the loaded movie which is develped in Actionscritp2.0 not finding this method
in new course player which in Actionscript3.0. its working well with the old course player.
can any one give me solution to solve the issue.
i can’t make changes in course swf files b/c there are thousand of course swf files in developed in as2.0.
i have used Swfbridge component and also local connection classes
but both are two way communication, so i have make changes in thousand of swf files of my cousrer ???
can any one give solution of this issue or guide me the right thing to do
regards
Shane
Class Not Working When Loaded Via Container
Hi there
I have made a button component that uses a class file to interact with Flash. (buttonControl.as).
I have basically created a shell that handles the navigation of all the content. That means that I am creating all my content externally in SWFs, which get loaded into the container file.
Heres the problem:
When I export the file, and it runs in its own SWF, it works beautifully. When I load it into my container file, however, it stops working. It's like Flash isn't loading the class, or at least, only partially loading the class. The thing is, my buttons are active, but the onRelease actions don't work.
Copying the component into the container file's library and duplicating the .as file fixes the problem, but is there another way?
File structure like this:
Root > Content > myFile.swf
buttonControl.as is in Content folder...
Thanks!!
Stop Loaded SWF From Resizing To Fit Container
I am really new to this, having recently decided to take up ActionScript 3.0 after years of Visual C++... I am having major troubles, the most recent being that I can't get a dynamically loaded swf to be the size that I want. Get this... The swf is x by y. I know the dimensions. I am not trying to make it scale to other dimensions. I am trying to KEEP it from scaling automatically. My app is dimensions w by h, and I load a swf of known dimensions x by y. For some reason, the result is a loaded swf that scales yet keeps it's aspect ratio: in this case, it scales until it fills up the y, leaving whiteness on both sides (x). Ok, I am using a Loader. I set width and height properties, and the swf doesn't load at all. I stuff it (the loader) into a sprite or movieclip and set the width and height; no swf. It only shows up on the screen if I let it do what it wants, which is to take over the whole app client area. HOW do I force it to stay the size that it is supposed to be? Better yet, can anyone tell me what good having a width and height property is if you can't set them without breaking your application? How does one create a container of a given width and height. Everytime I try to do it, the result is that the container doesn't exist.
Oh yeah, I forgot to mention - I am doing this in straight ActionScript 3.0 - no Flash IDE. I use FlashDevelop.
|