Referencing Author Time Buttons On The Stage?
I have some buttons on the stage that were manually placed during authoring. They all have their own instance names manually assigned already. I need to code them thru my Document Class. How do I get reference to them?
I know how to do this if I am placing them from the library at runtime, but not this way.
Thanks
ActionScript.org Forums > ActionScript Forums Group > ActionScript 3.0
Posted on: 08-14-2008, 03:38 PM
View Complete Forum Thread with Replies
See Related Forum Messages: Follow the Links Below to View Complete Thread
Accessing Author Time Instances By Name
Hi,
I am trying to control the timeline of a movie clip (created at author time) which is nested within another movie clip.I have the flash compiler set to automatically declare stage instances and when I debug, I can see the children underneath the parent object, and they are not null.
I'm using: getChildByName(...) as Movie Clip
But when I try to do anything with the movie clip I get the Error 1009 ...null object reference...The object is does not appear to be null, although FP says it is. Any help or guidance to a resource on this type of thing would be great. Thanks in advance
Help Mixing Author-time Animation With AS
I've been doing a fair bit of AS, and I thought I had this issue down, but maybe I'm too tired to get this right.
I'm trying to use some hand-built animations using objects and tweens on the timeline, where the animated object is an empty MovieClip. Some animations are movement, others are alpha fades. In the AS code, I am using attachMovie to attach another movieclip from my library to the animated container object.
However, when I run it, the author-time tweens appear to be ignored. The
container does not animate, nor does its attached child movie.
Is there a good resource or example for how to accomplish this. I want to do some complex animations by hand and then reuse them for various photos.
thx,
BR
SwapDepths On An Author Time Movieclip
I have a movie clip on a timeline. On frame 1 it's at scale 100 and at frame 5 it is scaled up. I need to swap the depth of this movieclip at runtime so I am using swapDepths. Before I call swapDepths, if I go to frame 5 the movieclip scales up as it should, but after I call swapDepths on this author-time created movieclip it seems to reset all its properties and now when I say gotoAndStop(5) the movieclip no longer scales up. It's as if a new instance of the movieclip was created at a positive depth level. I am looking for an alternative to dynamically attaching this movie clip because I don't want to hard-code the position and scale values. I am working with some non-programmer artists so I want to make it easy for them to position the movie clip as they see fit without altering the code. Any suggestions? Thanks a lot.
Can You Tell Images Created At Author Time To Load Dynamically?
hello,
I have many images in my movie which I just imported onto the stage and positioned manually, but now the site loads slow. Can I tell all the images to load dynamically with some lines of AS or a publish option or something else or do I have to replace all images with placeHolder-MovieClips and use the loadMovie command to dynamically load the images?
Many Thanks !!
[F8] Embedding For Foreign Languages-runtime And Author Time
oh oh- never thought i would have to ask this...i am doing a site in English, Italian , and French....this word: "Événements" has clearly proven i don't know how to embed fonts outside of Latin English...All i get is nements. Now, i have some text boxes on stage from authoring time, and some created at run time....what do i need to do to cover all bases for all text boxes...it's impossible to say which of the boxes will use words such as "Événements"
or is the problem my xml??
Code:
<menubutton label="Services" sub0="Traductions" sub1="Événements" sub2="Faits sur commande">Service au francaise......you have to put the french things here.</menubutton>
Communicate Between Author Time Created Movie Clips
Hello All,
I am new to AS 3 and need to figure out how get some Movie Clips to communicate with with each other or with the Main timeline (Scene 1) .
I have created two movie clips during author time not dynamically
- a movie clip instance named menu_mc and a movie clip named screen_mc.
Inside menu_mc are buttons that I have 'wired' to communicate with a movie clip on the main stage/main timeline .
How can I successfully reference the 'main' timeline and/or the 'screen_mc' clip.
So far the only thing that works is:
this.parent["screen_mc"].gotoAndStop("flower") ; // <-- (Script is written in a keyframe inside menu_mc)
Any help is much appreciated as this was so easy to achieve in AS 2.
Can You Tell Images Created At Author Time To Load Dynamically?
hello,
I have many images in my movie which I just imported onto the stage and positioned manually, but now the site loads slow. Can I tell all the images to load dynamically with some lines of AS or a publish option or something else or do I have to replace all images with placeHolder-MovieClips and use the loadMovie command to dynamically load the images?
Many Thanks !!
Author Time, Attach Components By Drag And Drop.
I want to build a component that provides a set of behaviors, the component can be added to anyone's library, and then dragged onto any movie clip on the stage in the authoring environment. When dragged onto a movie clip the component is attached to that movie and may add its behaviors to, or modify, the target movie.
Is this possible without asking my users to enter actionscript to make the connections? Any ideas or pointers?
I have not been able to find any concrete examples of something like this in action.
Thanks,
-BarryFM
Can You Tell Images Created At Author Time To Load Dynamically?
hello,
I have many images in my movie which I just imported onto the stage and positioned manually, but now the site loads slow. Can I tell all the images to load dynamically with some lines of AS or a publish option or something else or do I have to replace all images with placeHolder-MovieClips and use the loadMovie command to dynamically load the images?
Many Thanks !!
Runtime Embedded Fonts Conflict With Author-time Text Fields
I've been struggling for a week now trying to find a way to use runtime embedded fonts -- Font.registerFont() -- for runtime created text fields, but still be able to have author-time created text fields in my projects. There are many issues with this. Here is what I have discovered thus far:I can successfully load in a font from an external Fonts.swf and use it to create and display text at runtime.
There does not seem to be any way to specify the use of that runtime loaded font for an author-time created text field.
If I have an author-time created text field on the stage that uses the same font, it completely breaks the use of the runtime loaded font for runtime created text. The way in which this breaks varies depending on the author-time created text field:If the field is a Static text field, runtime created text using the runtime embedded version of the same font does not appear at all.
If the field is dynamic, but does not have its font embedded (using the properties "embed" button), the runtime created text using the runtime embedded version of the same font does not appear at all.
If that text field is dynamic and does have its font embedded, it will create a duplicate entry for that font in the Font.enumerateFonts Array. This is a problem, because Flash will then default to using the version of the font embedded in its own .swf (the one from the author-time text field) rather than the one loaded in at runtime... even if the .swf version of the embedded font doesn't have all of the glyphs required to display the text! So you end up with a runtime created text field that will only display some of its characters.
When there are duplicates of embedded fonts, I cannot find any way to specify which version to use, because they are all referenced only by the original font name.
It seems utterly ridiculous to me that I have the fonts embedded and ready to be used, but that Flash gets all confused by author-time created text fields and thus makes the use of those embedded fonts for runtime created text impossible. Has anyone out there found a solution to these issues? Specifically:
- Is there a way to specify the use of a runtime embedded font in an author-time created text field?
- If there are duplicate embedded fonts (not really duplicates, but with the same fontName, fontStyle, and fontType... so indistiguishable) is there any way to specify which one a text field should use? If there is, I could do a check on each embedded font for Font.hasGlyphs() until I find the one that works and then specify that version.
Thanks in advance for any thoughts!
Referencing Stage From Class
Hello,
I am trying to make my first as3 class based game and so i was wondering if i could get some help. although the game wont have fancy graphics, i just would like to understand the way it works...currently, i am at a point where im getting :
1067: Implicit coercion of a value of type flash.display:Stage to an unrelated type Stage.
in my main file robot.fla, im using
var robo:robot=new robot(stage);
//var starenemy:enemy1=new enemy1(this.stage);
addChild(robo);
inside that robot.as
....
public class robot extends Sprite {
import flash.display.Stage;
private var _stage:Stage;
....
public function robot(stageRef:Stage):void {
_stage = stageRef;
...
}
amongst other things and i cant reference anything from the stage.
I think im going nuts trying to figure out how to correctly reference things to the stage. so can you take a look and guide me and tell me how i can proceed?
Attached is the zip file
Referencing A MovieClip On Stage Through XML
Hello.
I have a swf with several MovieClip instances on the stage at authoring time. For example, say I have mBuilding that contains mFloor, that in turn contains mAppartment.
I have an xml file that contains data so the swf knows what to do with the MovieClips.
Code:
//xml
<my_data>
<movie_clip1>mBuilding</movie_clip1>
<movie_clip2>mBuilding.mFloor</movie_clip2>
</my_data>
//flash
//xmlMovies is the variable contaning xml data
trace (this[xmlMovies.movie_clip1]); //correct
trace (this[xmlMovies.movie_clip2]); //"... null object or reference..."
I've been trying different things, but I'm still stumped. Can anyone give me some advice?
Thanks in advance.
Problem Referencing The Stage
I'm having a problem that's got me completely baffled. I've got a swf file in which references to the stage give mixed results. When I test the file stand-alone, there are no errors. But when I load it from another swf, I get null object reference runtime errors. I'm referencing the stage at various points in the code, but the null errors occur only at one of those points. When I do
trace(stage)
from the code that lies outside of any function (I'm using free-form code, not a class) I get "null". But when I do the same thing from within a function, I get "[object Stage]". However, if I create a new function and reference stage from within it, I get "null". It seems to me that no matter where you reference the stage within a swf, it should always produce the same results. Am I mistaken?
Referencing Stage From A Child
Hi, I'm making a test game to flesh out my AS3 knowledge. Currently, I have a main class (let's call it gameTitle) that the game runs from. I have several other classes, including GameScreen which is eventually displayed using the addChild method. The third piece of the puzzle are the game controls. This block of code contains a method that requires 'stage' as an argument (it detects keys being held down).
This particular method works fine when it's a part of the main class. I want to move it to the GameScreen class, but I'm having trouble referencing the same 'stage' property from here without getting errors. I've tried parent.stage, but I get the following error message:
TypeError: Error #1009: Cannot access a property or method of a null object reference.
at GameScreen$iinit()
at gameTitle/menuSelection()
I should note that gameScreen is the class where the method is located. And this class is initiated by the menuSelection() method which is located in the gameTitle class.
Referencing A MovieClip On Stage Through XML
Hello.
I have a swf with several MovieClip instances on the stage at authoring time. For example, say I have mBuilding that contains mFloor, that in turn contains mAppartment.
I have an xml file that contains data so the swf knows what to do with the MovieClips.
I've been trying different things, but I'm still stumped. Can anyone give me some advice?
Thanks in advance.
Attach Code
//xml
<my_data>
<movie_clip1>mBuilding</movie_clip1>
<movie_clip2>mBuilding.mFloor</movie_clip2>
</my_data>
//flash
//xmlMovies is the variable contaning xml data
trace (this[xmlMovies.movie_clip1]); //correct
trace (this[xmlMovies.movie_clip2]); //"... null object or reference..."
Referencing The Stage From A Loaded Swf
I am converting my website, which has a liquid interface, to as3 but I am still learning and I have a problem.
I have child.swf that I load dynamically into parent.swf. When I run that I get:
Quote:
TypeError: Error #1009: Cannot access a property or method of a null object reference.
Through trial and error I found that the null object is the child.swf trying to reference the stage at several places such as stage.stageWidth. If I comment all of them out it runs error free, but it also doesn't do anything. I have tried replacing the first 'stage' with other things such as 'root.stageWidth' but no dice.
I was also wonder how I can have a button in child.swf unload itself from the parent.swf?
Referencing Objects On Stage
Ok, this is a dumb question but I'm just horribly stuck.
In my script I go toframe 5, and there are several textfields and clips on stage, but I can't reference them from my code. I get an error saying the objects don't exist.
If I move the objects of stage and just move them into place later that works but I'm pretty sure there is a better way to do it.
Any thoughts or links? I've checked around google but I don't know exactly what I should be searching for here.
Referencing To Stage, From MovieClip
Hi i've got little trouble... First files: http://rapidshare.com/files/12813666...there.rar.html
And now. How i can get from starterClass.as file to stage, and move to frame 2?
Referencing A MovieClip On Stage Through XML
Hello.
I have a swf with several MovieClip instances on the stage at authoring time. For example, say I have mBuilding that contains mFloor, that in turn contains mAppartment.
I have an xml file that contains data so the swf knows what to do with the MovieClips.
CODE//xml
<my_data>
<movie_clip1>mBuilding</movie_clip1>
<movie_clip2>mBuilding.mFloor</movie_clip2>
</my_data>
//flash
//xmlMovies is the variable contaning xml data
trace (this[xmlMovies.movie_clip1]); //correct
trace (this[xmlMovies.movie_clip2]); //"... null object or reference..."
Help Referencing Stage Elements
How do I go about referencing an element on the stage such as a Movie Clip from within a custom class that doesn't extend the movie clip itself.
For example if I have the following document class...
Code:
package classes
{
import flash.display.MovieClip;
import classes.XMLLoader;
public class DocumentClass extends MovieClip
{
public function DocumentClass():void
{
var xml:XMLLoader = new XMLLoader();
}
}
}
and this is my XMLLoader class...
Code:
package classes
{
import flash.events.*;
import flash.net.URLLoader;
import flash.net.URLRequest;
public class XMLLoader
{
var req:URLRequest = new URLRequest("myXML.xml");
var loader:URLLoader = new URLLoader();
public function XMLLoader():void
{
loader.addEventListener(ProgressEvent.PROGRESS, loadProgress);
loader.addEventListener(Event.COMPLETE, loadComplete);
loader.load(req);
}
private function loadProgress(event:ProgressEvent):void
{
var percent:Number = ( 100 / event.bytesTotal ) * event.bytesLoaded;
}
private function loadComplete(event:Event):void
{
var newLoader:URLLoader = URLLoader(event.target);
}
}
}
If I have a dynamic text box with the instance name xml_txt inside a movie clip with the instance name xml_movie on the stage, how can I access it from within the XMLLoader class?
Referencing Movie On The Stage Error
I have a movie_clip_A and a movie_clip_A on the stage.
From a frame in movie_clip_A and using a mouse over event, i'm trying to control movie_clip_B.
I have referenced the movie clip both relative and absolutely:
this.parent.movie_clip_B.gotoandPlay(frame);
root.movie_clip_B.gotoandPlay(frame);
But I keep getting this error. When I click go to source. It jumps to an unrelated line of code all together.
The error is:
1119: Access of possibly undefined property movie_clip_B through a reference with static type flash.displayisplayObject.
What I am not doing correctly? (By the way, i have double checked my instance names and spelling)
Referencing Stage Items From Packages
Take this very basic piece of code:
ActionScript Code:
package {
import fl.controls.Button;
import flash.display.*;
import flash.events.MouseEvent;
public class ControlButton extends MovieClip {
public function ControlButton() {
setupButtons();
trace("buttons setup");
}
private function setupButtons():void {
myPauseButt.addEventListener(MouseEvent.CLICK, pauseButtHandler);
}
private function pauseButtHandler():void {
trace("-- pauseButtHandler: pause/play clicked");
}
}
}
it just traps a button click for a button component on stage.
If you instance it in the document class, directly in the fla, it works.
Instead if you instance it in another class, defined in another package, it doesn't find the button:
1120: Access of undefined property myPauseButt.
for the record, this is how I instance ControlButton:
ActionScript Code:
var cb:ControlButton = new ControlButton();
addChild(cb); // tried with and without this, same thing.
MORALE: What should I do to see a button component on stage from some remote class?
Having A Problem Referencing Objects On Stage ?
Hi everybody,
I am having a problem referencing two objects on stage and telling them to swap depths. I have an object called "illustration" on the stage that has two separate layers inside of it. These two layers hold "illustrationText" and "illustrationTextRed". My problem comes when I try to swap the depth of the two child objects (illustrationText, illustrationTextRed).
The code I placed on the timeline:
PHP Code:
illustration.addEventListener(MouseEvent.ROLL_OVER, onIllustrationOver);
illustration.addEventListener(MouseEvent.ROLL_OUT, onIllustrationOut);
function onIllustrationOver(event:MouseEvent):void
{
root.illustration.swapChildren(illustrationText, illustrationTextRed);
}
function onIllustrationOut(event:MouseEvent):void
{
root.illustration.swapChildren(illustrationText, illustrationTextRed);
}
Compiler errors keep getting thrown:
Access of undefined property illustrationText
Access of undefined property illustrationTextRed
Am I going about this the right way?
Thanks for your help!
-Brian
Referencing Stage.stageWidth From A Class
I created a custom class in a .as file. I then linked this custom class with a symbol from the library in my .fla file. However, I can't reference stage.stageWidth in my custom class file. I get a null object error.
I think this happens because the custom class file is associated with a symbol on the stage and not the stage itself. For example, if I set the fla file's Document Class to the name of my custom class I can reference stage.stageWidth in the custom class. But I don't do this because I am creating multiple instances of the symbol on the stage. In order to do that properly i found I have to set the class in the properties panel of the symbol to the underlying class which then defines how each symbol behaves.
Under this type of linkage, is there a way to reference the stage width from the class?
I've tried root.stage.stageWidth and parent.stage.stageWidth to no avail. I also made sure to import flash.display.* in my custom class.
Below is the code for my .fla file and my .as file. In the .as file you'll see the line "x = Math.random() * stage.stageWidth;". This is the line giving me problems. I could hard code it, as I do for the y variable on the next line, but I'd prefer not to in order to keep the code flexible.
I also attached the files in a zip.
Any help would be appreciated.
ActionScript Code:
//.fla code
var i:int;
for(i=0; i < 100; i++){
var myBall:flaBall = new flaBall();
addChild(myBall);
}
//.as code
package {
import flash.display.*;
import flash.events.Event;
public class Ball extends MovieClip{
var dx:Number;
var dy:Number;
public function Ball(){
addEventListener(Event.ENTER_FRAME, onEnterFrame2);
reset();
}
private function reset(){
x = Math.random() * stage.stageWidth;
y = Math.random() * 400;
dx = Math.random() * 20 - 10;
dy = Math.random() * 20 - 10;
}
private function onEnterFrame2(event:Event):void{
move();
checkBounds();
}
private function move(){
x += dx;
y += dy;
}
private function checkBounds(){
if (x > 550 || x < 0){
dx *= -1;
}
if (y > 400 || y < 0){
dy *= -1;
}
}
}
}
Referencing Added Stage Children
I am trying to reference a child I added named "userInfo_mc" with nested inputText named "inputEmail". But I am getting this error when compiling referencing the line inside the userInfoSubmit function :
1120: Access of undefined property userInfo_mc.
Any Ideas? Any help is appreciated
Attach Code
function individualAccount():void
{
var userInfo_mc:UserInfoMC = new UserInfoMC();
addChild(userInfo_mc);
userInfo_mc.emailInput.addEventListener(MouseEvent.MOUSE_OVER, showEmailInfoBubble);
userInfo_mc.emailInput.addEventListener(MouseEvent.MOUSE_OUT, hideInfoBubble);
userInfo_mc.continue_btn.addEventListener(MouseEvent.CLICK, userInfoSubmit);
}
function userInfoSubmit(event:MouseEvent):void
{
if (userInfo_mc.emailInput.text == ""){
trace("Fill this out!");
}
}
Referencing Stage From External Class
I have an external class file that extends the MovieClip class and is linked to a movieClip on the main stage. I need it to be able to access properties of other movieclips on the main stage. How could I do this. Here is what my base movieclip class that I want to access the stage with looks like. Remember, it is linked to a movieclip on the stage, if that matters...
Obviously there is more code in the class, but I removed it for the sake of simplicity.
Attach Code
package{
import flash.display.MovieClip;
import flash.display.DisplayObject;
import Math;
public class Test extends MovieClip{
public function Test(){ //Constructor
}
}
}
Referencing Stage.stageWidth From A Class
I created a custom class in a .as file. I then linked this custom class with an symbol from the library in my .fla file. However, I can't reference stage.stageWidth in my custom class file. I get a null object error.
I think this happens because the custom class file is associated with a symbol on the stage and not the stage itself. For example, if I set the fla file's Document Class to the name of my custom class I can reference stage.stageWidth in the custom class. But I don't do this because I am creating multiple instances of the symbol on the stage. In order to do that properly i found I have to set the class in the properties panel of the symbol to the underlying class which then defines how each symbol behaves.
Under this type of linkage, is there a way to reference the stage width from the class?
I've tried root.stage.stageWidth and parent.stage.stageWidth to no avail. I also made sure to import flash.display.* in my custom class.
Any help would be appreciated.
Referencing Buttons In A MC
I am having an issue with displaying HTML documents in a Dynamic Text box.
To better summarize it here is what I am doing.
I have a movie clip that contains my button objects. Now when I click a button in the movie clip I would like it to load content into a dynamic text box that is locate outside of the movie clip. It is located on the main timeline where I have the site I am trying to create layed out.
What I would like to do is either have the button in the MC when clicked call to a function on the main timeline, or have its output be on the main timeline. I keep running into errors with the function being undefined (when it is written ion the main timeline) or the dynamic text box not existing (when it is written on the mc timeline).
Any help would be greatly appreciated.
External MC Loaded On Stage, I Can Press Buttons That Are On The Stage Through It...
I'm used to AS3, and I don't have much experience in AS2. I'm trying to modify an older flash file done in AS2.
An external swf is loaded using this code...
ActionScript Code:
on(release) {
loadMovieNum("supplimental/external.swf", 500);
}
The problem is that even though this external movie covers the whole stage, My mouse can still "see" buttons that are on the stage, and I can click them. I don't want to be able to click the buttons through my external movie. Thanks for any help.
External MC Loaded On Stage, I Can Press Buttons That Are On The Stage Through It...
An external swf is loaded using this code...
Code:
on(release) {
loadMovieNum("supplimental/external.swf", 500);
}
The problem is that even though this external movie covers the whole stage, My mouse can still "see" buttons that are on the stage, and I can click them. I don't want to be able to click the buttons through my external movie. Thanks for any help.
MC Buttons Within A MC Referencing Another MC Within The Same Scene....oh Boy
I have an array of buttons in a MC, these buttons are themselves MC's as they have RollOver and RollOut animations on them.
What I want to do is make these buttons reference another MC within my scene. I am using a controller for this navigation.
This is code I am currently using on the MC buttons:
onClipEvent (load) {
this.onRollOver = function() {
this.onEnterFrame = this.nextFrame;
};
this.onRollOut = function() {
this.onEnterFrame = this.prevFrame;
};
this.onRelease = function() {
this._root.main.play();
this._root.controller.gotoAndPlay(20);
};
this.stop();
}
and when I try to use the navigation I get the following error:
Target not found: Target="main" Base="_level0.controller"
I am getting a horrible sinking feeling that I have for gotten something very fundamently simple. This is my first big flash project and am still getting to grips with actionscripting and stuff like that.
I cant attach the file to this post as it is too big, even when I zip it. So if you want to see the file you can grab it from
www.excellence.co.za/Navigation5.zip
Thanks in advance to anyone who can offer advice/help
[F8] Referencing Buttons Not On Frame1
Hi, I'm hoping someone might be able to help me with my problem.
I have a movieclip(MC_2) nested inside another movieclip(MC_1). MC_1 is on the first frame of my main timeline. My actionscript is also on the first frame of my main timeline on its own layer.
My basic problem is that I can't seem to reference buttons in MC_2 if they are not on frame 1. I have also tried adding the code to the button but that doesn't work either.Is this something to do with the buttons not existing when the script is executed?
Can anyone help me with this?
Any help is much appreciated.
Referencing Buttons (simple)
I feel like chump at the moment... you guys are the only ones i can turn to for a quick answer.
All i need to know is how to referrence buttons and assign actions to them. I don't want to put the code directly on the button instance, but rather referrence the button from an actions layer.
Here is what I had.
HTML Code:
DRW.onRelease=function() { trace ("Hello")}
DRW is the instance name of the button.
Eek!
AS 2 Referencing Buttons Not On Frame1
Hi, I'm hoping someone might be able to help me with my problem.
I have a movieclip(MC_2) nested inside another movieclip(MC_1). MC_1 is on the first frame of my main timeline. My actionscript is also on the first frame of my main timeline on its own layer.
My basic problem is that I can't seem to reference buttons in MC_2 if they are not on frame 1. I have also tried adding the code to the button but that doesn't work either.Is this something to do with the buttons not existing when the script is executed?
Can anyone help me with this?
Any help is much appreciated.
Referencing Dynamically Created Buttons
I am creating a set of buttons from an array of information and need to know how to reference those buttons after they are created. I've clearly got some sort of syntax error and it's driving me nuts.
Here's the function (within a ProdSelectSystem class) that creates the buttons (which works just fine. The buttons work and do what they are supposed to do):
Code:
//--------------------------------------------------------------------
public function doInit(_systemData:Array):Void
{
systemData = _systemData;
listItems = new Array();
attachButtonItems();
}
//---------------------------------------------------------------------
/*
Attach a button clip for each data item in our systemData array
call init() on the new clip passing it an ID and data items
*/
private function attachButtonItems():Void
{
var exportName:String = "mcNLProdButton";
for(var i:Number = 0; i < systemData.length; i++)
{
var item:MovieClip = this.attachMovie(exportName, "Item_" + i, i);
item.init(this, i, systemData[i]);
listItems.push(item);
} //end for
} //end function
The problem comes when I try to reference these buttons later elsewhere. Since the instance name given in the loop via the this.attachMovie is "Item_" + i, I was under the assumption that I could use (for example for the _alpha property of the second created button) _root.Item_1._alpha. When I try that, however, I get "undefined".
I'd appreciate all thoughts on the subject.
TIA,
CP
Referencing Buttons Back To A Higher Layer
Hi
I'm having problems linking buttons back to a higher level in Flash MX.
I'm trying to link a button back to the original file from a movie that has been loaded into a layer on top of it (eg, layer 2, 3, etc)
For example:
My index page = layer 0
I want to load a movie onto layer 2. I need a button in that movie (on layer 2) which will take me back to the index page on layer 0.
All my attempts to do this have so far failed.
Can anyone help? (I'm sure it's something really simple I've overlooked)
Cheers
Rob
rjb@ace.edu.au
Problems Referencing Buttons From A Higher Level
On my index page, I have a movie clip with a series of buttons. The button(s) need to load a movie, which I've managed to do in 2 different ways:
1. By loading movies into a movie holder
on (release){
goToAndPlay("scenemain", "framelabel1");
_root.loadMovie("movie1.swf", movieHolder);
}
2. By loading the movie onto a separate level
on (release) {
_root.loadMovie("movie1.swf", level1);
}
Both of these ways work. However:
From the loaded movie (movie1.swf) I need to have a button which goes back to the index page EITHER:
a) By removing the movie which has loaded
Or
b) By linking back to the main movie on the Index page.
The following button code I've tried doesn't work:
on (press) {
_root["newclip"+(level-1)].removeMovieClip();
}
Can anyone help, or tell me what's wrong with this button code?
Cheers
Rob
Referencing Buttons From Class That Extends Movieclip
I'm attaching actionscript classes to my movie clips by extending the MovieClip class and specifying the AS 2.0 class in the linkage properties in the library – with the intention of having basically no code in the FLA.
This works fine and I can respond to events and reference objects contained within that movie clip by declaring a variable with the same name as the object's instance name in the class.
PROBLEM is that the object has to be present on the first frame of the MC, or the class just doesn't know about its existence. I have a short animation on the timeline, and then the btnOK button appears for the first time a few frames later. Problem is that I can't setup any sort of event handler or listener, because when the class is initialised on the first frame it doesn't seem to know about the button.
So in the below code... if the btnOK is on the first frame of the timeline, it traces, otherwise btnOK is undefined.
Code:
class myMC extends MovieClip {
var btnOK:Button;
function myMC() {
btnOK.onPress = function() { trace("clicked") };
}
}
Yeah sure I could place the button on the first frame and show/hide it as needed but that wouldn't be ideal and would make me want to vomit.
By the way, I'm talking about normal everyday button symbols, not the Button component.
Any ideas?
Cheers.
Who Is The Author Of This Incredible Code?
Can someone tell me who is the author of this? Incredible coding. Just using AS only. I do have the code but I don't know who is the author.
http://dikhach.maihoatrang.com/image...as_drawing.swf
How Do I Author A Flash File
I have been asked to create a flash thing for a CD and I have no clue how I author it so that all the person needs to do is put in the CD and it starts. I have Flash MX and it needs to work on A MAC and PC. If you know a simple solution please reply.
Jeff
Author, Date Setting?
is it possible to embed the author and date into the swf or fla file? i don't want the name to show up visually on the screen, but if they open up the fla or swf i want a way to know it's me.
thanks,
patrick.
Dynamically Author .swf Files
So,
What I would like to do is allow users to customize some aspects of a flash file, and then get emailed an animation with their personal touches. Let's say they can choose a background, a message, and a type of animation. They would input these options into a flash form, and in return, get emailed a .swf with the options they chose. I am just starting on this, an initially I have seen some stuff dealing with PHP, but at first glance, this seems to work in the browser, but not to actually be able to save a .swf in the end. Any ideas on this?
-B
Display Author In Invisible Mod
ok, in flash, you just need to put a invisible button and put some code on it. the code will attach a movie clip from the library to the stageor you can set a movieclip on the stage visible or invisible
does any one knows how to do that?
thanks a lot if you can help!!!
Referencing MovieClips Inside MovieClips From The Main Time Line?
is it possible to have event listeners that listen for a movie clip inside a movieclip and then execute a function from the main time line?
Or is it impossible to relate something this far removed? Sounds like a geek Jerry Springer episode!
Something sort of like this:
Attach Code
movie1_mc.closeBtn1.addEventListener(movie1_mc.MouseEvent.CLICK, closeMenu1);
movie2_mc.closeBtn2.addEventListener(movie2_mc.MouseEvent.CLICK, closeMenu1);
function closeMenu1(e:Event):void {
if (e.currentTarget.name == "closeBtn1"){
movie1.gotoAndPlay(27);
movie1.visible = true;
} else if (e.currentTarget.name == "closeBtn2") {
movie2.gotoAndPlay(27);
movie2.visible = true;
}
}
Multiple Buttons Loading MC Buttons On Single Stage
Hello,
I need three buttons , working independent of each other, to "turn on" the MC in three seperate boxes, all on the same timeline- further, I want these MCs once "turned on" to actually be buttons that can then send the user to a different page. I can make this work if it's only one button, using two frames (by "hiding" the already launch MC over the top of it- then sending the link to frame two etc) but I need ALL three buttons visible, in whatever order the viewer clicks them! (Think of a wall with three windows and the MCs are the window images!) SO: the viewer clicks a button (any or all three) that turns on the movie clip and the movie clip can then be clicked to launch to a new page. Is this even possible?
-sorry for the long explanation- thanks for any help!
ras.
Stage Size At Run Time
Hello,
I'm new in Flash and I have some experience with Director.
Is there a way to obtain at run time the stage size of an SWF?
Thanks,
Is This Your Code? Parallax Source Author Needed
I really need to reference the author of this parallax code but annoyingly Ive lost the forum post and Ive looked and searched for hours but I cannot find it.
Here is the code
Code:
stop();
var paused = false;
var active;
msgBox._visible = false;
var btnList = new Array();
function toggleEnabled() {
for (i in btnList) {
btnList[i].enabled = !btnList[i].enabled;
}
}
myPress = function (mc, num) {
btnList.push(mc);
mc.num = num
mc.onPress = function() {
if (!paused) {
paused = true;
this.gotoAndStop("dn");
active = this;
toggleEnabled();
msgBox._visible = true;
msgBox.play();
msgBox.msgs.gotoAndStop(active.num)
msgBox.btnClose.onPress = function() {
msgBox.play();
paused = false;
active.gotoAndPlay("up");
toggleEnabled();
msgBox._visible = false;
};
}
};
};
//
moveIt = function (wc) {
wc.imageStartX = 0;
wc.imageEndX = -wc._width + Stage.width;
wc.StartMouseX = 0;
wc.EndMouseX = Stage.width;
wc.MouseRangeX = wc.EndMouseX - wc.StartMouseX;
wc.PanRangeX = wc.imageEndX - wc.imageStartX;
//
wc.imageStartY = 0;
wc.imageEndY = -wc._height + Stage.height;
wc.StartMouseY = 0;
wc.EndMouseY = Stage.height;
wc.MouseRangeY = wc.EndMouseY - wc.StartMouseY;
wc.PanRangeY = wc.imageEndY - wc.imageStartY;
//
wc.onEnterFrame = function() {
if (!paused) {
wc.rX = (_root._xmouse - wc.StartMouseX) / wc.MouseRangeX;
wc.rX = Math.max(0, Math.min(1, wc.rX));
wc._x += ((wc.rX * wc.PanRangeX + wc.imageStartX) - wc._x) / 9;
//
wc.rY = (_root._ymouse - wc.StartMouseY) / wc.MouseRangeY;
wc.rY = Math.max(0, Math.min(1, wc.rY));
wc._y += ((wc.rY * wc.PanRangeY + wc.imageStartY) - wc._y) / 9;
}
};
};
//Call the function for each MC that is going to move. Be sure that the
//registration point of each MC is set to the upper left corner.
moveIt(bg);
moveIt(mid);
moveIt(fg);
//Set for each button that will be used, first parameter is button MC.
//Second parameter is the frame number of the msgs MC to display.
myPress(mid.btn1, 1);
myPress(fg.btn1, 2);
myPress(fg.btn2, 3);
The file was called just parallax I think. It has an image of a field and some message boxes etc. I havent used it in the same way, but I hope someone can claim ownership!
see attached file! If anyone knows the author or has the post, please inform me!
Cheers
|