Accessing Sound Objects From External Swf?
how's it goin'?I've been having trouble accessing sound objects that are located in an external swf. Essentially I've generated the sound objects in actionscript so that I don't have to link and create movie clips etc - the sound objects are now loaded into an associative array.... The code is similar to http://www.sonify.org/home/feature/...tesoundobjects/It plays fine in it's own swf, but as soon as I loadMovie() this swf into another one, my sounds are not playing - nor can I refer to them. How would I go about and access these sounds?? If ya'll have any suggestions please let me know. Thanksd
KirupaForum > Flash > ActionScript 1.0/2.0
Posted on: 11-11-2004, 06:02 PM
View Complete Forum Thread with Replies
See Related Forum Messages: Follow the Links Below to View Complete Thread
Accessing Sound Objects From External Swf?
how's it goin'?
I've been having trouble accessing sound objects that are located in an external swf. Essentially I've generated the sound objects in actionscript so that I don't have to link and create movie clips etc - the sound objects are now loaded into an associative array.... The code is similar to
http://www.sonify.org/home/feature/...tesoundobjects/
It plays fine in it's own swf, but as soon as I loadMovie() this swf into another one, my sounds are not playing - nor can I refer to them. How would I go about and access these sounds?? If ya'll have any suggestions please let me know. Thanks
d
Problem Accessing Sound Objects In External Swf
how's it goin'?
I've been having trouble accessing sound objects that are located in an external swf. Essentially I've generated the sound objects in actionscript so that I don't have to link and create movie clips etc - the sound objects are now loaded into an associative array.... The code is similar to
http://www.sonify.org/home/feature/r...esoundobjects/
It plays fine in it's own swf, but as soon as I load this swf into another one, my sounds are not playing - nor can I refer to them. How would I go about and access these sounds?? If ya'll have any suggestions please let me know. Thanks
d
Problem Accessing Sound Objects In External Swf
how's it goin'?
I've been having trouble accessing sound objects that are located in an external swf. Essentially I've generated the sound objects in actionscript so that I don't have to link and create movie clips etc - the sound objects are now loaded into an associative array.... The code is similar to
http://www.sonify.org/home/feature/r...esoundobjects/
It plays fine in it's own swf, but as soon as I load this swf into another one, my sounds are not playing - nor can I refer to them. How would I go about and access these sounds?? If ya'll have any suggestions please let me know. Thanks
d
AS3 Accessing External SWF Objects
Hello
I do understand that in Flash 8 (AS2) you can create and empty clip, then load SWF file and access objects inside it through this movieclip. For example if I have an instance of somethig called "inst" and I compile SWF, then after I load it in another project I can do MovieClipName.inst._x = 50;
Now in Flash 9 (AS3) I cant do that, since I have to use the loader, and if I try to do LoaderName.inst._x = 50 - that would not work. So how should I have to do this now?
In few words I have a project called MainProject.fla there I load up a movie with this:
var _ldr:Loader = new Loader;
var _req:URLRequest = new URLRequest("test.swf");
_ldr.load(_req);
Now in test.swf I have a bitmap with instance called "MyBitmap" . How can I change position of that bitmap in that SWF file after I load it?
Accessing Objects Into External Loaded Swf.
Hi guys,
I'm loading a external swf and i want add a action to a object into that swf. I have a button into the main swf and when this button was pressed i want than a object into the external swf execute a action. How i can make this.
This is my code so far.
Code:
var placeHolder:MovieClip = new MovieClip()
placeHolder.x = 0;
placeHolder.y = 100;
addChild(placeHolder);
var ld:Loader = new Loader();
var swf:URLRequest = new URLRequest("child.swf");
ld.load(swf);
placeHolder.addChild(ld);
botao.buttonMode = true;
botao.addEventListener(MouseEvent.CLICK, clickHandler);
function clickHandler(mEvent:MouseEvent):void
{
placeHolder.ld.myMc.x = 150;
}
Accessing The Sound Of An External Swf
i am loading a swf of an embeded video. i have no source fla, and when i remove the Loader that loads this swf, i can still here the sound. How can i access the sound object of this swf? I am trying to discover how to utilize the soundTransform class, but maybe that is not the way? I know it is with a NetStream, but i have not worked with embeded video from a swf in this way before
Trouble Getting Sound Objects Working In An External SWF
I have tried targetting the root, and just keeping the targetting within the external swf, neither system works. As of now I have all the objects activated on the root level.
Does anyone know a way around this. Here's the Fla's for reference
(only the intro page is active)
parent movie:
http://www.spfstudios.com/temp_fla/spf_index.fla
Child:
http://www.spfstudios.com/temp_fla/spf_intro_sc.fla
Thanks in advance...
Sound Objects No Longer Play External Swf HELP
I have several flash games and quizzes that I now want to put together as a collection on a CD ROM as a bumper pack to buy.
I wasn't sure of the best way to do that but I figured that I can create a flash file with individuals buttons on that when pressed loads that SWF's into the main page and plays which I'll export as a standalone player.
Sound good that's just what I wanted, only problem now is that the sound objects that are in the various games no longer play!
What do I need to do so that they will play as they do when I play each SWF on their own? (Hopefully without too much re-programming of the original games as there are quite a few)!
Any help would be appreciated.
Attn: Everyone - CRaZy Sound Objects & External SWFs
i know this is an incredible long post, but please guys stretch your patience and help out a poor soul
guys, i am trying to load external SWFs that contain sound objects in to _level1. fair enough it loads and plays with the following code, the code is stored in a dummy MC with instance name 'calendar'
Code:
onClipEvent(load){
//load external swf
loadMovieNum("track1.swf",1);
trigger=false;
}
onClipEvent (enterFrame) {
//external swf music preloader
total=_level1.getBytesTotal();
loaded=_level1.getBytesLoaded();
percent=(int((loaded/total)*100));
if(percent==100&&trigger==false){
_level1.audio();
trigger=true; // sets trigger to true so that sound object isnt initialised again to avoid sound layering.
}
}
i have 2 buttons both unload the movie from _level 1 when they are pressed, hence stopping the sound object playing. upon release, each one then loads its own corresponding swf in to level1. my problem is that after unloading the current movie from _level1, the movie loads the next swf in to level 1 however it doesnt play the sound object. It begins to play for a fraction of a second then just stops
code for buttons, button 1:
Code:
on (press) {
unloadMovieNum (1);
_root.calendar.trigger = false;
}
on (release) {
loadMovieNum ("track1.swf", 1);
}
code for button 2:
Code:
on (press) {
unloadMovieNum (1);
_root.calendar.trigger = false;
}
on (release) {
loadMovieNum ("track1.swf", 1);
}
here is the code for each of my external SWF files, each sound object is placed on the first frame of the timeline in each movie.
track1.swf
Code:
function audio () {
track = new Sound(this);
track.attachSound("track1");
track.start(0, 90000);
}
track2.swf
Code:
function audio () {
track = new Sound(this);
track.attachSound("track2");
track.start(0, 90000);
}
please help!!! i've been through this a thousand times but i cant find the rotten apple. chances are its a little syntax error i have made with the button code shown above.
i would like to thank you in advance for making the effort for firstly reading this and posting up possible solutions.
if you are unclear what i mean please send me your email addresses and i will forward you the FLAs. many thanks.
Sound Objects - How-to Preload Multiple Sound Objects
Im basically making a site for a sound engineer friend of mine, and like Im trying to make a music interface for his site, thats able to preload tracks, and play & load those multiple mp3 tracks dynamically (mp3s are in the same folder). Or the setup could be like multiple sound objects that have their own progress bar etc for loading kinda like the will-musser example. Im up for any suggestions as the MM docs dont help in this area very much
A good example of this would be @t http://www.willmusser.com. I under-stand how-to create and use 1 sound object for example, but when i try and use 2 sound objects etc, for 1 dynamic textfield named "progress", heres the coding to call-upon a sound object, which is basically 1 mp3 thats getting loaded, and shows progress in percentage via that dyamic textfield. What Im wondering, is if anyone knows of the AS for the btns to load tracks ie: on (release), load mp3"blaghla.mp3" ? if anyone knows the coding to load mp3s, feel free to leave a reply ;p And any good ways of calling upon multiple sound objects at once seperate dynamic textifelds or progress bars for loading etc.
PHP Code:
sound_1 = new Sound();
sound_1.loadSound("http://themakers.com/sounds/atmospheres_1.mp3", true);
function checkLoad(){
var percentLoaded = (sound_1.getBytesLoaded()/sound_1.getBytesTotal())*100;
progress.text = Math.round(percentLoaded)
message.text = "MEK - Far From Home";
}
checkProgress = setInterval(checkLoad, 1000);
Accessing Objects
Hi!
This is my first post here, so be nice to me )
How can i get access to objects which objectnames are saved in a string?
such as: (doesn't work)
nameOfTextfields = new Array("foobar1", "foobar2");
nameOfTextfields[0].text = "foobar";
i've tried the tellObjects() function, but isn't there an easyer way?
thx!
Accessing Objects Without Name
I put few Objects in the stage. Now I need to label them so I used the following code.
ActionScript Code:
var objectList:Array=new Array("apple","ball","cat","dog");
for(var i:uint=0;i<objectList.length;i++)
{
var obj:Object = getChildByName(objectList[i]);
var labelText:TextField=new TextFeild();
labelText.text="This is "+objectList[i];
labelText.x=obj.x;
labelText.y=obj.y;
addChild(labelText);
}
Yeppy! everything works.
Now there is a button called "clear". When it is pressed all the labels needs to be cleared.
Naturally, if I do labelText.text="", only the last label is cleared.
Any idea to clear all of them?
Accessing Objects In An Array
I have a card matching game I'm working on. My idea is that when two cards are turned over, they are placed in an Array. The array then checks to see if they are a match. The issue is that the card instance names will not match since both cards need to have different instance names onstage. I've tried just having the cards dump a number into the array, so then the numbers will match; but if it's not a match, I can't make the specific cards that were selected turn back over.
I could use two arrays, one for numbers and one that will hold the card MCs, but I was hoping there was a more elegant, streamlined solution.
To sum up, i guess my question is this...
When i've put an object like a movie clip instance into an array, can I use the array to access the objects' variables, functions, or anything so I can use THAT information to compare the cards other than their instance names?
Accessing Objects In Other Functions.
I'm working on a flash video player and I'm trying to figure out how to access something inside the constructor that I know is set but it keeps telling me its not.
Here is the code
ActionScript Code:
package player {
import flash.display.Sprite;
import flash.media.Video;
import flash.net.NetStream;
import flash.net.NetConnection;
import flash.utils.Timer;
public class InfernoPlayer extends Sprite {
// Declare variables
var vWidth:Number = 720;
var vHeight:Number = 480;
var duration:Number;
var ratio:Number;
// Set up the stream and video object
public function InfernoPlayer() {
// Create the video object
var video:Video = new Video(vWidth, vHeight);
addChild(video);
// Create a new NetConnection and connect / open a NetStream channel
var netCon:NetConnection = new NetConnection();
netCon.connect(null);
var netStream:NetStream = new NetStream(netCon);
// Set up the meta data handler and resize video if it is to small/large
var meta:Object = new Object();
meta.onMetaData = metaData;
netStream.client = meta;
// Attach video to the NetStream and start then pause playback
video.attachNetStream(netStream);
netStream.play("videoURL");
}
private function metaData(meta:Object):void {
var duration = meta.duration;
var ratio = meta.height / 480;
video.width = meta.width / ratio;
video.height = meta.height / ratio;
}
}
}
now in the metadata function its giving me the error, "Access of undefined property video"
Now, am I just completely not understanding how classes work or is this a common problem?
Accessing Objects Inside Another Swf
I am trying to keep from building one large swf in order to help a broswer window to launch more readily (28k modem audience). Can I have a button in one swf run a movie clip inside another swf in this same browser window?
Thanks
Help With Accessing Dynamic Objects
Hi all
Ok its my third day on the AS3 learning curve, go easy on me:)
Hit a problem and hope someone can help..
I have created a several child objects (MovieClips) they inturn have their
own birthed objects inside them
MC_Holder < MC_Holder_Preload < MC_Holder_Preload_TextField
MC_Holder < MC_Holder_Sprite < MC_Holder_Image
So MC_Holder has two child MC's etc etc
This all works fine!
The problem im having is that when "MC_Holder_Image" runs, the
ProgressEvent.PROGRESS listener needs to update the
"MC_Holder_Preload_TextField", just wondering how i get the information into
this dynamic object...
There are 32 of these at present they all have been given names from a loop
("Name "+i)...
So the objects i will need to update will be "MC_Holder_Preload_TextField_0"
through "MC_Holder_Preload_TextField_31"
private function progressHandler (event:ProgressEvent):void
{
event.target--->NEED HELP HERE<--- = event.bytesLoaded;
}
Everyrthing works fine, the images are loading from an XML schema etc etc...
Sorry if that sounds crazy, late here 04:44 infact...lol, coffee for the
correct answer!
Thanks
Rick
Code For The Class :
package
{
import flash.display.MovieClip;
import flash.display.Sprite;
import flash.events.*;
import flash.net.*;
import flash.display.*;
import flash.net.URLRequest;
import flash.text.TextField;
import flash.text.TextFormat;
import flash.text.Font;
import flash.text.*;
import xmllist;
public class imagemc extends MovieClip
{
public var ldr:Loader = new Loader();
public var holder_Preloader:MovieClip = new MovieClip();
public function imagemc (xmlArray,URLimages):void
{
trace ("CLASS CONSTRUCTOR : IMAGEMC");
for (var i:int=0; i<xmlArray.length; i++)
{
buildSlideContent (xmlArray,URLimages,i);
}
}
public function buildSlideContent (xmlArray,URLimages,i):void
{
// CREATE MAIN CLIP
var holder:MovieClip = new MovieClip();
holder.graphics.lineStyle (1, 0xFF0000, 1);
holder.graphics.moveTo (0, 0);
holder.graphics.lineTo (760, 0);
holder.graphics.moveTo (760, 0);
holder.graphics.lineTo (760, 390);
holder.graphics.moveTo (760, 390);
holder.graphics.lineTo (0, 390);
holder.graphics.moveTo (0, 390);
holder.graphics.lineTo (0, 0);
holder.name = "MC_Holder_"+i;
holder.x = 0;
addChild (holder);
// IMPORT TEXT
var Font_Levenim:Font=new Font1();
var Font_Levenim_Format:TextFormat = new TextFormat();
Font_Levenim_Format.font=Font_Levenim.fontName;
// CREATE TEXT FIELD //
var holder_Preloader_Text:TextField = new TextField();
holder_Preloader_Text.defaultTextFormat = Font_Levenim_Format;
holder_Preloader_Text.embedFonts = true;
holder_Preloader_Text.name = "MC_PRELOADER_TEXT_1_"+i;
holder_Preloader_Text.x = 0;
holder_Preloader_Text.y = 10*i;
holder_Preloader_Text.width = 350;
holder_Preloader_Text.height = 20;
holder_Preloader_Text.border = false;
holder_Preloader_Text.background = false;
holder_Preloader_Text.text = "HELLO";
holder_Preloader_Text.textColor = 0xFF0000;
holder_Preloader_Text.multiline = false;
holder_Preloader_Text.wordWrap = false;
holder_Preloader_Text.selectable = false;
// CREATE PRELOADER CLIP //
var holder_Preloader:MovieClip = new MovieClip();
holder_Preloader.graphics.lineStyle (1, 0xFF6600, 1);
holder_Preloader.graphics.moveTo (0, 0);
holder_Preloader.graphics.lineTo (760, 0);
holder_Preloader.graphics.moveTo (760, 0);
holder_Preloader.graphics.lineTo (760, 390);
holder_Preloader.graphics.moveTo (760, 390);
holder_Preloader.graphics.lineTo (0, 390);
holder_Preloader.graphics.moveTo (0, 390);
holder_Preloader.graphics.lineTo (0, 0);
holder_Preloader.name = "MC_PRELOADER_"+i;
holder_Preloader.x = 0;
holder.addChild (holder_Preloader);
holder_Preloader.addChild (holder_Preloader_Text);
// CREATE IMAGE HOLDER SPRITE
var holder_Sprite:Sprite = new Sprite();
holder_Sprite.graphics.lineStyle (1, 0xFF6600, 1);
holder_Sprite.graphics.moveTo (0, 0);
holder_Sprite.graphics.lineTo (760, 0);
holder_Sprite.graphics.moveTo (760, 0);
holder_Sprite.graphics.lineTo (760, 390);
holder_Sprite.graphics.moveTo (760, 390);
holder_Sprite.graphics.lineTo (0, 390);
holder_Sprite.graphics.moveTo (0, 390);
holder_Sprite.graphics.lineTo (0, 0);
holder_Sprite.name = "SP_Holder_"+i;
holder_Sprite.x = 80;
holder.addChild (holder_Sprite);
// CREATE IMAGE
var ldr:Loader = new Loader();
ldr.name = "IMG_"+i;
var url:String = URLimages+xmlArray;
var urlReq:URLRequest = new URLRequest(url);
ldr.load (urlReq);
ldr.x = 0;
configureListeners (ldr.contentLoaderInfo);
holder_Sprite.addChild (ldr);
}
private function configureListeners (dispatcher:IEventDispatcher):void
{
dispatcher.addEventListener (Event.COMPLETE, completeHandler);
dispatcher.addEventListener (HTTPStatusEvent.HTTP_STATUS,
httpStatusHandler);
dispatcher.addEventListener (Event.INIT, initHandler);
dispatcher.addEventListener (IOErrorEvent.IO_ERROR, ioErrorHandler);
dispatcher.addEventListener (Event.OPEN, openHandler);
dispatcher.addEventListener (Event.UNLOAD, unLoadHandler);
dispatcher.addEventListener (ProgressEvent.PROGRESS, progressHandler);
}
private function completeHandler (event:Event):void
{
trace ("HANDLER : COMPLETED > " + event +
event.currentTarget.loader.name);
}
private function openHandler (event:Event):void
{
trace ("HANDLER : OPEN > " + event + ldr);
}
private function progressHandler (event:ProgressEvent):void
{
---------------------------------------------------------------------------------------------------------->
HELP event.target.="HOOOOOOOOOOOOO"; <-----
trace ("HANDLER : PROGRESS LOADED > " + event.bytesLoaded + " total: " +
event.bytesTotal);
}
private function securityErrorHandler (event:SecurityErrorEvent):void
{
trace ("HANDLER : SECURITY > " + event);
}
private function httpStatusHandler (event:HTTPStatusEvent):void
{
trace ("HANDLER : HTTP STATUS > " + event);
}
private function ioErrorHandler (event:IOErrorEvent):void
{
trace ("HANDLER : I O ERROR > " + event);
}
private function unLoadHandler (event:Event):void
{
trace ("HANDLER : UNLOADED > " + event);
}
private function initHandler (event:Event):void
{
trace ("HANDLER : INIT > " + event);
}
}
}
Accessing The Tab Order Of Objects
Hello,
I am having difficulty determining the identity of the next object in the tabbing order. I set the tabIndex of a group of text fields as they are attached and upon running the app the tab key works as expected. However, another requirement is that upon a condition (say length of field reached while typing) I want to actionscript to move the focus to the next text field in the tabbing order. The problem is I don't know what field that is.
getFocus() will return me a tabIndex of the field I am on. But setFocus() wants an object name. focusManager has a nextTabIndex property but there again, just a number. I could build my own array of objects as I set the tabIndex, but that seems a little clunky and operates independently of Flashes handling of it.
I understand this functionality was meant for use with the tab key, but it sure would be nice to query against wherever Flash has stored its reference to objects in tab order. Is that possible? Or is there another way to approach moving the focus the next field without requiring a tab keystroke?
Thanks for any help you may provide.
Accessing Array Within XML Objects
Here's my code:
Code:
function loadProjects(loaded){
if(loaded){
projects = this.firstChild.childNodes;
projectName = new Array();
projectImage = new Array();
projectDesc = new Array();
projectShtDesc = new Array();
projectLink = new Array();
projectNext = new Array();
for(i = 0;i < projects.length;i++){
projectName.push(projects[i].attributes.name);
}
trace(projectName);
trace(projectName.length);
}
else {
trace("PROJECTS NOT LOADED");
}
}
projectData = new XML();
projectData.ignoreWhite = true;
projectData.onLoad = loadProjects;
projectData.load("projectData.xml");
var numProjects = projectName.length;
trace(projectName);
trace(numProjects);
the traces within the function return correct results, however when trace values of the arrays within the function and created by the xml are attempted results are returned 'undefined'.
Why can I not access arrays made in this way from outside of the function?
thanks!
Accessing Objects Within MovieClips
I'd like to use instance names to access movie clips that are inside other movie clips, which may be inside other movie clips, etc. Everything works fine until things start moving, and then instance names become weird...
Sometimes, I can access the instance name, but tracing the position reveals that it isn't moving (even though I can see it moving on the screen!)
Sometimes, I can't even access the instance name, and even getChildByName returns null.
It's been driving me crazy for days now... Could anyone shed some light on this issue, what's going on???
Thanks a lot!
Emil
Accessing Objects In DisplayList
Hi,
I have problem with accessing objects in AS3.0.
Suppose I write this code on MainTimeLine:
Code:
var sprite1:Sprite = new Sprite();
var sprite1Child:Sprite = new Sprite();
sprite1.addChild(sprite1Child);
addChild(sprite1);
//custom class
var myMC:myMovieClip = new myMovieClip();
Now from myMC I want to reference sprite1Child object.
How?
To access sprite1 I use this code inside myMC:
Code:
this.parent.getChildAt(0)
That works, but I can’t reference sprite1Child which is inside sprite1.
Thanks,
Accessing Objects On Stage
Hello all,
Could someone explain me the concept of objects at the stage? How I would access them.
For example: I've made 3 classes, in one of them I made an container that contains a Circle. In another class I want to access them. So I know the structure of the stage is now as follow:
stage
_ container
____ circle
First I thought about giving the container a name so I could access it with getChildByName(). Only when I try stage.getChildByName() I get the error that I cannot access a property or method of a null object reference.
Thanks in advance
Accessing Objects In Other Functions
I'm having difficulty controlling objects created in one function, by another function. I'm adding the children to the stage, stage.addChild("lrg" +i), and trying to reference the children by stage["lrg"+id]. I think I'm just doing something wrong with the syntax. Any ideas?
Here's the error I'm getting:
Code:
ReferenceError: Error #1069: Property lrg8 not found on flash.display.Stage and there is no default value.
at playertest2_fla::MainTimeline/showPicture()
And here's the relevant code:
Code:
function loadXML(event:Event):void {
currentPlaying = 0;
xml = XML(event.target.data);
xmlList = xml.children();
for (var i:int=0; i < xmlList.length(); i++) {
imageLoader = new Loader();
imageLoader.load(new URLRequest(searchAndReplace(xmlList[i].attribute("tn"), "/tn/", "/tn2/")));
imageLoaderBig = new Loader();
imageLoaderBig.load(new URLRequest(xmlList[i].attribute("tn")));
imageLoaderBig.y = 268;
imageLoaderBig.x = i * 50 - 18;
imageLoaderBig.alpha = 0;
imageLoaderBig.name = "lrg" + i;
stage.addChild(imageLoaderBig);
this["myHolder" + i] = new MovieClip();
stage.addChild(this["myHolder" + i]);
this["myHolder" + i].y = 335;
this["myHolder" + i].x = i * 50 + 10;
this["myHolder" + i].addChild(imageLoader);
imageLoader.name = "id" + i;
this["myHolder" + i].addEventListener(MouseEvent.MOUSE_OVER, showPicture);
this["myHolder" + i].addEventListener(MouseEvent.CLICK, showVideo);
}
}
function showPicture(event:MouseEvent):void {
var hovered = searchAndReplace(event.target.name, "id", "");
trace(hovered);
trace(stage["lrg"+id]);
}
Accessing Class Objects Via The Name
Hello
I have a class name Contents I am creating 5 objects of this class. Is there a way to keep track of the instance names assigned to the objects. What I am doing is get all the objects of Contents class and make button out of these and when user clicks a button the I want to reterieve descrioption from Contents class but I dont have any mean of storing the instance name. I think I am not making any sense so here is some code
Code:
public class TestContent extends EventDispatcher
{
//Class properties
private var _desc:String;
private static var _children:Array = new Array();
// Class Constructor
public function TestContent(name:String, desc:String)
{
// I want to store the name assigned to this object so I can use this later
this.instanceName = name;
_desc = desc;
TestContent._children.push(this);
}
public function get name():String
{
return this.instanceName;
}
public function get desc():String
{
return _desc;
}
public static function getChildren():Array
{
return _children;
}
So in another class I am using the number of objects of this class to create buttons
Code:
//Some other class
parentSprite:Sprite = new Sprite;
var mArray:Array = new Array;
mArray = TestContents.getChildren();
for (i = 0; i<mArray.length; i++)
{
var mc:MovieClip = new MovieClip(mArray[i])
parentSprite.addChild(mc);
}
parentSprite.addEventListener(MouseEvent.CLICK, onClikc);
public function onClick(e:MouseEvent):void
{
// here I wanna use the instance name of the TestContents object to call the desc property
trace(e.target.desc);
}
I hope I am making sense here
Thanks in advance
Accessing Data In Objects
I posted on the XML boards but later realized that this particular question is more of a Actionscript question.
I just used Branden Hall's ©Deserializer to convert WDDX into a flash object. The object mimics the structure of the wddx (xml nodes). How can I properly access the data in an Object (with nodes of data)?
Accessing Objects In Other Functions
I'm working on a flash video player and I'm trying to figure out how to access something inside the constructor that I know is set but it keeps telling me its not.
Here is the code
Code:
package player {
import flash.display.Sprite;
import flash.media.Video;
import flash.net.NetStream;
import flash.net.NetConnection;
import flash.utils.Timer;
public class InfernoPlayer extends Sprite {
// Declare variables
var vWidth:Number = 720;
var vHeight:Number = 480;
var duration:Number;
var ratio:Number;
// Set up the stream and video object
public function InfernoPlayer() {
// Create the video object
var video:Video = new Video(vWidth, vHeight);
addChild(video);
// Create a new NetConnection and connect / open a NetStream channel
var netCon:NetConnection = new NetConnection();
netCon.connect(null);
var netStream:NetStream = new NetStream(netCon);
// Set up the meta data handler and resize video if it is to small/large
var meta:Object = new Object();
meta.onMetaData = metaData;
netStream.client = meta;
// Attach video to the NetStream and start then pause playback
video.attachNetStream(netStream);
netStream.play("videoURL");
}
private function metaData(meta:Object):void {
var duration = meta.duration;
var ratio = meta.height / 480;
video.width = meta.width / ratio;
video.height = meta.height / ratio;
}
}
}
now in the metadata function its giving me the error, "Access of undefined property video"
Now, am I just completely not understanding how classes work or is this a common problem?
Accessing Objects Within Objects
Hey there,
What I'm trying to do is somehow assign the same class to a large number of movieclips within another movieclip. The nested mcs are already on stage in the positions that they need to be in. I need to go through all of the 200+ nested mcs and apply the same actions to them.
In AS2.0, I would loop through and do something like this...
Code:
for(var i in someObject){
if(typeof someObject[i] == "movieclip"){
someObject[i] = new objectClass();
}
}
What's an equivalent way of going about this? Any ideas?
Accessing Parent HTML's Objects
Hi,
I would like to access certain HTML tags' value in the flash.
My flash is embedded in a HTML page and there are several check boxes in the page. When user clicks a button in the flash, it needs to retrieve the value of the check boxes.
What would be the best way of achieving this ?
I am a little desparate ^^ Please let me know !!
Thanks in advance,
Keeyong
Accessing Objects From Other Embedded SWFs
Hi,
I'm working on a project adapting some stuff and the way it's working leads me to believe they may have had one embedded SWF accessing a global object in another embedded SWF. Is that actually possible, and if it is can someone tell me how 'cause it'd save me a hell of a lot of hassle.
Thanks.
Creating And Accessing Objects Dynamically
Hi,
I'm experiencing some serious AS2 to AS3 transition problems
I have a movieclip in the library that I place on stage using a custom class. It works fine by all means. The thing is that I want to create six instances (if that's the right word nowadays) that I want to access from other functions (one function is to animate all six instances). My problem is that I would expect all created objects to be accessible via their .name but they are not... Instead, the only way that I can access them is through the variable that I use to create the object instances (var myVariable:myClass = new myClass()). My problem then is that I don't want to predefine six variable names for this (the idea is to make something scalable) and that's when I really get lost. How on earth do I either 1) create dynamic variable names (i.e. "variable_"+i) or 2) access the created object instances on stage (that should be able to get to in one way or another...)?
Thanks a lot in advance.
.cristian
Accessing Objects Within Instances Of Components
I have my stage, that has an instance of the avpresence component on it,
Basically there are several webcams, all share the same properties but I want one to be different
Right, I can get to some objects within the property using the following code:
_root.mainwebcam_cc.sit_button._x = 10; _root.mainwebcam_cc.sit_button._y = 132;
_root.mainwebcam_cc.seat_video._width = 180; _root.mainwebcam_cc.seat_video._height = 135;
mainwebcam_cc is the instance and sit_button and seat_video are objects within the component, be it buttons or movie clips
There are objects I want to move on the 3rd frame within the timeline (it may or may not get to frame 3 depending on certain things but if it does, I want to be able to move the objects) the above methods don't work, is there something else I need to do?
For example, camBtn_mc appears on frame 3 within the component but
_root.mainwebcam_cc.camBtn_mc._x = 10; doesn't do anything from on the main timeline
I have to do this outside of the component as if I try and position stuff from within the component it affects all instances and not just the one I need to concentrate on.
Dave
Accessing Shared Objects From Classes
I'm trying to use a SharedObject to send/receive messages in a text area (basically a chat applet). However I've run into a problem where I can't seem to pass the SO to a constructor and then use it inside the object.
This is a sample:
quote:so = SharedObject.get("users_so", null);
function chat(so) {
this.so = so;
// also tried var this.so, and var so
}
chat.prototype.cmsg(msg) {
this.so.send("chatmsg", msg);
}
c = new chat();
c.cmsg("test");
It works when I create the SharedObject in application.onAppStart and call it from the main application.* events. However the moment I try moving it anywhere else (as a properly structured application really should...) it balks.
Any ideas? I'm pretty sure this has something to do with passing by reference not-existing in ActionScript, but I've read that by passing an object in, it gets passed by reference...
Edited: 11/28/2006 at 01:10:28 AM by seraerie
Accessing Display Objects Via The Stage Var
I'm passing a stage reference to my class, but when I try to access a movieclip on the stage I get an error.
this gives me an error:
var mc = targetStage.myMovieClip;
Thanks!
Attach Code
package {
import flash.display.Stage;
import flash.display.MovieClip;
public class MyClass {
private var targetStage:Stage;
public function MyClass ( aStage:Stage) {
targetStage = aStage;
var mc = targetStage.myMovieClip;
}
}
}
Accessing Objects Across Keyframes And Layers
Hello,
I'd like to have all my scripting in one layer and one keyframe, yet I can't seem to find how to access the instances across keyframes and layers.
for instance, beeing in layer1 and timeframe 1, how to access the objects in layer1 and timeframe 2 ? a concrete example, I have a login screen that navigates to a main screen, and I'd like to make most the main screen components invible for the first navigation.
_root.gotoAndStop(2)
frame2Object._invisible = false
works OK.
however the screen flashes, and I'd like to do
(...).frame2Object._invisible = false
in the init of the flash doc and then
_root.gotoAndStop(2)
is this possible ?
thank you.
Sebastien.
Accessing Properties And Methods Of Like Objects
Hello.
Is there a straightforward means of limiting access to a class's properties and methods to other instances of that class? For instance, say we have two instances of the Example class. Is there a way to allow one instance to access certain properties of the other, but to prevent any instance of any class that is not Example from accessing the same properties? (That includes non-Example classes in the same package as Example- I know about the internal namespace. But I like the way you're thinking.)
I'm tempted to do something with custom namespaces, but I'm not very experienced with them. Any ideas?
Accessing A List Of Objects Within A Movieclip.
Hi all,
I've been searching around most of the day for an answer, however everything has turned up a blank. So I hope someone can help me here.
I have a movie clip on my scene with a number of objects all prefixed with a keyword 'build' (e.g. 'build8934', 'build4920') - is there any method, array or object that I can access that would give me access to a list of objects for that movie clip?
I'm intending to loop through an add events to an instance which matches the prefix 'build' and set additional properties based off that instance.x.
Thanks and cheers in advance.
Beza.
Accessing Dynamic Added Objects
I'm building an videoplayer with XML list.
I dynamically add multiple instances of a movieclip from the library (to hold the contents) to a movieclip called Holder wich is on the stage.
The instances are named Disp0 to Disp5.
So far it works out.
But how do I access these instances, my thought was:
Holder.Disp0
Why isn't this working?
Problem(I Think...) Accessing Instance Objects.
First up, my first post here, so hi to all.
Ok the problem I've got isn't really a bug, I mean the code does what I want so far, but I think I might going about it the wrong way. Simple game, a breakout clone in AS3, although this time I was messing about splitting it up into classes, but was having trouble accessing instances of those classes...
Way I got around it was to... add them to arrays... example, creating an instance of a menu...
Code:
var menuItem = new MainMenu();
menuArray.push({aButton:addChild(menuItem.createStartBtn())});
menuArray.push({aButton:addChild(menuItem.createOptionBtn())});
// some time later
menuArray[0].aButton.x = 10;
That cant be right though can it? I mean I was ok with it when I was sticking instances of blocks and player paddle etc into arrays, but now sticking the menu screen into an array?
Is there a better way of accessing them, other then adding them to an array like that?Or am I just worrying about nothing?
EDIT: Well, doesn't look like I'm going to get a reply to this thread... but no worries, I found a better solution, for anyone else who might suffer a brain fart like I did and finds this, make the external class return an object, and in the main class be sure to have an object variable handy ( var bla:Object; ), just assign the returned object to that, no need for arrays. If object variable has scope, no problems accessing it form anywhere else.
Accessing Objects Across Keyframes And Layers
Hello,
I'd like to have all my scripting in one layer and one keyframe, yet I can't seem to find how to access the instances across keyframes and layers.
for instance, beeing in layer1 and timeframe 1, how to access the objects in layer1 and timeframe 2 ? a concrete example, I have a login screen that navigates to a main screen, and I'd like to make most the main screen components invible for the first navigation.
_root.gotoAndStop(2)
frame2Object._invisible = false
works OK.
however the screen flashes, and I'd like to do
(...).frame2Object._invisible = false
in the init of the flash doc and then
_root.gotoAndStop(2)
is this possible ?
thank you.
Sebastien.
Accessing Class Objects Instance Name
Hello
I have a class name Contents I am creating 5 objects of this class. Is there a way to keep track of the instance names assigned to the objects. What I am doing is get all the objects of Contents class and make button out of these and when user clicks a button the I want to reterieve descrioption from Contents class but I dont have any mean of storing the instance name. I think I am not making any sense so here is some code
Code:
public class TestContent extends EventDispatcher
{
//Class properties
private var _desc:String;
private static var _children:Array = new Array();
// Class Constructor
public function TestContent(name:String, desc:String)
{
// I want to store the name assigned to this object so I can use this later
this.instanceName = name;
_desc = desc;
TestContent._children.push(this);
}
public function get name():String
{
return this.instanceName;
}
public function get desc():String
{
return _desc;
}
public static function getChildren():Array
{
return _children;
}
So in another class I am using the number of objects of this class to create buttons
Code:
//Some other class
parentSprite:Sprite = new Sprite;
var mArray:Array = new Array;
mArray = TestContents.getChildren();
for (i = 0; i<mArray.length; i++)
{
var mc:MovieClip = new MovieClip(mArray[i])
parentSprite.addChild(mc);
}
parentSprite.addEventListener(MouseEvent.CLICK, onClikc);
public function onClick(e:MouseEvent):void
{
// here I wanna use the instance name of the TestContents object to call the desc property
trace(e.target.desc);
}
I hope I am making sense here
Thanks in advance
Accessing Built Objects That Are Not In Display List?
I have a routine that loops through an XML file and builds out the necessary sprites. The thing is, I don't want to add them to the display list right then and there. I want to wait for the user to perform an action before adding it to the screen.
What I've done is add it to the stage using the this.addChild(sprite); and then setting the alpha to 0. I dont want to do this.
When I remove the this.addChild(sprite);, I am assuming the sprite is still being built but not added to the display list. How do I access that sprite once the user clicks a button? I can't use this.getChildByName(sprite name); since its not in the display list...
What's the best method to prebuild objects and wait to load to the stage based off user interaction?
Help!
Thanks!!
Accessing Properties Of Objects Stored In 2D Arrays
I'm looking to put together a bit of code that dynamically scales a field of movie clips based off of the user's mouse movements. I have the code that scales a single movie clip written, and I've filled a two-dimensional array (an array filled with other arrays, which are in turn filled with objects, which have clips attached).
So my question is: how do I access the properties (scaleX and scaleY, specifically) of those movie clips?
Thanks, and much love.
Accessing Values From Dynamic Objects Problem...
I have a loop which creates dynamic objects from a class (MenuBulletClass) and adds it into my container (menu_select_list_container:MovieClip). I'm having problems getting properties/variables back from a specific object for example below.
PHP Code:
for (i=0; i < 8; i++) { var menuBulletObject:MenuBulletClass = new MenuBulletClass(); menuBulletObject.name = "bullet" + i; menuBulletObject.xml_selection = i; menu_select_list_container.addChild(menuBulletObject); } trace(menu_select_list_container.getChildByName("bullet1").xml_selection);
It throws a "1119: Access of possibly undefined property xml_selection through a reference with static type flash.displayisplayObject." error. I'm really stumped on this and the answer will probably be laughable. Anyone? Thanks!
Accessing Objects On Specific Frames From Document Class
I have a button that exists on a certain frame in my flash movie. In my document class, I try to assign an action to that button but I'm getting a null reference error when I run the movie. Here's what the trace window reports:
Code:
onConnect1 running! chatService has connected.
TypeError: Error #1009: Cannot access a property or method of a null object reference.
at MethodInfo-289()
at flash.events::EventDispatcher/dispatchEventFunction()
at flash.events::EventDispatcher/dispatchEvent()
at net.flashmog::FlashMOGService/socketConnectHandler()
It got me wondering about whether it's possible to reference components or objects that exist on particular frames in a document class. Is it possible?
Here's the document class:
PHP Code:
package {
import fl.controls.TextArea;
import flash.display.MovieClip;
import flash.events.*
import flash.text.TextField;
import net.flashmog.FlashMOGService;
/**
* A simple chat application.
*/
public class ChatExample extends MovieClip {
private var lastErrorMessage:String = '';
private var chatService:FlashMOGService;
public function ChatExample() {
this.stop();
chatService = new FlashMOGService('74.94.218.51', 1234, 'chatService');
configureListeners();
chatService.connect();
}
private function configureListeners():void {
chatService.addEventListener(Event.CONNECT, onConnect1);
function onConnect1(evt:Event):void {
trace('onConnect1 running! chatService has connected.');
gotoAndStop('username');
function submitClick(evt:MouseEvent) {
if (usernameText.length > 0) {
usernameStatusText.text = "Registering username with server...";
chatService.server.registerUsername(usernameText.text);
} else {
usernameStatusText.text = "You must enter a name!";
}
}
submitButton.addEventListener(MouseEvent.CLICK, submitClick);
} // onConnect
} // configureListeners
} // class ChatExample
} // package
Accessing Objects On Specific Frames From Document Class
I have a button that exists on a certain frame in my flash movie. In my document class, I try to assign an action to that button but I'm getting a null reference error when I run the movie. Here's what the trace window reports:
Code:
onConnect1 running! chatService has connected.
TypeError: Error #1009: Cannot access a property or method of a null object reference.
at MethodInfo-289()
at flash.events::EventDispatcher/dispatchEventFunction()
at flash.events::EventDispatcher/dispatchEvent()
at net.flashmog::FlashMOGService/socketConnectHandler()
It got me wondering about whether it's possible to reference components or objects that exist on particular frames in a document class. Is it possible?
Here's the document class:
PHP Code:
package { import fl.controls.TextArea; import flash.display.MovieClip; import flash.events.* import flash.text.TextField; import net.flashmog.FlashMOGService; /** * A simple chat application. */ public class ChatExample extends MovieClip { private var lastErrorMessage:String = ''; private var chatService:FlashMOGService; public function ChatExample() { this.stop(); chatService = new FlashMOGService('74.94.218.51', 1234, 'chatService'); configureListeners(); chatService.connect(); } private function configureListeners():void { chatService.addEventListener(Event.CONNECT, onConnect1); function onConnect1(evt:Event):void { trace('onConnect1 running! chatService has connected.'); gotoAndStop('username'); function submitClick(evt:MouseEvent) { if (usernameText.length > 0) { usernameStatusText.text = "Registering username with server..."; chatService.server.registerUsername(usernameText.text); } else { usernameStatusText.text = "You must enter a name!"; } } submitButton.addEventListener(MouseEvent.CLICK, submitClick); } // onConnect } // configureListeners } // class ChatExample} // package
Problem: [sound].setVolume(x) Controling Two Sound Objects In One Call...?
Hi there, hopefully some or at least one of you will be able to figure this out because it's wrecking my head!
Basically I'm writing a little looper player movie, that will play [x] number of techno/jungle/house/whatever music loops at the same time, and the user will be able to switch loops and turn loops on and off whenever they want to. I'd like to avoid putting sound in the timeline so I'm using sound objects to trigger the sound properties.
For a test, I've created two sound objects (these will later be in a 2D array), but for now- just two sound objects, I've attached the sound to the links in the library, and set the volumes on both sounds to 0. Both WAVs in the library have the linkage on "Export this symbol" and they are labelled/identified as "loop1_link", and "loop2_link"... (obviously without the quotes in the properties box). Here's the code:
// ---------------------------
loop_test1 = new Sound();
loop_test2 = new Sound();
loop_test1.attachSound("loop1_link");
loop_test2.attachSound("loop2_link");
loop_test1.setVolume(0);
loop_test2.setVolume(0);
loop_test1.start(0,999);
loop_test2.start(0,999);
// ---------------------------
So the sounds are triggered when the movie loads, and the start playing silently in the background for 999 loops.
Here's the problem:
In the interface of the movie, on click of a play button, I'm making a call to _root.loop_test1.setVolume(100) to turn that sound on, but when I make that call, the volume is set to 100 for BOTH loop_test1 AND loop_test2 !! I'm hearing both loops playing at the same time and I only want to hear just the one. Makes no sense to me because I'm only telling that ONE sound object to set it's volume to 100...
Any ideas? Any feedback/comments would be greatly appreciated.
Cheers,
Anthony
-Dublin, IE
Sound Control Volume For Multiple Sound Objects?
I've got a file with several scenes.
Each scene has controls with different sound object defined on the first scene. There is a constant background sound object playing over all scenes. I need to control the volume of multiple sound objects playing simultaneously and setting each to different volumes from these scenes.
e.g
_root.bgmusic.setVolume(20);
_root.s001.setVolume(100);
can this be done? When I try, all sounds playing are set to the same volume.
Thanks heaps in Advance!
Sound Control Volume For Multiple Sound Objects?
I've got a file with several scenes.
Each scene has controls with different sound object defined on the first scene. There is a constant background sound object playing over all scenes. I need to control the volume of multiple sound objects playing simultaneously and setting each to different volumes from these scenes.
e.g
_root.bgmusic.setVolume(20);
_root.s001.setVolume(100);
can this be done? When I try, all sounds playing are set to the same volume.
Thanks heaps in Advance!
Multiple Sound-objects Causes Sound To Overdrive
hey guys..
I've built a small game with multiple enemies firing stuff at the same time. And here's the problem.. each shot makes a sound by simply creating a sound-object like this:
var es:explSound_1=new explSound_1();
es.play();
..it can get very crowdy, and multiple sounds of the same type are played at the same time. The sound now overdrives and gets disturbingly loud.
Does anyone know how to prevent this from happening?
|