Tracking Forums, Newsgroups, Maling Lists
Home Scripts Tutorials Tracker Forums
  Advanced Search
  HOME    TRACKER    Flash




Passing Varible From External Class To Main Fla



okay i'm like going crazy on this.

all i want to do is have a variable in an external class..something along the lines of:

public var _temp_text:String = "woooo";

and then all i want is for my main fla file to be able to see it.

how come if i do a trace(_temp_text) it still says undefined? even though i imported the class?

sooooo confused. i think i'm missing something. can anybody help???



ActionScript.org Forums > ActionScript Forums Group > ActionScript 2.0
Posted on: 03-09-2007, 05:18 AM


View Complete Forum Thread with Replies

See Related Forum Messages: Follow the Links Below to View Complete Thread

Passing Arguments To A Main Class
In Flash CS3/AS 3.0 you associate a "main class" with a flash file which when loaded in the flash player (quoting from the Colin Mook book AS 3.0 Essentials) "automatically creates an instance of the program's main class."

I'd like to know if it is possible, and if so, how to pass arguments to the main class.

Any help is greatly appreciated.

Passing Variable From External .swf Into Main Movie..
I'm loading an external swf, titled "arial.swf" into a placeholder MC on my main movie "font_typer.swf".

The variable in font_typer.swf is user_input

I want to pass the value of user_input into my external .swf so when it is loaded into the main .swf I can use the variable's value in it.

Ideas?

Passing A Variable From External Swf To Main Movie?
Hi -

I have a main movie, one frame long with one variable defined in the first frame called movieCount. (_root.movieCount=0; ) with a dynamic text field that displays this number.

I then have a movie clip in the first frame of the main movie also that simply loads an external movie into it using loadMovieNum(this works and the movie does load and play).

All I'm trying to do is update the movieCount variable of the main movie from the external swf that's loaded. On the first frame of the external movie I have (_root.movieCount=1; ). This doesn't seem to be working.

I've tried various configurations to no avail. I have a feeling I'm just doing something wrong in relation to paths.

Any help is appreciated! Thanks.

Passing Variables From An External Movie To Main Timeline
So I've been fighting Flash (8 if you're curious) for a good half-day and even the internet is letting me down. I'm still in the learning stages, so I'm convinced it's something I'm just totally too dumb to have missed -- if anyone could send me in the right direction, I'd be forever grateful. I'm not going to be able to sleep 'til I figure this out!

So my project is setup like so: I've my main flash file, and it loads external .swfs into a movieclip on the main timeline at _root.content using the loadMovie function. In the first frame of external swf, variables are defined for number of bytes loaded, number of bytes total, and percent loaded. When the percent loaded variable (currently named as loadPercent) reaches 100, the movie begins. No problems there.

Then I have a loading bar on my main timeline. It is set to appear only when an external movie is loaded. Dynamic text fields display the bytes loaded, total bytes, and percent done accurately (path used from within the loader clip is _root.content.loadPercent). That works fine.

But when I try to write ActionScript containing if-statements that reference this variable, it fails to evaluate it correctly. I'm trying to use the loadPercent variable, but I've also tried creating a new one in the main timeline by referencing the bytesloaded/totalbytes variables. That also fails. I've tried declaring the loadPercent as a _root variable from within the external swf, and that didn't work. I tried declaring it as a global variable. No dice. I've tried using it in all kinds of different places, none of which work. Usually it seems to evaluate itself as either undefined, or as the formatted "100" that displays as dynamic text -- except that the variable held all that formatting, HTML-style, too. (I have since eliminated THIS problem by using different variables entirely for the two.)


The strangest part of ALL is that when I export and get the player to list my variables, _root.content.loadPercent SHOWS UP CORRECTLY. (As _level0.content.loadPercent, but this doesn't work for me either, if I try to use it.)

My wits are totally ending. If anyone knows any way to either a) obtain those two variables regarding the external swf from the main timeline or b) pass the variables properly from the external swf into the main timeline, please let me know.

Thanks!


s.

Passing Data From Combo Box To Varible
How do you capture a combo box component value and store it in a varible?

Access Var In Main .fla From External Class
Hi,

I'm having trouble figuring this out. Basically I have an .fla with three parts:
FLVPlayback component (defined as var flv:FLVPlayback)
a box that contains some textFields (which should contain info about the movie currently playing. Loaded using an external class called InfoBox.)
a 'filmstrip' of thumbnails to select which movie to play (this is generated dynamically using an external class called Dock.)

How do I change the source of the FLVPlayback component using the navigation generated by my Dock class. Here's the simplified code examples...

From the main .fla


Code:
// ***** FLVPlayback Component *****

var flv:FLVPlayback = new FLVPlayback();
flv.source = 'flv/test.flv';
// snip - formatting options
addChild(flv);


// ***** INFO BOX *****

// snip - var declarations
var info:InfoBox = new InfoBox(480, infoHeight, infoWRadius, infoHRadius, strokeCol, fillCol, infoOpacity);

addChild(info);
I then call my navigation element class(Dock) within a loop:


Code:

