Accessing Stage Items Through Doc. Class
Hi there. Super Quick question:
If I drag library items onto the stage, can I access those specific instances through my document class? Or do I have to place everything on the stage with actionscript?
KirupaForum > Flash > ActionScript 3.0
Posted on: 11-29-2007, 10:07 PM
View Complete Forum Thread with Replies
Sponsored Links:
Accessing Stage From The Class
I got the following file Tiles.as
Code:
package{
import flash.display.*;
public class Tiles extends MovieClip{
public var map:MovieClip = new MovieClip();
private var stageSet:Stage;
public function Tiles(stageRef:Stage):void{
stageSet = stageRef;
}
/* i draw on map MC with drawing API and i want it to be shown on Stage (main frame), but i cant access it*/
public function createMap():void{
map.graphics.lineStyle(1,0x990000);
map.graphics.moveTo(0,0);
map.graphics.lineTo(100,100);
stageSet.addChild(map);
}
}
}
and following code in Tiles.fla
Code:
var Tile:Tiles = new Tiles(Stage);
Tile.createMap();
and i get error like this :1067: Implicit coercion of a value of type Class to an unrelated type flash.display:Stage.
View Replies !
View Related
Accessing MC On Stage From Different Class In AS3
I'm new to AS3. I am a mediocre AS2 programmer, but I've taken some java courses so I guess I'm not too clueless that I can't eventually make the jump to AS3 : ) I have a new project that I am converting to AS3 from AS2 and am getting an error and am not sure what to do.
Background:
I need to create a scaled down version of Deal Or No Deal (with some major variations to the rules). I have a fla with a bunch of briefcase movieclips onstage named case1_mc, case2_mc, etc. There are 26 of them. I have a bunch of classes named Main.as (which is the document class for the fla), Briefcase.as, Game.as, Banker.as, etc.
My trouble is that within each briefcase mc there is a dynamic text field. I need to assign text to the dynamic text fields in each of the briefcase mc's. Here is my code from the Main class that is the document class that is causing the problem. This function is called from the Main constructor, to initialize the briefcase objects (not the visual ones, but the ones that will hold data to be displayed in the visual ones as needed):
Code:
function generateCases(_totalNumCases) {
for (var i=1; i<=_totalNumCases; i++) {
//generate the Briefcase objects
this["case"+i] = new Briefcase(i);
//assign the Briefcase object's caseNum to the displayed briefcase movieclip
this["case"+i+"_mc"].num_txt.text = this["case"+i].getCaseNum();
}
//randomize the caseValues_arr and assign values to Briefcases
shuffledCaseValues_arr = dollarValues_arr.shuffle();
//assign the shuffledCaseValues_arr values to the correlating Briefcases
//NOT WORKING
var incrementArray:Number = 0;
for (i=1; i <=_totalNumCases; i++) {
this["case" + i].setCaseValue(shuffledCaseValues_arr[incrementArray]);
incrementArray++;
}
}
When I compile and run in Flash CS3 I get the following output error (I get no compile errors anymore after much editing!):
ReferenceError: Error #1056: Cannot create property case1 on com.vertexinc.dealornodeal.Main.
at com.vertexinc.dealornodeal::Main/com.vertexinc.dealornodeal::generateCases()
at com.vertexinc.dealornodeal::Main$iinit()
So it appears that it just cannot run the function because it can't set the text properties of the briefcases? Any help is greatly appreciated! I had this working in AS2/Flash 8 but want to stick it out and get it going in AS3 as my first AS3 project!
View Replies !
View Related
Accessing An Instance On Stage From Within Another Class
Hi,
This really should be simple, but is proving frustratingly difficult! All I want to do is access one instance of a MovieClip on the stage (blue_mc) from within the class file of another MovieClip (red_mc).
e.g. One instance of "Blue" on the stage called "blue_mc", and one instance of "Red" on the stage called "red_mc". Both symbols are linked to class files (Blue.as and Red.as).
In Red.as, I set up a function to listen for a mouse down event. When this is triggered, I want to move the instance blue_mc. At the moment, though, I can't seem to get a reference to blue_mc.
I've looked into the new stage and root properties, but even though blue_mc is on the stage, it cannot be accessed using stage.getChildByName( "blue_mc" ) either.
Code for Red.as:
Code:
package {
import flash.display.MovieClip;
import flash.events.MouseEvent;
import flash.events.Event;
public class Red extends MovieClip {
private function ballPressed( eventObject:Event ) {
trace( this.name + " pressed" );
trace( stage.getChildByName( 'blue_mc' ) + " not pressed" );
};
public function Red() {
trace( "Red loaded" );
this.addEventListener( MouseEvent.MOUSE_DOWN, ballPressed );
}
}
}
Can anyone point me in the right direction!?!
Thanks!!!
Chris
--
www.chrisblunt.com
View Replies !
View Related
Accessing An Object On The Stage From Within A Class?
It's me again
Naah, this is a simple one. I think. If I've created a label on the stage just by sticking the code below on the first frame of the .fla:
Code:
var imgLabel:Label = new Label();
imgLabel.text = "Hello World";
imgLabel.x = 100;
imgLabel.y = 100;
stage.addChild(imgLabel);
and right below that I'm creating an instance of an image-scrolly class (that extends MovieClip) with:
Code:
var mySlideShow = new FeaturedPanel("slideshow_name");
stage.addChild(mySlideShow);
... then how the heck do you get at the label, from the image scroller thing?
I've got a function in the FeaturedPanel class that's fired when you click an image within it, with just "imgLabel.text = imgCaption;" - and it keeps telling me "Access of undefined property imgLabel."
Nuh?
View Replies !
View Related
Accessing Stage Variables From Class
hi ..
I have written some action script (well most of the script) on main time line without using any CLASS - (bad practice) .. there are many variables that i have created there and the stage objects .. I am using those objects on main time line as ..
ActionScript Code:
this.mVideo.someProperty ...
now i have written a class say .. "Test.as" which i have placed in the same directory. now while being in that class method, how can i access variables define on the timeline actionscript + on the stage ..
how can i access that "mVideo" object from that class ??
View Replies !
View Related
Accessing Object On Stage From Class
Hi,
I'm creating a game and I want to test if an object (created by a class)
hit the main character (created on the stage)
I tried referencing the main character in the class (parent.main_character),
but it states that it doesn't recognize that instance name.
How can I reference an object on the main stage through a class?
Thanks.
View Replies !
View Related
Problem With Attaching Library Items To Stage From External Class
hello
i'm new to AS and i can't figure out why i am having this problem.
i have this item in the library (Class: Buton ; base class: flash.display.SimpleButton)
and this code in my custom class:
private var butonStg:SimpleButton;
[...]
this.butonStg = new Buton();
this.butonStg.x = 30;
this.butonStg.y = 40;
addChild(this.butonStg);
now if i trace butonStg properties (like x, y, width, height) they work just fine, but the item isn't displayed on the stage, i can't see it
can anyone help me with this?
thanks
View Replies !
View Related
Accessing The Same Array From Stage And Class Files?
Hey all.
Ive been stuck on this for a while now, and am finding it hard to find anything on the net, because whenever i combine "array" and "class(es)" in a search it just brings stuff up about the array class lol.
What i basically want is:
enemies are created on the main timeline via actionscript, and pushed into an array.
How can i now access that array from within say a "Turret.as" class file that is controlling my turrets, to let them loop through the enemies and choose their target?
Thanks for any help,
Gareth
View Replies !
View Related
Help With Senocular's TopLevel Class Accessing Stage
Hello,
Hope your Sundays is going well Mine isn't.. I;ve been struggling with Senocular's TopLevel class usage. A quick overview is that my Document Class extends TopLevel and makes th static variables (as per Senocular's post) and then I have some remoting classes that fetch things from my database. I can use the TopLevel to access [object Stage] but when I try to access anything on that it just says '1119: Access of possibly undefined property HB1 through a reference with static type flash.display:Stage' compile-time error - this is when using
Code:
trace(TopLevel.stage.HB1);
I also tried
Code:
var TL = TopLevel.stage;
trace(TL.HB1);
which gives me "ReferenceError: Error #1069: Property HB1 not found on flash.display.Stage and there is no default value.
at Remoter/::healthUpdate()" Run-time error.
AM i missing some interim property that stores the actual objects? There is an instance of the target on the stage with instance name of "HB1" and I can access it from the Document Class with just "trace(HB1);"
I can't just pass a reference directly, and I can't find anyone with issues regarding Senocular's code, so I guess I'm just missing something. the describeType() result for the TopLevel.stage (called from non-document class) doesn't enlighten me, lots of properties but none seem to relate to much.
Any help gratefully received!
Edit: I have also tried playing with the linkages but didn't entirely understand what it meant, so left it with nothing ticked, but none of the settings seemed to help.
View Replies !
View Related
Accessing Elements On The Stage From A Linked Class
I'm trying to link a clip to a class, and it goes well until I try to access MovieClips or TextFields placed on the stage within that clip from code in the class. My code is below; there is a TextField called output_txt on the stage within this clip.
Any help is much appreciated.
Dave
class Main extends MovieClip{
public function Main() {
//trace("123"); <--if I replace the line below with this, it traces nicely
output_txt.text = "123";
stop();
}
}
View Replies !
View Related
Accessing Parent Document Class Stage
Hi folks!
I'm having some problems accessing the stage of a parent document class in a full-browser site I'm working on.
Here's my setup: I have a main document class that loads sub-classes when individual pages are chosen from the main navigational page.
Since it's full-browser, I'd like to have the ability to reference the stage width and height from sub-classes, but can't seem to get it working properly. I've mucked around with Application Domains, and still can't seem to figure it out.
Help!
Many thanks in advance.
View Replies !
View Related
Problem Accessing .stage From An External Class
Hello!
I've done a very simple fullscreen test application which worked while everything was in the document class. Now I want to try having the fullscreenswitch-code in an external class but I get an "1120: Access of undefined property stage." error.
Sorry if this is a really dumb question (I'm new to flash/as3/and the process of working with classes) but how do you access stage from an external class?
This is the document class
Code:
package com {
import flash.display.Stage;
import flash.events.Event;
import flash.display.StageScaleMode;
import flash.display.StageAlign;
import flash.display.MovieClip;
import flash.text.TextField;
import flash.text.TextFieldAutoSize;
import flash.events.TextEvent;
import com.FullscreenSwitch;
public class FullscreenTest extends MovieClip {
// Constants:
// Public Properties:
public var txtFullscreen:TextField = new TextField();
// Private Properties:
// Initialization:
public function FullscreenTest() {
stage.scaleMode = StageScaleMode.NO_SCALE;
stage.align = StageAlign.TOP_LEFT;
txtFullscreen.multiline = true;
txtFullscreen.autoSize = TextFieldAutoSize.LEFT;
txtFullscreen.htmlText = "<p><a href='event: aaaaaa'>Fullscreen</a></p>";
txtFullscreen.x = 12;
txtFullscreen.y = 12;
addChild(txtFullscreen);
txtFullscreen.addEventListener(TextEvent.LINK, FullscreenSwitch);
}
}
}
And this is the fullscreenSwitch which is called upon from the documentclass
Code:
package com {
import flash.display.Stage;
public class FullscreenSwitch extends MovieClip{
// Constants:
// Public Properties:
// Private Properties:
// Initialization:
public function FullscreenSwitch() {
switch(stage.displayState) {
case "normal":
stage.displayState = "fullScreen";
break;
case "fullScreen":
default:
stage.displayState = "normal";
break;
}
}
// Public Methods:
// Protected Methods:
}
}
http://www.kirupa.com/forum/showthread.php?p=1952513 seems to be the solution to the problem but I'm not sure how to explicitly give a reference to a non-display object classes..
View Replies !
View Related
Accessing Variable And Method In A Class From A Sub Movieclip On Stage?
Folder structure.
root_folder/site.fla
root_folder/hdg/HDGClass.as
I have the document class set to hdg.HDGClass and there are 3 movie clips on the stage with the instance names btn1, btn2, and btn3 and each have a submovie clip with the instance name btn.
HDGClass.as
Code:
package hdg {
import flash.display.MovieClip;
import flash.net.URLLoader;
import flash.net.URLRequest;
import flash.xml.*;
import flash.events.*;
import flash.errors.*;
public class HDGClass extends MovieClip {
public var currentNav:int = 1;
public function HDGClass():void {
init();
}
public function init():void {
//initialize top navigation buttons
btn1.btn.addEventListener(MouseEvent.MOUSE_OVER, topNavOver);
btn1.btn.addEventListener(MouseEvent.MOUSE_OUT, topNavOut);
btn1.btn.addEventListener(MouseEvent.MOUSE_DOWN, topNavClick);
btn1.btn.buttonMode = true; //gives movieClip the hand cursor
btn2.btn.addEventListener(MouseEvent.MOUSE_OVER, topNavOver);
btn2.btn.addEventListener(MouseEvent.MOUSE_OUT, topNavOut);
btn2.btn.addEventListener(MouseEvent.MOUSE_DOWN, topNavClick);
btn2.btn.buttonMode = true;
btn3.btn.addEventListener(MouseEvent.MOUSE_OVER, topNavOver);
btn3.btn.addEventListener(MouseEvent.MOUSE_OUT, topNavOut);
btn3.btn.addEventListener(MouseEvent.MOUSE_DOWN, topNavClick);
btn3.btn.buttonMode = true;
}
function topNavOver(event:MouseEvent):void {
event.target.parent.gotoAndPlay(2);
}
function topNavOut(event:MouseEvent):void {
event.target.parent.gotoAndPlay(34);
}
function topNavClick(event:MouseEvent):void {
currentNav = event.target.parent.id_txt.text;
}
function yo() {
trace("yo");//test function
}
}
}
frame 1 of my root timeline just has...
Code:
stop();
on frame 34 of btn1, btn2, and btn3 there is this code just to test if the variable or test methods can be retreived/called.
Code:
trace(currentNav);
yo();
The mouse events work fine triggering the mouse_over and mouse_out and mouse_down actions. But when I added the above code to frame34 I get these errors...
1120: Access of undefined property currentNav.
1120: Access of undefined property yo.
How do I access them correctly?
I tried adding this to frame1 of my root timeline just to do another test but still got errors....
Code:
var x:HDGClass = new HDGClass();
x.yo();
trace(x.currentNav);
View Replies !
View Related
Accessing Properties From Items In An Array?
whats up... im getting stuck on this thing that i originally thought would be straight forward...
basically... i have several clips that are attached dynamically and assigned sequential instance names; i.e. clip0, clip1, clip2, etc...
when the mc's are clicked on... i add the name of the instance to an array w/ a simple
Code:
_parent.aClickedTiles.push(this._name);
with 'aClickedTiles' of course being my array to hold these values...
now, what i want to do, is to be able to loop through this array and pull some properties off the clicked tiles to use elsewhere in my script, and this is where im getting caught up...
if i want the x pos of the clips i thought that a:
Code:
for (var cnt=0; cnt < aClickedTiles.length; cnt ++){
trace ("the X val of " + this.aClickedTiles[cnt] + " is " + this.aClickedTiles[cnt]._x);
}
would do the trick... but it returns
Code:
the X val of clip6 is
the X val of clip4 is
the X val of clip8 is
which is wierd because i get the name of the clips that were clicked on, but not thier x values...
i must be missing something here..
any ideas?
thanks.
View Replies !
View Related
Question On Accessing Combobox Items Through Xml
sir
i got an error while changing the combobox item i.e i have wriiten a program to retrive the data from an xml file and display the corresponding image file using loadMovie command. i also written a "change" function for the combobox. when i click the first item i didn't get any image in the loader but for the second item i got it. so is there any problem in accessing the selected Index value of the combox?.
Thank you.
View Replies !
View Related
Accessing Loaded SWF Library Items
In _root level I'm loading a swf that contains button skins(In library with linkage names)
And I want to load a button skin in _root._mc level. I can do this using attachMovie but, it adds to _root level because the swf is loaded from _root level. But, I want it to be added to _root._mc level. Hopefully this is clear.
1) Load a swf that contains button skins in _root level
2) in _root._mc using attachMovie add a button skin in _root._mc level NOT _root level.
Thanks,
View Replies !
View Related
Accessing Next/previous Items In Array
This is probably something very simple, but I'm not too sure of the code used to access items within an array.
Suppose I have an array like this (using Kirupa's Arrays example):
grocery = ["bananas", "oranges", "apples", "kiwis"];
trace(grocery);
And we've loaded up the corresponding variables/text for "bananas", thus the current item = bananas.
Therefore the next item would be "oranges". How can I tell Flash that I want to access this next item?? (I'd like to be able to access it through a variable so that the same action can be applied when the item is "oranges" to move to the next item, which would now be "apples"). Thanx
View Replies !
View Related
Accessing DataGrid Column Items....
I was wondering if anyone knew how to access column items...
ie if i made a column named "Info" and wanted to get the 5th item how would i go by doing so.. i though it was just an array something like this
my_dg[Info][i] were i is the index counter.. but that wasn't it.. i can get it to display the column name but thats about.. anyhelp is helpful
ps.. also had a question about flash and saving data locally...
i tried using MMSave(mystring,"/myfile.xml") but it seems that it always saves in the path C:Program FilesMacromediaFlash 8enConfiguration now i know i could just do MMSave(mystring,"../../../../../myfile.xml") and get it to save in the C: but i wanted it to be saved in the same path as the swf.. anyhelp with this would be helpful...
Thanks
View Replies !
View Related
Accessing Linkage Items From Other Levels
I'm trying to access an item in my library with the linkage name 'thisone'...
Easy enough, just:
attachMovie ("thisone", "newone", 1);
However, this movie - library.swf has been loaded onto level 10 - and the simple target as shown above doesn't work - neither does appending _level10. to "thisone"...
Any one know how I can access this library element without it having to reside on the same level???
Thanks
View Replies !
View Related
Accessing Library Items In As3 File
Hi,
I have a fla file with lots of library items. I can access them in the actionscript inside the fla file, but how can an external class access them?
I have arms.fla with library item Box that's a MovieClip. In an external file NumberLine.as I need the Box item for display. I've exported Box for actionscript, but I still get compile errors. How do I get Box into NumberLine.as?
Thanks!
Jay
View Replies !
View Related
Accessing Instantiated Items Not On Displaylist
Hi!
I have this loop that instantiates some classes that extend Sprite -
Code:
private function xmlLoaded(event:Event):void{
xml = new XML(event.target.data)
for(var i:uint = 0; i<xml.children().length(); i++){
var c = new Container(String(xml.children()[i].attribute("name")), String(xml.children()[i].attribute("url")))
c.name = "cont"+i
c.x = nextx
c.y = nexty
nextx+=889
if(nextx<stage.stageWidth){
items.addChild(c)
}
}
}
some of the items are not added to the displaylist. It possible to access them later?
If so then how?
View Replies !
View Related
Accessing Library Items From Loaded SWFs
Hello All ---
I have my Document class (Movie A) that is loading in an external swf (Movie B). Within Movie B, in the library, there is a sprite exported for AS, with the Class name Square. This Class (Square) is not going to be used until it is added/loaded into the Document class. Once Movie B is loaded into the Document Class, how can I access the Square Class from within Movie A/Document Class.
Thanks for any and all replies.
View Replies !
View Related
Accessing Library Items In External Content
Hi;
I'm loading in external resources (using the loadMovie method) and this works fine. I'm having problems accessing library items from the loaded movie clip (relevant movie clips are set to "export in first frame" in the loaded movie clip). I try to access the relevant items in the same way as usual using :
Code:
this.attachMovie("linkageIdInLoadedMovie", "newName", myDepth);
Does the location where the external movie is loaded to matter ??
View Replies !
View Related
Accessing A Dynamic Text Field In A Class Other Than The Primary Class
I have tried to read and understand some of the other threads for this issue but, I think it would be easier to understand if I show my specific issue. I left some code out to make my issue more clear.
Alpha is the primary class with access to the stage. If I write the event listener and function contained in the Bravo function into the Alpha function it works. Although, I want it to be in a different class in the same package (such as the Bravo class).
I have created a instance of a class which is a physical object on the stage (lets say it's a card). The event listener is in the instance so that each instance has a self contained listener.
The bottom line is it works in the primary class but in no others. How can I make it access the text field (so when I click on the "card" the text field shows "something"?
ActionScript Code:
package a {
public class Alpha {
public function Alpha() {
x:Bravo = new Bravo();
}
}
}
package a {
public class Bravo {
public function Bravo() {
this.addEventListener(MouseEvent:CLICK, clickEvt);
function clickEvt(event:MouseEvent) {
<MovieClip>.<MovieClip>.<DynamicTextField>.text = "something";
}
}
}
}
View Replies !
View Related
Tough One: Accessing Class Methodes From Other Class Files
Tough question for the experts...
In my classfile class Classes.tools.depthManager, I've got a static methode
Code:
public static function getLoopDepth():Number {
In another classfile Classes.tools.frameRateViewer, I want to access that methode
Code:
var tempDepth = Classes.tools.depthManager.getLoopDepth();
The compiler claims: "There is no class or package with the name 'Classes.tools.depthManager' found in package 'Classes.tools'."
So I tried writing import Classes.tools.* at the top of my Classes.tools.frameRateViewer.as, hoping I could just write
Code:
var tempDepth =depthManager.getLoopDepth();
But there the compiler claims: "The class being compiled, 'Classes.tools.depthManager', does not match the class that was imported, 'depthManager'."
I'm sure the Classes.tools.depthManager.as works fine: I can call the static depthManager.getLoopDepth() from a button in the fla file...
Any ideas? Thanks!
View Replies !
View Related
Accessing Document Class From Static Class?
I am building a family tree like tree in flash.
I have a package TreeManager which holds all my classes.
The document class TreeManaager.Tree controls adding new nodes to the stage.
ActionScript Code:
public function addProfile(relationship:Object):void
{
profile = new Profile();// create new profile
var align:Alignment = new Alignment();//make Alignment object
...
The profile class controls all the internal node functionality.
Question - If I have a button in my node MC (profile class) which should add a new relationship (i.e. call addProfile) how to I do this?
ActionScript Code:
public class Profile extends MovieClip {
public function Profile ():cool:
{
this.addEventListener(MouseEvent.CLICK,Tree.addProfile);
This always throws an error. I can just add the buttons events from the document class, but it would be helpful to know if you can access the document class from a packaged static class?
ActionScript Code:
// add button events
profile.mother.addEventListener(MouseEvent.CLICK,addRelationship);
profile.brother.addEventListener(MouseEvent.CLICK,addRelationship);
profile.son.addEventListener(MouseEvent.CLICK,addRelationship);
View Replies !
View Related
Items Not On Stage Showing
I have just created a Flash movie, and I have blank movie clips about 20 pixels off the stage that hold preloaded movie clips until I need them.
I was just looking at my SWF file in the browser and it showed the movie clips I had off the stage.
As I recall, Flash is not supposed to show items which are not on the stage, correct?
Any solutions?
View Replies !
View Related
External Swf - Off Stage Items?
I loading an external swf file into a movie yet in the external file contains some objects that hang over the stage (off screen) yet when I load the swf into the main movie the objects that are off screen are viewable? How can I hide them? The document size is set to117x217...
Any ideas?
Thanks,
dEVS!
View Replies !
View Related
Off Stage Items Appearing
Whenever I make an swf out of my fla the swf file pops up just fine and looks nice, but when you resize the swf window you can see items that were off the stage. Is there any way I can prevent this from happening? Thanks.
View Replies !
View Related
Items Appearing Off Stage
Hello,
This has been remarked on before but the answer given avoided the question.
If I make an amimation then publish it to the web why do items that are stored off of the stage show in the published swf? I thought I remembered reading that anything off the stage will not be shown.
Many thanks
View Replies !
View Related
[CS3] CPU Usage And Items Off Stage
Hi,
how does flash handle items that are off stage.
I have a mc which contains 5 empty mc's
each of these has a swf loaded into it.
The main mc slides across stage moving a set distance at regular intervals bringing one of the 5 swf's into view.
pretty basic stuff.
When I expand my stage I see that the 5 swf's are always playing
With my stage its normal size is flash using CPU power to draw the 4 that are not visible (off stage) but still playing?
I ask because I sometimes get audio glitches when they slide into view.
the audio is not in the moving stuff it is in the main movie.
thanks
mark
View Replies !
View Related
Problem With Off-stage Items
Hi,
I'm new to flash and I have a problem. I'll try to explain the best I can...
I created a site and when I test the movie at 1024X768 it looks fine. I wanted to see it in a higher resolution so I bumped up the res on my monitor and tested the movie again. Now, I can see items that are off the stage in the browser. My understanding is that anything not on the stage will not be seen in the final movie. Is there something I have to do to ensure that the "outside the stage" area is not visible in the published swf? Thanks for any help!
Jason
View Replies !
View Related
Moving Multiple Items On The Stage
This is probably a dumb question, but here goes:
I need to dump the contents of all my nested mov clips to Scene1 as one flat animation. When I do, they are no longer in the right place on the stage.
- Is there a way to move multiple keyframes and tweens as a group to another point on the stage, without having to reposition every keyframe one at a time?
When I try selecting them all and grouping, it only moves what keyframes my timeline pointer is on. The rest are left to make unwanted crazy animations.
thanks for your help
View Replies !
View Related
Refrencing Array Items Already On Stage
i understand how the attached code works.
Code:
for (var m = 0; m<30; m++) {
thumbNails = picts.createEmptyMovieClip("thumbNails"+m, picts.getNextHighestDepth());
thumbNails.createEmptyMovieClip("thisThumb", this.getNextHighestDepth());
thumbNails.myNumber = m;
thumbNails._alpha = 50;
thumbNails.onRollOver = function() {
this.onEnterFrame = function() {
if (this._alpha<100) {
this._alpha += 10;
}
if (this._alpha>=100) {
delete this.onEnterFrame;
}
};
};
The idea in this was to learn how to individually refrence each instance in the array, without having to write m[0],m[1],m[2]...etc , 30 times for each action. I also wanted to learn how to duplicate clips with a for loop..It makes since to me when i am creating mc's from AScipt
. But how do i do the same idea, with 5 different mc's are already on the stage. I am sure it starts with classifying them into an array, But from there, my head got a bit boggled.. So far, i am taking it in this direction:
Code:
var demos:Array= [mc1.demoScrollBar,mc1.demoButton,mc1.demoNeedle,mc1.demoSnap,mc1.demoSafetyPin];
var thisDemo:MovieClip;
for(var d=0;d<demos.length;d++){
thisDemo=demos[d].createEmptyMovieClip("helpButtons", this.getNextHighestDepth());
demos[d]._alpha=50;
thisDemo.index=d
thisDemo.onRollOver=function(){
clearInterval(nAlpha);
nAlpha=setInterval(alphaUp,50,demos[this]);
}
thisDemo.onRollOut=function(){
clearInterval(nAlpha);
nAlpha=setInterval(alphaDown,50,demos[this]);
}
thisDemo.onRelease=function(){
txDemo.text=myXML.firstChild.childNodes[this.index].attributes.words;
}
}
however, it seems that i am not getting how i can refrence each mc without writing demos[0], demo[1], etc for each i want to addres with the onRelease. was that confusing? any ideas?
View Replies !
View Related
How To Apply As3 Code To Items On The Stage
hello again...
i have to code a project in which the designer already prepared a fla file with an embedded MovieClip.
this MovieClip contains a lot of other MCs which i have to control using scripts...
this sucks a little but i have to do it anyhow.
now here is a specific problem:
there are four movieclips on the stage which should act as buttons.
they are named btn_0 to btn_3
to make them happen as buttons previously i would have coded:
Code:
for (var i =0;i<4;i++){
var btn=this["btn_"+i];
btn.id=i;
btn.onRollOver=function(){
btnOver(this.id);
}
btn.onRollOut=function(){
btnOut(this.id);
}
btn.onRelease=function(){
btnRelease(this.id);
}
}
function btnOver(id){
this["btn"+id].gotoAndStop(2)
}
function btnOut(id){
this["btn"+id].gotoAndStop(1)
}
function btnRelease(id){
this["btn"+id].gotoAndStop(3)
this.curr_btn_id=id
}
can someone nudge me into how this would be done in AS3 ?
thanks a lot!
View Replies !
View Related
Moving Stage Items On Resize
Does anyone know how to reposition the stage items on resize like they do on
http://www.hellohikimori.com/
I know how to just move the items onResize, but I want to have the effect of waiting till the resizing has finished before the items move, and how the items bounce in using a Tween.
Any Suggestions.
View Replies !
View Related
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?
View Replies !
View Related
BUG? Selecting Items On Stage Causes Crash
I am able to consistently recreate the following issue, but no one else that I've spoken to has. Is anyone else having this issue? If I’m the only person in the world having this issue then it must be my machine and not Flash.
I'm on Windows XP with Flash 9. (latest updates, etc.)
Draw a box.
Select it and press F8 to make it a movie clip
Copy it and paste it 10 times (distribute across the stage)
Select all 11 movie clips and press F8 to make into another mc
(So now we have 11 mc’s, nested in a single mc)
Holding down the SHIFT key select each mc one at a time (do not marquee select.)
SOMETIMES it's OK. However, a lot of times one of the mc's I select will not highlight as selected. If I continue to click mc’s my machine will scream and power down! (No crash report, no blue screen, etc.) If I wait patiently the one mc that didn't highlight will highlight, the ones I previously selected will deselect.
***************************
This is getting on my nerves because I often get fla files from graphic designers that place everything on a single layer. My first task might be to select all of the text labels, for example, and place them on a separate layer. Yesterday I had to select 75 labels copy/move to another layer and paste one at a time!
***************************
View Replies !
View Related
Load Items To Stage Via An Array
Hi all, I'm just trying to learn AS3 and am having some trouble ...
I have 4 library items (all movie clips), named as mc0, mc1, mc2, mc3. The linkage is set so the class name is the same.
I want to create an array with the class names in, so I have:
HTML Code:
var mcNames:Array = new Array(mc0, mc1, mc2, mc3);
I then want to be able to loop through (either using a for or if statement) and dynamically attach the items to the stage by looping through the array. So my code would be like:
ActionScript Code:
for (var i:Number = 0; i<mcNames.length; i++){
// put an instance of the movieclip on the stage that
//has the same name as the current item in the array.
//So for example, if the first item in the array is mc0,
//then the item attached to the stage will be the
//movieclip mc0 from the library --- but how do I do it????
}
Any help would be greatly appreciated
View Replies !
View Related
Removing Items From Stage Using RemoveChild
So, I have a file where I've added 27 movie clips to the stage using a for loop to cycle through items in an XML document. Here's the pertinent part of the code I'm using, it's AS3:
So, I end up with 27 instances of mini_mc, each named 0, 1, 2, 3, etc.
I'm trying to write code to remove them at a certain point in the movie but having problems. Here's what I'm using:
But I get this error:
ReferenceError: Error #1069: Property 0 not found on String and there is no default value.
I'm thinking I'm not referencing the "name" of the mcs properly?
Any help would be greatly appreciated! Thanks very much.
Attach Code
for(var i = 0; i < myXML.photo.length(); i++) {
mini_mc = new mcMini();
mini_mc.name = i;
mini_mc.buttonMode = true;
stage.addChild(mini_mc);
}
for(var i = 0; i < myXML.photo.length(); i++) {
stage.removeChild(mini_mc.name(i));
}
View Replies !
View Related
Removing Items From Stage With RemoveChild
So, I have a file where I've added 27 movie clips to the stage using a for loop to cycle through items in an XML document. Here's the pertinent part of the code I'm using, it's AS3:
for(var i = 0; i < myXML.photo.length(); i++) {
mini_mc = new mcMini();
mini_mc.name = i;
mini_mc.buttonMode = true;
stage.addChild(mini_mc);
}
So, I end up with 27 instances of mini_mc, each named 0, 1, 2, 3, etc.
I'm trying to write code to remove them at a certain point in the movie but having problems. Here's what I'm using:
for(var i = 0; i < myXML.photo.length(); i++) {
stage.removeChild(mini_mc.name(i));
}
But I get this error:
ReferenceError: Error #1069: Property 0 not found on String and there is no default value.
I'm thinking I'm not referencing the "name" of the mcs properly?
Any help would be greatly appreciated! Thanks very much.
View Replies !
View Related
Brining Items To The Stage From The Library
Hi
I have three small movie clips in my library and three buttons on my stage (b1, b2 and b3)
Initally I want movie one to be displayed and then when the user clicks b2 for example I want to be able to take movie_two_mc from the library and place it on the stage, whilst removing movie one first. Then if b3 was clicked movie 2 would go and movie 3 appear.
I know these could be external swfs but these are just tiny movie clips and I would rather them stay in the main fla. I have this working at the moment by changing the movie clips visibility but this is a little messy as all clips are on the stage at the same time until I test movie.
I know about linkage in the library and I have manged to bring in a movie clip from the library using this code
Code:
this.attachMovie("one", "one_mc", 10, { _x:275 , _y:150 });
but i can't get any further.
Thanks
Ricky55
View Replies !
View Related
Slide Show - Random Items To Stage -help
17 slides
each slide: (each on separate layers)
image of a shool subject
static text box with subject in a second language
a button to advance to next frame
call in a picture which allows students to give a give an opinion like It's great/It's boring/I't fun etc. (this is where I need help see below)
frame label f1/f2 etc
AS on layer slpit into 17 keyframes which intructs forward button to move to the next frame (so if you are on f4 the AS says onto F5 and at frame 17 the AS sends you back to frame one again.
I have created the pictures for the opinions and made them into movieclips which only exist in the library.
How do I script it so that when I press the opinions button a random opinion movie clip comes to the stage when I run the slide show?
Make it obvious if you think you can help. It it about creating variables or and array? (a little knowledgs is a dangerous thing)
I'm running MX 2000 Educational
Cheers
Huw
View Replies !
View Related
Accessing Functions In A Class, From Another Class?
is this possible?
for instance, i have a function called "registerThumb" in my main engine class which keeps a delegated array of items.
However the only time i want to call that function, is from within another class which creates the thumbnails "Thumb.as", so i can automatically register paths into the array instead of just names.
does that make any sense?
View Replies !
View Related
|