Accessing Variable From Frame With Button In Flash
Mar 24, 2011
I am a beginner in Flash development and I was just recently assigned to fix an old Flash project at my work. Essentially, the application is a video booth whereby users can record up to 60s of video via their webcam and then share it either via email, twitter, or facebook. When the application is started, a video ID is generated, and that is used as the video's file name when it is streamed and saved to the server. I am sure there is a better way to do this, but the way I came up with is to grab that video ID and pass it to the "Share" page as a URL variable, and then use that to access and share the video from the server. How I can access the video ID from the button that is sending the user to the "Share" page.
Here is the code:
var nc:NetConnection = new NetConnection();
var ns:NetStream;
var cam:Camera;
var mic:Microphone;
var vidId:String = configName();
function tracer(p_s) {
[Code] .....
View 1 Replies
Similar Posts:
Dec 12, 2011
Background: I have a project where i need to create multiple objects that consume the same base calss from an external .as file. each of the individual fla files that consume the base class need to pass a variable to the base class so the class can return information specific to the fla.
My question is,if i have an external class path set up, how do i get a variable on the first frame of the movie to be visible to the base class && how do i call upon its value from within the class.
View 2 Replies
May 10, 2010
I have a 20 frame movieclip (named mc), and by default the playhead is stopped at frame 0 of that movieclip. At frame 10 I have a movieclip instance there named "apple". Now I want to tell mc to go to frame 10, and immediately access "apple" movieclip. This is what I do (from the main timeline):
mc.gotoAndStop(10);
trace(mc.apple);
It prints out null (appled is undefined). However, when I put a timer (say of 5 milliseconds) before calling the trace statement, then it works and can access apple. I don't want to rely on timers, since the timer duration depends on different circumstances. At the same time, I do not want to put code anywhere except the first frame of the main timeline.
View 9 Replies
Feb 8, 2010
I've beein digging forums everywhere but cant find the solution to my problem...
I have an external swf "advert_3.swf" loading into the main index.swf.
advert_3.swf has two buttons: one needs to go to "services" frame the other to "events" within a content_mc which is in the index.swf.
that is in the index.swf:
ActionScript Code:
var request:URLRequest = new URLRequest("advert_3.swf");
var loader:Loader = new Loader();
loader.x = 35;
[Code].....
View 1 Replies
Sep 15, 2011
I'm pretty new to AS3 but I want to get my buttons to play the same movie then go to their button function. i.e., Picture button > play movie (same as all buttons) > picture frame.
This is the code on my buttons
ActionScript Code:
stop();
import flash.display.MovieClip;
import flash.events.MouseEvent;
var currentButton:String;
[Code] .....
Then at the end of the movie I tried using a variable to link the button to its frame
ActionScript Code:
stop();
if (currentButton == name) {
content.gotoAndStop("music");
} else if (currentButton == name) {
content.gotoAndStop("book");
} else if (currentButton == name) {
content.gotoAndStop("stereo");
}
I know the scripts messed up but not sure I really get the variable thing as yet.
View 2 Replies
Apr 17, 2011
how can i access a movie clips variable from its parent...??? i've done alot of way but still failed,
View 2 Replies
May 24, 2011
On the stage I have a movieclip by the name of rect_mc. Inside it have have a MovieClip sqaure_mc.
In the time line that I get when I double click on rect_mc (timeline of rect_mc) I have written the following code
var width1:Number;
width1 = sqaure_mc.width;
How can I access width1 from the document class?
View 1 Replies
Apr 10, 2009
accessing swfObject variable within Flash...
View 3 Replies
May 24, 2011
On the stage I have a movieclip by the name of rect_mc. Inside it have have a MovieClip square_mc.In the time line that I get when I double click on rect_mc (timeline of rect_mc) I have written the following code
var width1:Number;
width1 = sqaure_mc.width;
How can I access width1 from the document class?The thing that I want to is access the variable declared (width1) in the timeline of rect_mc. Just for the sake of a example only I choose the width of MovieClip.My doubt is how can access a variable declared inside the timeline of rect_mc from the document class. It could be any variable.My document class is:
package
{
import flash.display.MovieClip[code]....
View 1 Replies
May 31, 2011
I want to find out whether my swf was loaded locally or from another swf. For this purpose I have declared a variable 'parentType' in my fla. var parentType:String = String(parent); There is a function in the document class that determines whether swf was loaded locally or from another swf. The name of the function in the document class is 'externalOrInternal'. The varaible parentType is passed as a parameter to the function externalOrInternal externalOrInternal(parentType); The name of the document class is Main. In the constructor of Main I have the function pollResize() (the use of this function is to listen for the resizing event. That part of the code is not shown in the snippet given below).
[Code]...
I see that swfParentType is has value insde the function externalOrInternal. My doubt is why null is traced inside the function pollResize. Why is it not [object Stage] as inside externalOrInternal. Due to this I am not able proceed further with the stage resizing event.What needs to be done so that proper value is traced in the function pollResize.
View 1 Replies
Jun 14, 2004
I have three buttons: each one changes a variable to a name: one, two and three and plays the movie.when the movie gets to frame 100, it should get the variable and play the label with the same name of the button...How should be the AS of this frame so it plays to the correct label?
View 1 Replies
Nov 5, 2010
I have been searching for a resolution to this for weeks but to no avail. I have made a game already where I had a character names mainChar placed on the screen using the Flash IDE. With this method, i was able to access it's various nested movieclips such as mainChar.walk and mainChar.jump. The problem is that I am making a new game where the main character is loaded via external code using hero:mainChar = new mainChar(); in the external file. after this, i would like to check what the current frame of a nested movieclip is. for example, hero.walk.currentFrame. however, by initializing it using the external code, as opposed to my previous method of placing it right on the stage, the compiler is not picking up of hero.walk.currentFrame stating that "a term is undefined and has no properties (error type 1010)". Is there any way for me to let the compiler know that the nested movieclip is there. It's odd because i can state hero.gotoAndStop("walk"), but when i say hero.walk it gives an error, so i know it isnt spelling.
View 4 Replies
Nov 20, 2006
I have a problem where I have declared an onRollOver event handler on frame 5. I also have a button on frame 4 telling flash to go to frame 5.But, if the mouse is already over the movieclip on frame 5, the rollover event will not play.Is there a way to force this onRollOver or another workaround for this?
View 1 Replies
Apr 7, 2011
I want to dynamically load the graphic of the button into an mc inside each frame of the button (up and over). Inside each frame I have a movie clip (canvas and canvas_over). The green box is the button object (header_btn):
This is my code:
var hLoader:Loader = new Loader();
hLoader.contentLoaderInfo.addEventListener(Event.COMPLETE, hLoaded);
hLoader.load(new URLRequest("[URL]"));
function hLoaded(event:Event):void {
[Code] .....
It would be nice though if as3 allowed for buttons to contain objects.
View 1 Replies
Dec 28, 2011
I am trying to access a button inside an external swf file that I loaded. Problem is every time I try to access this button I get an error saying that it's null!
Here is my code:
public class DocumentClass extends Sprite
{
public var loader:Loader;
public var swfFile:URLRequest;
[Code].....
Now this should work, code-wise I think its correct. The problem is that loader cant find the required button. There is indeed a button in the loaded movieClip with an instance name of "button", I double checked that.
[URL] basically i was just a layer too high and this is why i couldn't access anything..
View 1 Replies
Nov 25, 2009
Ok, so I made a custom class, but I did not want to add all the text to it through code (much easier to type it in flash on the frame). I name the instance aScoreBoard.
As my code runs, I need to call some of the functions that are part of the ScoreBoard class. As the code gets to this point, I try this line:
aScoreBoard.UpdateScores(passArray);
which will update the scores on the scoreboard. When that line in AS3 tries to execute, I get this error:
TypeError: Error #1009: Cannot access a property or method of a null object reference.
at Main/Main:ayEnd()[C:projectsDev_LearningLongJumpsrcMain.as:616]
at Main/Main::ButtonAfterJump()[C:projectsDev_LearningLongJumpsrcMain.as:606]
Is there a way to do things this way? or will I have to go and do all the extra text entering in the code?
View 2 Replies
Mar 15, 2010
Lets say I have a movieclip on the stage.
On the stage on frame 1 I define a variable. Lets say its a string that reads "hello".
Now in my movieclip on stage I am trying to trace that string I defined on frame 1 on the stage. How can I make this happen?
I have tried a few things but I can't seem to get it working right.
View 1 Replies
Sep 15, 2008
I have a problem accessing a variable loaded from another swf. Actually the variable is a singeltone class, which needs to be initialized.It has structure presented in the last part of the message.The project has the following structure:
- main.swf - this loads all the other swf files and is their holder.
- assets.swf - contains some common elements and initializes the SingleTone class
- interface.swf - contains some interface elements and needs to use the SingleTone class
- all the three swf files have access to a common class structure, where the SingleTone class is defined.
Now, the problem I have is accessing the SingleTone class from the interface.swf file. If I try to send the SingleTone.singleTone. property parameter to the class I get "Type coercion failed: cannot convert from ClassName@.. to ClassName". If I try to access the SingleTone class directly from the interface.swf file i get "Cannot access a property or reference of a null object...". Both errors I get seem logical:
- if I send a parameter, I send the reference to that object, but the interface.swf file does not have access to the assets.swf domain;
- if I try to access the SingleTone class directly from the interface.swf file, I get the null error because the class is not initialized over the interface.swf domain.
Is there any work arround? I know a simple solution may be to initialize the variable over the interface.swf domain, but what if there is a variable that can only be instantiated in the assets.swf? Can I access that variable from another swf, or can I change the ApplicationDomain?
View 1 Replies
May 25, 2009
I've got two classes running...one is a document class (EgoGame.as) and another is a class linked to several similar movie clips (Ball.as).I'm trying to access a public variable from Ball.as which has been declared in the doucment class EgoGame.as.When I run the test the outputs states the following...1120: Access of undefined property _ballPlaced.Here's my code. What I'm trying to do is remove the event listeners from the Ball.as when the _ballPlaced variable is true, so that the user can't drag and drop the balls after they've been placed in a zone.
Document ClassEgoGame.as
package
{
[code].....
View 3 Replies
Feb 1, 2011
I have a variable declared in AS code on the main timeline, which I want to access from the timeline of an underlying movieclip. How do I do this?
View 4 Replies
Oct 12, 2011
here is the wrong script:
var Var1:int=1;
var Var2:int=2;
var Var3:int=3;
[Code]....
View 2 Replies
Feb 8, 2012
Here is my code in my main timeline:
var loadit = new Loader();
loadit.unload();
loadit.contentLoaderInfo.addEventListener(Event.COMPLETE,mcLoaded);
[Code]....
View 11 Replies
Jan 20, 2009
ActionScript Code:
package
{
//import ....
//First Class
[code]....
A seemingly trivial problem, however, the variable "code" 's value would not change! Note: I've tried to add parameters to the constructor of B, as a way to use B, but I had error of " #1063 - Expected 1 , Received 0" for that one even though I've added parameters to it.
View 3 Replies
Jun 17, 2010
I searched for external SWF and got 500+ results but i couldnt see what i needed.Lets say you have a basic SWF file which contains a ball whose instance name is ball.Is it possible to load this SWF and access ball by name?The issue i have is that lets say you have 12 different heads... I need to load these heads in when required.. but each head.swf has a sprite called skinColor. need my main movie to have access to the skin layer sprite so i can Tween it. SWFs have much more details, but the skin sprite is on the bottom layer... so i cant just "color tween" the entire SWF.
View 1 Replies
Jul 30, 2010
if there is a way to access XML attributes by replacing the actual attribute name with an ActionScript variable?
For example:
Code:
var myXml:XML = <root> <child id="child1" /> <child id="child2" /> </root>;
var propToAccess:String = "id";
trace(myXml.child.@{propToAccess});
As you might expect, this throws a compiler error. Hopefully it gets the point across, though.
View 2 Replies
Sep 25, 2010
I'm accessing my json data like this:
ARRAY[0].data1[0].data2
and it works ,but could I substitute data1 or data2 with variables( strings) so that I can construct this kind of paths dinamically?
View 1 Replies
Jan 4, 2011
I'm having trouble setting up my Ball class so I can set a variable which I can then access in another class later. I'm under the impression you can only do this with a public static var, but when I try to make my variable public static the code doesn't work.
[Code].....
the code checks where the balls are on the screen and moves them onto the square. I want to set a string variable for the direction its moving eg. "right" for the ball that's moving right. I'm not sure how to access this in another class.
View 1 Replies
Jan 4, 2011
I'm having trouble setting up my Ball class so I can set a variable which I can then access in another class later. I'm under the impression you can only do this with a public static var, but when I try to make my variable public static the code doesn't work.
Code:
Select allpackage {
import flash.display.MovieClip;
import flash.events.Event;
public class Ball extends MovieClip {
public var _startX:uint;
public var _startY:uint;
[Code] .....
The code checks where the balls are on the screen and moves them onto the square. I want to set a string variable for the direction its moving eg. "right" for the ball that's moving right. I'm not sure how to access this in another class. Here is a pic of the screen to visualize.
View 1 Replies
Feb 23, 2009
I would like to access an xml node through a variable.
something like the following:
Code:
my_images = myXML.(myVariable.name).IMAGE;
but of course it does not work.
View 2 Replies
Jun 24, 2009
I have successfully loaded an external swf inside my main swf. Now, I'm unable to try to trace a variable of the loaded swf from my main swf....
Code:
// Create site request
var siteRequest:URLRequest = new URLRequest('site.swf'); // 'site-' + siteAmbiance + '.swf'
[Code]....
View 6 Replies