function ParseXML(dockInput:XML):void {
var videoList:XMLList = dockInput.video.children();
var numFiles:Number = videoList.length();
var i:Number = 0;
var baseVal:Number = (800 / numFiles);
for each ( var input:String in videoList) {
var temp:Dock = new Dock(input, numFiles, i, baseVal);
temp.x = baseVal*i;
i++;
trace(baseVal);
addChild(temp);
}
}
So, basically I need to change flv.source when I click on a button in my nav. I tried this in my eventListener, but I get an error: 1120 Access of undefined property flv.


Code:
function dockClick (event:MouseEvent):void {
flv.source = flvURL; //flvURL defined within this class
trace ("Mouse CLICK!!");
}
I know I don't have flv declared in my Dock class, but I don't know if that's the problem or how to do it correctly. I was also thinking I could target flv by using Stage or something, but again not sure.

Thanks for any help!

Is It Possible To Get A Reference To The Main Timeline In An External Class?
Hello,
After spending more then 2 hours on google on how to acces the main Timeline trough an external class
i found no solution.

Does anyone know how to acces the main Timeline in an external class?
And can you acces a movieclip (the instance name) of a movie clip that is drawn on the stage and not
dynamically placed with addChild in an external class?

I hope to hear from someone.

Help Passing Variable To An External SWF Document Class
I'm, building a 100% screen height and width flash website. The problem that I'm having is the UI section, is a separate SWF file, and same as the background. Anyways once it's finished loading I want to pass the paramaters of the stageWidth and stageHeight to it's variable called xWidth and yHeight. But when I trace those variables inside the swf, I get a NaN error. I'm not sure if I'm doing this correctly.

Document Class of the Preloader
Code:

package com.base
{
   
   import flash.display.*;
   import flash.events.Event;
   import caurina.transitions.*;
   
   public class TopLevel extends MovieClip {
      
      public static var stageAlign:StageAlign;
      public static var stageScaleMode:StageScaleMode;
      
      public static var stage:Stage;
      public static var root:DisplayObject;
      
      public var xWidth:Number;
      public var yHeight:Number;
      
      public function TopLevel() {
         
         TopLevel.stage = this.stage;
         TopLevel.root = this;
         
         TopLevel.stage.align = StageAlign.TOP_LEFT;
         TopLevel.stage.scaleMode = StageScaleMode.NO_SCALE;
         
         setStageBounds();
         
         stage.addEventListener(Event.RESIZE, onStageResize);
      }
      
      private function onStageResize(ev:Event):void {
         
         setStageBounds();
      }
      
      private function setStageBounds():void {
         
         if (TopLevel.stage.stageWidth < 955) {
            
            xWidth = 955;
            
         } else {
            
            xWidth = TopLevel.stage.stageWidth
         }
         
         if (TopLevel.stage.stageHeight < 780) {
            
            yHeight = 780;
            
         } else {
            
            yHeight = TopLevel.stage.stageHeight
            
         }
         
         if (mainUI != null) {
            
            mainUI.xWidth = xWidth;
            mainUI.yHeight = yHeight;
         }
         
         alignObjects();
         
      }
      
      private function alignObjects():void {
         
         if (preloader != null) {
            
            preloader.x = (xWidth / 2) - (preloader.width / 2);
            preloader.y = (yHeight / 2) - (preloader.height / 2);
         }
         
         if (mainBg != null) {
            
            mainBg.x = (xWidth / 2) - (mainBg.width / 2);
            mainBg.y = (yHeight / 2) - (mainBg.height / 2);
            
         }
         
      }
   }
}


Document Class of the UI
Code:

package com.bruno.base
{
   
   import flash.display.*;
   
   public class TopUI extends MovieClip
   {
      
      public var xWidth:Number = 0;
      public var yHeight:Number = 0;
      
      public function TopUI() {
         
         
         
      }
   }   
}


I'm not sure what I might be doing wrong.

Changing A Variables Value In An External .as Class From The Main Movie
hello, ive put this in another thread already after a different question but thought it might get ignored!

my first frame


Quote:





var picnumbers = 1;
butGo.onRelease = function()

{simpleSearch.doSearch(tag.text);


}








simpleSearch is a movie which the external class is linked to

my button which i wish to use to increment picnumbers and change the value in my external file


Quote:





on (release) {
picnumbers = picnumbers * 4;
myTextbox.text = picnumbers;
simpleSearch.doSearch(tag.text);
}








the first few lines of the external class file i am using, flashr.


i need NUM_RESULTS to be associated with picnumbers from the main movie somehow and im a bit stuck!!

Quote:





*/
class com.kelvinluck.flashr.example.FlashrSimpleSearch extends MovieClip
{

public static var NUM_RESULTS:Number = 10;

private var _flashr:Flashr;
private var _flashrResponse:FlashrResponse;

private var _numResults:Number;
private var _photos:Array;

Main.as Listen For External Swf's Document Class Function
repost, sorry some thought i was giving advice!
i cannot seem to get my head around this:


ActionScript Code:
Button.swf:
Button.as
This has a function to load a new swf in.

Movie.swf
Movie.as
This has a openPage function and closePage function.

Movie2.swf
Movie2.as
This has a openPage function and closePage function.

I need a way of the button.as function to fire the current closePage function, load the new movie in, then fire the current openPage function.

I need advice on ways of setting this up:
Extending certain classes to keep property functions?
override functions?

The problem I am having is that I cannot work out how to get the main.as to listen to the external swf being loaded in, then record a function from within the external swf's document class.

Passing Global Variable In External Class Files
I have main.swf which has an accompanying main.as file where all code lives. This code loads a separate pictureGallery.swf into an empty movie clip. The pictureGallery.swf also has it's own pictureGallery.as file where it's code lives. On a button release, I'm setting a global variable in the main.as and loading the pictureGallery.swf. For some reason the variable is not accessible in the pictureGallery.as file. Any idea why it's not passing between .as files?

Problem Accessing Main Timeline Textfield From External Class
Hello,

I'm having a real hard time trying to work this one out. I'm pretty new to AS3 and OOP in general, but I'm slowly progressing.

I have an uploading class that I have made that uploads mp3s to a server, that works fine, the problem I'm having is inputting information about the file into a textfield that is located on the main stage. I can't work out how to refer to it properly, as the old AS2 method of dot syntax doesn't work.

I had the uploader working fine when it was is in it's own fla and not utilising external classes, and the textfield displayed exactly as I wanted. I just want to get my head round using classes and thus having cleaner, modular code.

I've searched all day and found some stuff that I think might help, such as displayobject and defining root and stage, but I can't really get my head round how to do it.

Here are some code snippets that hopefully you'll be able to make sense of...

The main fla code:


Code:
mUpload.bPlay.addEventListener(MouseEvent.CLICK, uploadFile);

function uploadFile(evt:MouseEvent):void {
var tester:Uploader = new Uploader();
}
and the Uploader.as file code:


Code:
package {

import flash.net.*;
import flash.events.*;
import flash.display.Sprite;
import flash.text.TextField;

public class Uploader extends Sprite{

private var fileTypes:FileFilter = new FileFilter("mp3 (*.mp3)", "*.mp3");
private var allTypes:Array = new Array(fileTypes);
private var fileRef:FileReference = new FileReference();
public var tStatus:TextField;

public function Uploader():void {
fileRef.addEventListener(Event.SELECT, selectHandler);
fileRef.addEventListener(Event.COMPLETE, completeHandler);
try {
var success:Boolean = fileRef.browse(allTypes);
trace("Uploading...");
} catch (error:Error) {
trace("Unable to browse for files.");
}
}
private function selectHandler(event:Event):void {
var fileTypes:FileFilter = new FileFilter("mp3 (*.mp3)", "*.mp3");
var allTypes:Array = new Array(fileTypes);
var request:URLRequest = new URLRequest("http://www.blahblah.com/alive/uploads/uploader.php");
try {
fileRef.upload(request);
} catch (error:Error) {
trace("Unable to upload file.");

}
}
private function completeHandler(event:Event):void {
tStatus.text = "Successfully Uploaded - " + event.target.name + " - " + event.target.size;
}
}
}
I have a textfield that i have created on the stage called tStatus within which I want to display some information once I have uploaded the file.

Any help would be greatly appreciated, for my sanity's sake

How Do You Use A Varible In The Path Of Another Varible In A Condition Statement?
This is part of a load checking script i'm doing

for (i=0; i<split1.length; i++) {
temp = split1[i].split(":");
if (_parent.(temp1).percent == 100) {
trace(temp[1]);
}
}

In this line

if (_parent.(temp1).percent == 100) {

The bit in brackets temp1 needs to be a varible whilst the rest of the path and the varible name needs to be static.

Anyone know how to format the condition like that ?

Referencing Clips On Main Timeline From My Main Document Class
Hi All,

I'm trying to reference clips on the main timeline either in or via my main Document class, but if I declare any clips as public in the class body as I would have done is AS when linking an external class, I get:


Code:
1151: A conflict exists with definition tfLength in namespace internal.
If I don't declare the clip, then I can reference it from within the same class with this.tfLength, but other classes complain it the Document classes tfLength variable doesn't exist!

So how do I reference a clip on the timeline in my class?

Thanks,
Dave

Buttons And Sending Varible From A External MC
I am loading a external MC with a button in it, into a empty container. That button needs to tell a MC on the main to play, and at the end of the MC on the main, I want to unload the container and load the next external MC into the empty container. I tried this code below but with no sucess.
-------------------------------------------
use action for button
on(release){_root.tempvar="external1.swf";}
-----
at the end fo ur mc
loadVariablesNum (_root.tempvar, 0);
-------------------------------------------

How do I tell a MC on the main from a loaded MC what MC to load Next?

Reload Main Class From Within Main Class?
I'd like to just start my whole main class over again if certain conditions arise. The monitoring of those conditions takes place *within* the main class. Is there any way to just tell that class to reload itself -- to call its own constructor -- essentially starting the whole thing from scratch? I found references to doing it the old way -- jumping back the first frame of the main timeline, for instance -- but I'd like to do it in a more OO/AS3 sort of way.

Thanks.

Calling A Function In Main Class From A Loaded Swfs Document Class
Hi
I have a main.swf that loads page.swf. They each have a document class called "Main" and "Page".

How can I call a function in Main from Page?

In AS2 this would be somthing like _parent.myFunction();


Cheers

Main Mc Loads External Swf, Then Main Swf Buttons Stop Working
I have a portfolio site that I am building. The main site swf has a navigation menu, and a empty movieclip. Each of the buttons on the menu calls up an external swf to load into the main empty mc. When you click on 'home', the 'home' swf loads.. when you click on 'about', the 'about swf loads, I can switch between them, no problem.

This is where my problem comes in... I just created another external swf that has a gallery in it. The gallery consists of thumbnails and a larger image that are calling from an XML file. When this swf loads into the main mc, everything is fine. But then, the buttons on the main swf menu stop working! The buttons all work going between one another, except when you load the gallery and then you can't go anywhere else. Help!

let me know what code you need, if any. MUCH APPRECIATED in advance :)

example of whats happening:

http://christinevanetten.com/index2.html





























Edited: 04/18/2008 at 08:30:55 AM by christineski

Main Flash Loading External Swf Then Back To Main
SOLVED



Heres a rather complicated situation I am in.

I put together an after effect file and exported it as an swf. Work perfectly. There is no FLA


In my flash file, frame 1 is a preloader. Frame 2 is an Action script that says

loadMovieNum("page1.swf", 1);


And voila, the movie start to play.


Problem is, it doesn't go back to the main on frame 3.




Solution-
Using sorenson squeeze theres an option to load/unload movies that you compress into swfs. There was a stop at the end of my movie with no fla file.

Preloading External .swf's And The Main .swf All In The Main .swf's Preloader
Hello everyone

My question is would anyone know how to preload external .swf's and the main .swf all in the main .swf's preloader? All feedbacks are welcomed. Thank u.

toneDigital

HOW TO PRELOAD MY MAIN SWF (not External Files But My Main)
I've done a main.swf that i use as a big container for my website, in this main.swf i used the document class, where i import all the classes that i need for my interface and i load all the sections from externals .swf, preload this sections is not a problem, but i have this problem: how can i preload my main.swf if i have to put the code for the preloading into the document class, that is not working till its loading is not complete!?!?!? i mean it is like to say to the same object that i'm loading to check the loading of itself, the methods aren't be instanced, so.. looks not possibile to me.. wich way to follow?

Passing Var From Main Timeline To Mc
I'm trying to access info in a mc from an external class. I can get the info on the main timeline, but can't access it from the mc. Here's what I have on the first frame of the timeline:


Code:

var m:TesterMake= new TesterMake();
var mcAlf:Number;


var timer:Timer = new Timer(1000,0);
timer.addEventListener(TimerEvent.TIMER, numTimer);
timer.start();



function numTimer(t:TimerEvent):void{
var mcAlf= m.alfaNum;

}
In the first frame of the mc (in the same fla) , I have tried


Code:

lines.alpha=mcAlf;
as well as

Code:
this.mcAlf
and pretty much every combination I could think of. I also tried just doing it all in the mc and not on the root, but just get an error saying that m is not defined. What am I missing here? Thanks in advance. Still trying to learn this all!

Passing Variable From MC To Main Timeline
I have 2 frames in my main timeline both with stop actions. The first frame has a movie which is basically an intro. At the end of this intro movie i wanted to specify a variable so that the main timeline would play to frame 2. It seemed simple enough with the _global setting but i cannot get it to work with that or _root. In my main timeline in the first frame i have:

if(z < 13) {
stop();
}else if(z == 13){
gotoAndStop(2);
}


In the MC that sits in the first frame I've tried:

_global.z = 1;
_root.z = 1;

at the end of that MC but neither of those pass varibles to the main timeline (i've been using trace). I'm starting to think my Flash MX is posessed because i've read posts on this board which say how to use global variables but it isn't working for me. Please help. I've spent too many hours on this one problem.

Thanks!

Passing A Variable To The Main Film
hello,

i am loading a swf into my main movie using the loadMovie command. now i want my main movie to stop whilst the laoded movie is paying and once the loaded movie has reached a certain position, i want my main film to go to lets say frame x.
i tried defining a variable in my loaded swf
if(....){
(_root.mainPlay = true;
}

and then in the main film

if(_root.level1.mainPlay == true){
gotoAndPlay(x);
}

but it doesnt seem to work at all, what am i doing worng

thanks and ciao...

MC's And Passing Vars To Main Timeline
Ok, I think I am doing something stupid. Here's the story. I have a movie that is 4 frames long. On the first frame there are input boxes and when values are entered and the submit button is clicked, they get passed to the 2nd frame and things happen...works great...until...

I wanted to allow the user to print each frame separately, so I added a print button to each frame and labeled each frame with #p. So, in order to print ONLY the first frame from the print button on that frame, I was forced to put everything on frame 1 into an MC. Now that I've done so, none of the vars are passing to the second frame.

I went into the code on the second frame and added _root.frame1.blah so it knows where to get it, but still nothing.

Like I said, I am probably just doing something stupid, but can't figure out what. So there are probably a few answers to this question. I could either figure out how to "target" the vars, or figure out a better way to print. Which is easiest? Thank you in advance.

Help With Variable Passing To Main Timeline
on main timeline, I declared a varibale;

var nextSection:String;
nextSection = "sample1";

and I have a MC with 20 frames
on the 10th frame

parent.content_mc.gotoAndStop(parent.nextSection);

but I am getting all sorts of errors,

1119: Access of possibly undefined property nextSection through a reference with static type flash.displayisplayObjectContainer.

would some-one explain why this is and how I can correct it ?

attached the fla also.

Thanks in advance.

Passing Info Between Main Swf And Flv Control Swf
I'm making a custom video player, and I'm using one of the skins thats ships with flash to control it, but customising the graphics, as I thought this would be a better option that having to worry about my own buttons moving out of position in fullscreen mode. This is going fine, however, I have to make the buttons so they can have their colour changed by means of a variable, passed in through flash vars, or possibly a query string. I think I'm ok with getting this value into my main swf, but I'm not sure how to pass this variable to the skin swf. this swf is not referenced in the html, so how would I pass it from the main swf? I've tried a few methods of referencing it from the root of my main swf, but no joy.

Passing A Variable Change From A MC To The Main Timeline. Help?
I want to change the status of a variable that has been introduced on the main level, from a movie clip!

The variable is 'fin' , the variable fin is set to NO when a button is rolled over (which starts a movie clip), I DONT WANT ANYOTHER BUTTONS TO WORK UNTIL THAT MC IS FINISHED PLAYING...

SO at the end of that movie clip I want to change fin to "YES" ,

HOWEVER, of course the normal fin="yes" didnt work and neither did _root.fin="yes" ....can someone please help me?

thanks ! tv

Q: Passing A Variable From A Loaded Swf To Main Timline?
Hello,

I have a main movie that contains a movie clip called "music track". I then load a streaming music swf file called "fileM1.swf" into the clip "music_track". Now I have numerous songs that load into "music_track", at the end of each fileMxxx.swf I've added a command to load the next file. So on the last frame of fileM1.swf it reads "loadMovie("fileM2.swf", "_parent.music_track");" and so on for each fileM. Everything so far works great..

Here's my problem. I need to pass a number variable from the song swf files (fileM1.swf etc) to the main timeline. However because these are external files I can't seem to get it to work. I've been working on this for the past 4 hours and no luck. I tried passing a global variable from the loaded swf to the main movie but because they aren't link parent to child (only "music_track" movie clip has a child parent relationship with the main timeline not it's contents) the variable doesn't seem to get passed.

At the begining of each loaded song file (fileM etc..) I have:

_global.songcount = xxx;

Where x is a different number each time. I need to somehow pass that value back to the original timeline. Does anyone know how to do this?

Thanks in advance.
Monk

PS I can't pass the variable when the movie is loaded because this is a streaming file.

Passing Variables From A Loaded Swf Back To Main?
Hey, I need help trying to pass a variable, actually change a text field - from a loaded variable into a text field on the main flash file...

Here's the script i'm attempting to use:


Code:
unloadMovieNum(66);
loadMovieNum("[url location]", 66);
_root.artist.text = "[artist name]";
_root.song.text = "[song track]";
_root.album.html = true;
_root.album.text = "";


This is at the end of a steaming mp3 swf, which loads the next track and displays the next information of the track - should I change _root to _parent or create a _global variable on the main source?

THANKS IF YOU CAN HELP!

ps - text in [brackets] is just a filler for the real text i'm using, it's not a variable.

Passing A Variable From Preloader To Main Movie
So here's my issue, and I suspect the answer is really simple, but I tried the simple way and that didn't seem to work. Basically I have an HTML file that loads a preloader SWF "loader.swf" this preloader then loads up the main movie called "ccc.swf". Now the deal is that the HTML file sends a variable to loader.swf when it loads up, and I need that variable then passed on to ccc.swf.

I have tested and confirmed that the var chosenUnit exists in _root of loader.swf...now how do I pass it along...

BTW, I have already tried a simple:
_root.container.chosenUnit = _root.chosenUnit
I placed this code in three different locations within my preloader code and it still didn't work.

here is the code in the preloader:

code:
// Hides displayed elements
this.reelmc._visible = false;
this.loadbar._visible = false;
percent_display = "";
//create a new movieclip to load
//the external movie into
this.createEmptyMovieClip("container",10);
//load the external movie into the new movieclip
container.loadMovie("ccc.swf");
//check the download status of the external
//movie once every frame
this.onEnterFrame=function(){
//trace the percentage of the movie that has loaded
percent=(this.container.getBytesLoaded()/this.container.getBytesTotal())*100;

if(!isNan(percent)){
// trace(percent+"% loaded");
if (percent == 0) {
percent_display = "";
} else {
percent_display = Math.ceil(percent) + "% LOADED.";
}
this.loadbar._visible = true;
this.loadbar._xscale = percent;
if (percent > 1) {
this.reelmc._visible = true;
}
container.stop();
} else {
// trace("0% loaded");
}
if(percent == 100){
delete this.onEnterFrame;
this.reelmc._visible = false;
percent_display = "";
this.loadbar._visible = false;
loadMovieNum("ccc.swf",0);
}
}
stop();


Let me know if you have any ideas! Thanks!

chigasakigaijin

Passing Variable From Main Movie To Loaded Swf?
hello all,

i am using flash cs3,i have a main movie that load many swf using a document class..

i need to pass "userid" variable from the main movie to loaded swf so they can change their content dynamically,i need your help



thanks in advance



cheers;

Anthony youssef

Passing Variable From Main Movie To Loaded Swf?
hello all,
i am using flash cs3,i have a main movie that load many swf using a document class..
i need to pass "userid" variable from the main movie to loaded swf so they can change their content dynamically,i need your help

thanks in advance

cheers;
Anthony youssef

_global? - Passing Var From Loaded Movie To Main?
This might be really simple - but i can't seem to figure it out!

I've got my main movie [background] which loads in a swf via loadMovieNum. I'm desperatly trying to get the loaded movie to pass a variable [lets say just change the .text of a field] to the main movie - background.

I've tried _global variable [although i'm not sure i'm using them correctly ] and all variations of _root / _parent.

I'm at a loss!

Like i said, i'm sure this is really simple....i just can't see the solution.

any help at all would be great!

Passing Variables From The Main Timeline To A Movie Clip.
Hi. I have (successfully) taken variables from a txt file and had them display in some dynamic text boxes on the main timeline of my movie, BUT, I would like them to show in a movie clip (within that movie) instead of showing on the main timeline/movie. The movie is here (the variables aren't shown there) and what I wanna have done is have the variables load up in the main timeline, but when the user presses the launch shoutbox button, I want the variables to be shown in there, get me? So how would I go about passing the variables from the timeline to that movie clip?
Thanks in advance, Chris.

Passing A Variable From A Movie Clip To The Main Timeline
Hi,

I'm having trouble passing a variable from a movie clip in my flash file to the main timeline.
I have a movieclip with the instance name IntroNav which contains several buttons. Clicking a button sets the variable "page" to a specific name, i.e. page = "home"
However, outside of the movie clip, on the main timeline I am unable to call this variable, and "page" seems to have no value.

Can anyone tell me why this is and how to solve it?

Thanks

Passing Variables From A Loaded Movie Clip To Main?
All,

Not sure why this is beating me up, but it is...
I can't seem to load a movie clip, and then pass some variables from that loaded movie clip back to through stage_mc it is loading into - to the SubClip.

The structure is as follows:

Main
>SubClip
>>Stage_mc

Where the new movie clip is loading into stage.

I need to pass two variables from the loaded clip into the SubClip.
Simple vars to fill some dynamic text in SubClip.

Any help or a push in the right direction would be appraciated.

I've done the whole _root.myvar thing, _parent, and _global.
without luck..

Thanks!

Problems Passing Variables From Popup To Main Window With Netscape
I'm trying to pass a variable from a popup window to the main window using javascript. Then having a .swf in the main window catch the variable are react to it. It works perfectly in IE. Here's the code:

================================================== ==
PopUP Window

Head

function passFlash(){
window.opener.movie.SetVariable("text", "musicOn");
parent.close();
}

Body
<a href="#" onMouseOut="MM_swapImgRestore()" onMouseOver="MM_swapImage('Image2','','images/pop_yes_on.gif',1)" onClick="passFlash()"><img name="Image2" border="0" src="images/pop_yes_off.gif" width="97" height="34"></a>

<a href="javascriptarent.close()" onMouseOut="MM_swapImgRestore()" onMouseOver="MM_swapImage('Image3','','images/pop_no_on.gif',1)"><img name="Image3" border="0" src="images/pop_no_off.gif" width="103" height="34"></a>



Main Window

Body

<object classid="clsid27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=5,0,0,0" width="200" height="50" id="movie">
<param name=movie value="movie.swf">
<param name=quality value=high>
<param name="name" value="movie">
<param name="swLiveConnect" value="true">
<embed src="movie.swf" quality=high pluginspage="http://www.macromedia.com/shockwave/download/index.cgi?P1_Prod_Version=ShockwaveFlash" type="application/x-shockwave-flash" width="200" height="50" name="movie" swliveconnect="true">
</embed>
</object>


==================================================

Any ideas? Thanks in advance.

Passing A Variables Values From A Movie Clip To The Main Stage
Hi all,

Newbie here. I have been studying up a storm but the learning curve is steep.

I'm perplexed by passing variables from a movie clip to the main stage.

I have a movie clip with an instance name mc1 on the main stage. In that movie clip I declared a variable

c = 5;

on the first frame inside the mc1 movie clip.

I thought I could access that variable inside mc1 from the main stage by placing this on the first frame of the main stage:

x = _root.mc1.c;

Obviously I don't understand what is going on in terms of scope of variables because I keep getting an undefined statement in my variable x.

Some insight would be appreciated.


__________________
Thanks,
Greg

Passing Xml From Class
Well i used to be an average AS2 developer, but thanks to AS3 I feel like I should be back in the newbie forum.

I'm trying to import some xml data to display in some lists. I've got a class that imports the data ("Stage1") and a movieclip ext class ("S1Menu") which generates the list components, but I can't get the xml data from Stage1 to the stage to S1Menu. I've traced the data in Stage1 and it returns the properly formatted xml data (see Stage1::ExecStage1()), but when I try to export it from Stage1 to the stage either as xml or an xmlstring, the result trace is blank (no error, just blank) (see fla traces and Stage1::GetData(). I've done some OOP in PHP, but am still relatively new to OOP design patterns. Any help appreciated.
Here is some code:
fla:Frame 1:
Code:
var s1 = new Stage1();
s1.LoadStage1();


//trace(s1.s1_data);//no result, but shouldn't because it is xml format
//trace(s1.s1_data.toXMLString());

//var md:XML = s1.s1_data;
//trace(md.toXMLString());//no result

//var md:String = s1.GetData();
//trace(md);//no result

var s1m = new S1Menu(s1.s1_data);
addChild(s1m);
s1m.x = 10;
s1m.y = 9;


Stage1 class:

Code:
package{
import flash.display.*;
import flash.events.*;
import flash.net.*;
import fl.controls.ComboBox;
import fl.controls.Button;
import fl.controls.Label;
import fl.controls.List;
import fl.data.DataProvider;
import flash.text.*;

public class Stage1 {
public var req_stage:Number = 1;
public var req_type:String = 'packets';
public var path:String = 'http://localhost/itemsdev/summary/fl/';
public var data_script:String = 'dataProvider.php';
public var errorText = new Error();
public var out:String;
public var s1_data:XML = new XML();
function Stage1(){}
public function LoadStage1(){
var url_request:String = path+data_script+'?stage=1&type='+req_type;
var send_url:URLRequest = new URLRequest(url_request);
var receive_url:URLLoader = new URLLoader();
receive_url.addEventListener(Event.COMPLETE, ExecStage1);
receive_url.addEventListener(IOErrorEvent.IO_ERROR, loadIOError);
receive_url.addEventListener(SecurityErrorEvent.SECURITY_ERROR, loadSecurityError);
receive_url.load(send_url);
}
private function ExecStage1(event:Event):void {
var loader:URLLoader = URLLoader(event.target);
s1_data = XML(loader.data);
//trace(s1_data.toXMLString());//returns properly formated XML
//out.text = 'Response:'+s1_data.toString();
}
// Handler for IO error
function loadIOError(event:IOErrorEvent):void {
// output errors to trace
// window and errorText field
trace("IOError: "+event);
errorText.text = "IO Error: "+event;
}
// Handler for security error
function loadSecurityError(event:SecurityErrorEvent):void {
// output errors to trace
// window and errorText field
trace("SecurityError: "+event);
errorText.text = "Security Error: "+event;
}
public function GetData():String{
return s1_data.toXMLString();
}
}
}

S1Menu class:

Code:
package{
import flash.display.MovieClip;
import fl.controls.List;
public class S1Menuextends MovieClip{

public var menu_data:XML;

function S1Menu(md){
menu_data = md;
generateMenus();
//trace(menu_data.toXMLString());
}
private function generateMenus(){
var row_ct = 0;
var col_ct = 0;
}
}
}


Thanks in advance.

Import Main In Class
I'm wondering if this would work and if it does if its bad programming practice or not. I am trying to do things right and don't want to develop bad habbits...anyway if I have a class with a button and I want that button to call a function in main (the main document class) could I import main to that class so it has access in a handler to call the function in main? I'm trying to figure out a way to have button panels (a message I left here earlier) control different aspects of a game, ie..startOver, Quit, etc...I know I can create the buttons in main and it will work but I want to encapsulate them in functional 'button' panels. Since the main functionally of the game lies in 'main' how can I encapulate the button panel(s) with the appropreate buttons to control functionallity in main? I'm not looking for someone to give me the code...just someone with more Class knowledge to steer me in the right direction. THANKS!

What Should I Do When My Main Class Becomes 600+ Lines?
I was using cs4 as my IDE, so i switched to flashdevelop which helped alot...

I guess i'll have to try break it down into more/smaller classes?
which is gonna be a pain...

I already have a class that gets extended like 3 times...

bitmapData -> buffer -> collision buffer -> level

I guess i'm gonna have to just bite the bullet, and try and grind down the other areas of my code...

Unless someone has a genius idea for me..

(made this thread so i can sulk and b**** about my over sized project )

Loading External SWF From External SWF Onto An Empty MC On Main Timeline?
Hi Everyone,

Please bear with me while I explain. I have an external swf that loads into a frame in the main timeline, into an empty MC. I can do this just fine. Once this clip is loaded, I have a button in this clip that loads another external swf into a different empty MC on the main timeline. I'm using loadMovie, and I need to load these movies into specific empty MCs. In other words,

I have the following:

MainStage: frame 5, contains empty MC "ClipA"; frame 6, contains empty MC "ClipB"
External swf: "Movie1"
External swf: "Movie2"

"Movie1" goes into "ClipA" of frame 5 on Main Timeline; and "Movie1" has a button that loads "Movie2" into "ClipB" of frame 6 on Main Timeline. I need help loading "Clip B" into "Movie2" from a button in "ClipA."

I'm sorry my message is so roundabout - it's not really a complicated situation, but explaining it makes it seem so.

Thank you in advance for any help - I'm assuming it's some sort of _root or _parent issue things I'm not quite understanding.

Thanks!
macgirl

Trigger External Swf To Load Into Main Swf From Button In Another External Swf
I'm really stuck with this and it seems like such a simple problem to solve.

I am trying to get a nav button in one movie (main_nav.swf) to target a my main movie (index.swf) and load a sub nav movie (metals_subnav_infinite.swf) into it. The sub nav movie will do a similar task - loading a portfolio swf into main movie (index.swf).

Here is the file breakdown of my working files:

index.swf - main final movie which loads "main_nav_infinite3.swf" on start

main_nav_infinite3.swf - loads main nav "main_nav.swf" and scrolls it infinitely (infinite menu)

main_nav.swf - main nav with buttons that trigger sub nav "metals_subnav_infinite.swf" to load into index.swf

metals_subnav_infinite.swf - loads sub nav "metals_subnav.swf" and scrolls it infinitely

metals_subnav.swf - sub nav with buttons that trigger "folio.swf" (have not created this file yet!) to load into "index.swf"


The script I was focusing on is in main_nav.fla and it is:

metals_mc_bn.onRelease = function() {
reActivateMenu();
this.gotoAndStop(3);
this.enabled = false;
_level1.sub_nav_content_mc.loadMovie("metals_subna v_infinite.swf");
};

I haven't yet activated all the buttons yet just the "Metals" button as the first to get working.

I have attached the FLAs.


exxie!

Passing A Class Instead Of An Instance
Well,
in game.as

var slug = new bullet(alien,this.ship.x,this.ship.y);
this.addChild(slug);

in bullet.as
var alien:MovieClip;
public function bullet(hitTestObject:MovieClip,shipX:Num ber,shipY:Number){
alien = hitTestObject;
this.x = shipX;
this.y = shipY;
this.addEventListener(Event.ENTER_FRAME,
bulletMove);
this.addEventListener(Event.ENTER_FRAME,
bulletHit);
this.addEventListener(Event.ENTER_FRAME,
checkY);
}

public function bulletHit(event:Event){
if(this.hitTestObject(alien)){
alien.parent.removeChild(alien);
clearListeners();
}

}

So is there any way I can pass a reference of the alien class into the constructor of the bullet class, because I want all bullets to look for all aliens.

Passing A Class Instance To A MC
Hi guys, ehm... I know I'm quite late but...

I'm going to rewrite a 10.000 lines app wrote in as1, in as2. And soon, I've just found out that's still impossible to "connect" MCs to classes... I'll be more clear; writing:


Code:
_level0.attachMovie("libName","pippo",10, new myClass(initVal,[otherStuff]));
I can't call myClass methods in the MC. MC inherited ONLY myClass properties, not methods.

please tell me I'm stupid, tell me I miss something!...

ciao

Passing A Class Instead Of An Instance
Well,
in game.as


ActionScript Code:
var slug = new bullet(alien,this.ship.x,this.ship.y);
this.addChild(slug);

in bullet.as

ActionScript Code:
var alien:MovieClip;
public function bullet(hitTestObject:MovieClip,shipX:Num ber,shipY:Number){
alien = hitTestObject;
this.x = shipX;
this.y = shipY;
this.addEventListener(Event.ENTER_FRAME,
bulletMove);
this.addEventListener(Event.ENTER_FRAME,
bulletHit);
this.addEventListener(Event.ENTER_FRAME,
checkY);
}

public function bulletHit(event:Event){
if(this.hitTestObject(alien)){
alien.parent.removeChild(alien);
clearListeners();
}

}

So is there any way I can pass a reference of the alien class into the constructor of the bullet class, because I want all bullets to look for all aliens.

Passing Parameters Into A Class
I am trying to pass parameters into a linked Class but am getting an error:
There is no property with the name 'testNum'

What I have is an instance of a MovieClip symbol. I have attached an actionscript to this instance...


Code:
onClipEvent (load) {
this.testNum = 10;
trace(this.testNum);
}
The trace shows the correct number.

The symbol is also linked to an external Class file called TestClass.as which contains the following code...


Code:
class TestClass extends MovieClip {
// Constructor
function TestClass() {
trace(this.testNum);
}
}
This is what throws back the 'no property with the name' error message.

Can someone explain why the properties defined on the clip don't translate across into the Class file?

And is there a 'best practice' way of having unique properties on multiple clips all accessing a common Class file?

Thanks.

Passing Variable From One Class To Another
hi everyone. i've been reading the kirupa tuts for a while now, but recently just signed up for the forum as well.


well, i'm getting into flash classes, and i'm working on my first project using self written classes. but i got a question about variables.

i've got a MC rad_container with the class Rad linked to it. By using class instances i can now send the variable from the MC to the class, and get it returned.

but i want to use the same variable in another MC ball_container with it's own class Ball.

how do i do that exactly ?

here's my class Rad


Code:
class Rad extends MovieClip {



public var ballKleur:String;
public var radKleur:String;



// constructor

public function Rad(radKleur:String) {


ballKleur = radKleur;
//trace (ballKleur);

}



public function get dezeKleur():String {

return ballKleur;




}


public function set dezeKleur(radKleur:String):Void {

ballKleur = radKleur;


}



}
and here's the code i'm using in my MC rad


Code:
var myRad:Rad = new Rad("groen");
thanx!

Copyright © 2005-08 www.BigResource.com, All rights reserved