Passing objects to eventhandlers


Hy Guys!

Let me first introduce myself: I am Marcel, I live in the Netherlands.. I'm fairly new to Kirupa, that is, new to posting my problems/findings. I'm using flash (CS 3) now for allmost a year, and the threads in kirupa helped me through sometimes!

Now, my problem. I'm making my own Portfolio, and i have a problem with eventhandlers. I have a couple different objects, lets call em A, B, etc. I want to do the same things to these objects, when i hover over, or click on them. I want to do this with, obviously, event handlers. The tricky part is, i want to make a bunch of eventhandlers for every object, but all handlers have to call the same function. To do this, i have to put the object as an variable in the event handler. Only, this is not possible in AS3! How can i do this

Since this is my first thread here, i hope it is clear for you ! If it isn't, just ask!

Greetings!
Marcel
Posted On: Thursday 25th of October 2012 10:54:57 PM Total Views:  52
View Complete with Replies

RELATED TOPICS OF Flash / ActionScript PROGRAMMING LANGUAGE




MovieClip object not appearing on the stage after passing it to addChild()

Short explanation of my question: addChild appears 1 time in the code i posted. I essentially pass something to addChild. Yet i cannot pinpoint where in the code the cause arises of why nothing seems to be added to the stage. Here's a version of the code which is more comprehensively formatted than the code pasted below: http://flash.pastebin.com/m471d31c1 More detailed explanation: Here's basically what i'm trying to do. The following code which you'll see are two AS3 classes in seperate flash .as files. Those classes are part of a game which i'm trying to create. The first class is called GameLogic and the second class is called Symbol. The class GameLogic is run as a script in a frame by creating a new object of that class in that framescript. Ok so the code tries to generate random numbers from 0 to 8. Those random numbers represent types of symbols. When a random number is created and that number is not the same as a previously generated number, then it's used as an argument to create a new instance of the class Symbol. Every new instance of the class Symbol is stored in an array. That array is called chosenSymbol[]. The class Symbol also contains a method getSymbolType(), which returns a MovieClip. So when i want to get a MovieClip which is basically a graphic design of a symbol i do this: chosenSymbol[].getSymbolType() The MovieClips are in the library of flash and i have named them appropriatly(i think) and have checked the checkbox "export for actionscript" in their properties. So to draw a MovieClip from the library to the stage i do: addChild(chosenSymbol[limitedCounter].getSymbolType()); Then when i try to test the movie in Flash i get no errors in the output window. But no MovieClip on the stage! So i've tried to trace the height and width and name of chosenSymbol[limitedCounter].getSymbolType(), afterall it returns a MovieClip, When i do that i get 0 & 0 for height and width and some name called instance50 as the name. So there's definitly something wrong, but i can't seem to figure out what it is. The MovieClips are 92 * 92 pixels and they have names like Square_MC and Ring_MC etc. I've also tried to give the MovieClip's X and Y values 200 and 200 to make sure they are positioned on the stage, but to no avail. Can someone see what is wrong in this code Why doesn't a MovieClip get shown on the stage This is the first class called GameLogic: Code: package { import flash.display.MovieClip; import flash.events.MouseEvent; public class GameLogic extends MovieClip { public function GameLogic(chooseLevel:Number) { var level:Level = new Level(chooseLevel); //Create new level object with mandatory level number argument var chosenSymbolNumberArray:Array = new Array; //Create and array to store all the chosen symbol numbers in. //Symbol numbers match certain symbol types like a square, ring, leaf, etc. var chosenSlotNumberArray:Array = new Array; //Create an array to store the chosen slots in which are to be filled with the chosen symbols. var slotArray:Array = new Array(); slotArray[0] = new Slot(0, false); slotArray[1] = new Slot(1, false); slotArray[2] = new Slot(2, false); slotArray[3] = new Slot(3, false); slotArray[4] = new Slot(4, false); slotArray[5] = new Slot(5, false); slotArray[6] = new Slot(6, false); slotArray[7] = new Slot(7, false); slotArray[8] = new Slot(8, false); var chosenSymbol:Array = new Array(); //Set random chosen slots to "true" so that they are receptive for chosen symbols for(var counter_0001:Number=0; counter_0001 < level.getAmountOfSymbols(); counter_0001++) { //Choose symbol (randomly) chosenSymbolNumberArray[counter_0001] = Math.floor(Math.random()*9); //Check if symbol number already exists in chosenSymbolNumberArray for(var i_0001:Number=0; i_0001 0) && (chosenSymbolNumberArray[counter_0001] == chosenSymbolNumberArray[i_0001])) { chosenSymbolNumberArray[counter_0001] = Math.floor(Math.random()*9); i_0001 = -1; } } //Create a new symbol in an array using the chosenSymbolNumberArray for the symbolType argument and _symbolType property chosenSymbol[counter_0001] = new Symbol(chosenSymbolNumberArray[counter_0001], 300, 200); var currentChosenSymbol:Number = chosenSymbol[counter_0001]; trace("chosenSymbol[counter_0001].getSymbolType()", chosenSymbol[counter_0001].getSymbolType()); trace("height", chosenSymbol[counter_0001].height, "width", chosenSymbol[counter_0001].width, "name", chosenSymbol[counter_0001].name); //Choose slot (randomly) chosenSlotNumberArray[counter_0001] = Math.floor(Math.random()*9); //Check if slot number already exists in chosenSymbolNumberArray for(var i_0002:Number=0; i_0002
VIEWS ON THIS POST

117

Posted on:

Friday 12th October 2012
View Replies!

Help with passing movieclip parameters

I have a movieclip (menu1_mc) on my root timeline. (There will be 3 of these movieclips so I want to use the same functions to control their properties) For simplification, I am only showing 2 mouse events for one movieclip, over and out. menu1_mc.addEventListener(MouseEvent.MOUSE_OVER,is Active); menu1_mc.addEventListener(MouseEvent.MOUSE_OUT,not Active); function isActive(evt:Event):void { trace(evt.target.name); // menu1_mc trace(typeof(evt.target.name)); // String evt.target.name.x=300; // error "Cannot create property x on String." evt.target.name.y=0;// error "Cannot create property y on String." } function notActive(evt:Event):void { trace(evt.target.name); // menu1_mc trace(typeof(evt.target.name)); // String evt.target.name.x=30; // error "Cannot create property x on String." evt.target.name.y=0; // error "Cannot create property y on String." } I could sure use some help getting this to work. TIA.
VIEWS ON THIS POST

90

Posted on:

Friday 12th October 2012
View Replies!

passing a class type and declare it

i am trying to pass a class type into a function which then declares it to an array this way: i have this class which i am using the add movieclips form the library. PHP Code: package{ \t\timportflash.display.MovieClip; \t\t \t\tpublicclassTestClassextendsMovieClip{ \t\t\t\t \t\t\t\tprivatevarallTypes:Array; \t\t\t\t \t\t\t\tpublicfunctionTestClass{ \t\t\t\t\t\tallTypes=newArray(); \t\t\t\t} \t\t\t\t \t\t\t\tpublicfunctionaddType(i:Number,type:*){ \t\t\t\t\t\t//theniwannadeclarethetypeoftheclassthatisputintothismethod \t\t\t\t\t\tallTypes[i]=newtype("name",10,50); \t\t\t\t\t\taddChild(allTypes[i]); \t\t\t\t} \t\t} } and then on my main timeline, i have this document class, which will have an instance of the TestClass, and add in types which i want to add onto the stage. i wish to pass in the type of the class name of the exported movieclips which i have in my libraries. PHP Code: package{ \t\timportflash.display.MovieClip; \t\timportTestClass; \t\t \t\tpublicfunctionMainMovieextendsMovieClip{ \t\t\t\t \t\t\t\tvarTestClass:TestClass; \t\t\t\t \t\t\t\tpublicfunctionMainMovie(){ \t\t\t\t\t\tTestClass=newTestClass(); \t\t\t\t\t\t//nowiwanttoaddtheTypeoftheclassintotheparamaters \t\t\t\t\t\t//thesetypesareclassnamesofthemovieclipsinthelibrarythatareexportedforactionscriptinlinkage \t\t\t\t\t\tTestClass.addType(0,Plane); \t\t\t\t\t\tTestClass.addType(1,Bird); \t\t\t\t} \t\t} } however, this doesn't seem to work. any idea how should the syntax or the right way be for doing this
VIEWS ON THIS POST

86

Posted on:

Friday 12th October 2012
View Replies!

AS3 CS4 help passing variables between MovieClips

I'm trying to develop a site map, which draws a tick over the sections of my app that have been completed. I've figured out how to draw the tick and how to pass variables from root to the MovieClip that the function is in. To make the tick appear only after an mc has been watched, I tried setting a variable equal to 1 ino the last frame of the MovieClip, and telling the function to run if that variable was 1. I'm not getting compiler errors, but I'm also not getting the tick. And I'm definitely completing the Movie Here's what I've got so far: In root Code: var xcoord = 125; var ycoord = 300; var WaterComplete = 0; In WaterMovie Code: MovieClip(root).WaterComplete = 1; stop(); In SiteMap Code: function f_testDrawing(xcoord, ycoord) { var square:Sprite = new Sprite(); addChild(square); square.graphics.lineStyle(3,0x00FF00); square.graphics.beginFill(0x0000FF); drawShape(square); square.graphics.endFill(); square.x = xcoord; square.y = ycoord; function drawShape(sprite:Sprite):void { sprite.graphics.lineStyle(3,0x00FF00); sprite.graphics.beginFill(0x0000FF); sprite.graphics.moveTo(35,0); sprite.graphics.lineTo(55,5); sprite.graphics.lineTo(25,40); sprite.graphics.lineTo(15,40); sprite.graphics.lineTo(0,30); sprite.graphics.lineTo(10,20); sprite.graphics.lineTo(20,28); sprite.graphics.lineTo(35,0); sprite.graphics.endFill(); } } if (MovieClip(root).WaterComplete == 1) { f_testDrawing(MovieClip(root).xcoord, MovieClip(root).ycoord); } I'd love any help or suggestions, please! -A-
VIEWS ON THIS POST

105

Posted on:

Tuesday 16th October 2012
View Replies!

passing a parameter to the function in the loop

for(var i=1;i
VIEWS ON THIS POST

89

Posted on:

Wednesday 17th October 2012
View Replies!

passing instance names into an array

How do you pass instance names into arrays I've got a bunch of movieClips of states. They all have instance names.. alabama, arkansas, delaware, florida, georiga, etc.. I am trying to send them all to an array because I need to be able to disable the movieClips all at once and I don't want to call each one separately. I setup an array and a "for" loop, and it properly gets each value in the array: ActionScript Code: states = new Array(alabama, arkansas, delware, florida, georgia); stateslength = states.length; trace(stateslength); for (i = 0; i < states.length; ++i) { states = states[i]; trace(states[i]); //
VIEWS ON THIS POST

90

Posted on:

Wednesday 17th October 2012
View Replies!

Problem of passing variable from sql/php to flash

I am writing the codes that can pass the value from the table of database when I click on a button. When I click on the button in the first time, I send the the number of click: clickNum = 1 to the php file and I want to select the first row from the table. When I click on the button in the second time, I send the clickNum = 2 to the php file and I want to select the second row from the table, and so on. I can successfully send the clickNum in that numerical order. However, I can't pass the corresponding row of result back to the flash. For example, when I send clickNum = 1, it pass the value of the second row of table back to flash, but not the first row. And the row that it pass back to flash is different everytime, seems it is random and I can't find a pattern. The second question is that I still can't read the chinese character from the table of database even I have included the header("Content-Type:text/html; charset=utf-8"); in the php file. I don't know what's wrong with it. Please help me.T^T
VIEWS ON THIS POST

93

Posted on:

Friday 19th October 2012
View Replies!

sound duplicating on passing as parameter

Hi! Following my tiny project I experienced awkawrd behaviour of the sound object. Likely it is something wrong in my code though. I've got a DocumentClass where the sound loads in, and then starts, and have 2 Sliders, one responsible for actual position of the sound in time, and second VolumeSlider. I pass to both of them current Sound object and SoundChannel to the constructor and when I move my TimeSlider to scrub the sound I hear that second sound plays in the background (which is not scubbable). Moreover my VolumeSlider even if it passes a value to the sound.soundTransform and reapply it I didn't hear any change. My question is: can I have right soundChannel object referenced in other classes to change its parameters From my point of view it is rhetorical question and any passed object has a reference to the main object, but as always I can be wrong. Or maybe some of had similar issue in the past. Particularly I can instantiate my sliders in the same class as sound object to pass the value(already sliders are instantiated in mainPanel class which represents what the name suggest - main panel ^^just exactly like i.e. Winamp^^ )this way it should work ( I wouldn't have to pass sound object as a parameter to the sliders objects but retrieve slider's value to change the volume) From one point it is clear method as sliderVolume object shouldn't have an sound object inside, but from the point of my app it would be better to pass it though and manage inside the sliderVolume, timeSlider sliders. Hope you can imagine that, as there's to much code to post it here.
VIEWS ON THIS POST

68

Posted on:

Friday 19th October 2012
View Replies!

Loading SWF and passing asset

I'm currently having a problem with preloading. What I have is: 1. Preloader -> an SWF preloader, made in Adobe Flash CS5 2. GUI -> an SWF file containing the user interface, made in Adobe Flash CS5 3. Game -> an SWF containing actual game logic, made in Flash Develop The preloader SWF should preload both GUI and Game. I can do this, no problem. The problem however is: I need to be able to control the GUI from the Game. So how can I access the GUI from the Game In particular the main movieclip in the GUI which contains every interface screen. More general: how can a script inside a SWF communicate with another SWF (all in the same file)
VIEWS ON THIS POST

74

Posted on:

Friday 19th October 2012
View Replies!

Help passing variables

Hi all, Could someone help me out find a way to pass variables from one flash file to another Basically there's a flash navigator that has multiple links in it. Once clicked it needs to pass a variable to go to another keyframe in another flash file. I'm guessing the receiving flash needs to be able to receive a variable and if variable == a certain variable it goes to and plays a specific keyframe. Hopefully this makes sense.
VIEWS ON THIS POST

72

Posted on:

Friday 19th October 2012
View Replies!

Bypassing pop-up filters with _blank

all, I figured out why my external, embedded player wouldn't link back to my site: I was using _self rather than _blank, which I'm sure many of you knew. However, my next stumbling block is that any subsequent link now needs to be authorized if you are using a browser with a pop-up blocker (IE7, Firefox, etc.). What I've noticed is that YouTube has somehow completely bypassed this, and I need to figure out how. First, check out this site for an example of my player and YouTube's player on the same page: http://www.1037kissfm.com/ Note in the lower-right the YouTube clip. Click that first. Notice how the pop-up blocker doesn't ask for permission Then, beneath that is my "Comic Wonder" player. If you click on any links, it'll work, but only if you allow your pop-up blocker to allow it. Anyone know how YouTube has bypassed that
VIEWS ON THIS POST

94

Posted on:

Friday 19th October 2012
View Replies!

WebService problem: passing "Object" variabe

Hi all, I have an object passing problem with method's parameter when calling Webservice. When I import my Webservice URI to Webservice development panel. My calling function, named GetData, look like: --GetData -->params ..|-->key:String(string)[optional] ..|-->cmt:Ecomment(Object)[optional] .....|-->var1:Integer(long) .....|-->var2:Integer(long) .....|-->var3:Number(long)[optional] Here is my code to call the method and trace the result back Code: import mx.services.*; var key:String = "mykey"; var var1:Number= 1; var var2:Number= 2; var var3:Number=3; var webServiceURL:String="myServiceURL"; var resultObject:Object; var myWebSrvcLog = new Log(); var getService_ws = new WebService(webServiceURL,myWebSrvcLog); myWebSrvcLog.onLog = function(message : String) : Void { trace("myWebSrvcLog.message: " + message); } getService_ws.onLoad=trace("loading"); getService_ws.onFault=function(fault){ throw new Error("Can not connect to WebService"); //add some debug code here } resultObject = getService_ws.GetData(key,var1,var2,var3); resultObject.onResult=function(result){ trace(result); } When I call this method, the error: "Error opening URL" appear.The other method i call the same way work well without any error! I guess method's parameter isn't correct. Anyone has encountered this problem Help me, please. It's took me 2 days for googling but i couldn't figure it out. Sorry for my poor english
VIEWS ON THIS POST

61

Posted on:

Saturday 20th October 2012
View Replies!

Variable passing between Eventlistners

Ok, I've spent many hours searching the web for an answer I can understand. Its been a few years since I've done major AS1 and AS2 work. So I'm not sure why I decide to start with AS3 on this project. This is the basic functionality: I have a video that loads upon the start of a scene, then a listener detects flv play completion and then loads the next video in an array. (working). But I also have menu buttons so the user can also control which which video in the array plays. But in order to do this, and not have the original array loop get lost, I need my buttons to set the event variable on click. I feel like I am so close but I cannot figure our how to share this variable between the 2 listeners. I have researched and it seems I need use a package and a public class. This is foreign to me and not sure I have time to rewrite everything (should have struck with AS2 for now). Can you offer me any quick and dirty solutions without a package or maybe you can help me figure out the right way. This project is now past due because I can't seem to figure this out. Here is my code on the root timeline: import fl.video.*; import flash.events.Event; //The Video Array var myvideoarray:Array=new Array(); myvideoarray[0] = "deliverables/Clinical Pearls/CLINICAL PEARLS 01.flv"; myvideoarray[1] = "deliverables/Clinical Pearls/CLINICAL PEARLS 02.flv"; myvideoarray[2] = "deliverables/Clinical Pearls/CLINICAL PEARLS 03.flv"; myvideoarray[3] = "deliverables/Clinical Pearls/CLINICAL PEARLS 04.flv"; myvideoarray[4] = "deliverables/Clinical Pearls/CLINICAL PEARLS 05.flv"; var k:Number = 0; Vid.play(myvideoarray[k]); cp_q1.cp_q1btn.gotoAndStop(2); trace(k); Vid.addEventListener(VideoEvent.COMPLETE, loadnext); function loadnext(myevent:VideoEvent):void { k++; trace(k); if (k==0) { cp_q1.cp_q1btn.gotoAndStop(2); cp_q2.cp_q2btn.gotoAndStop(1); cp_q3.cp_q3btn.gotoAndStop(1); cp_q4.cp_q4btn.gotoAndStop(1); cp_q5.cp_q5btn.gotoAndStop(1); } if (k==1) { cp_q1.cp_q1btn.gotoAndStop(1); cp_q2.cp_q2btn.gotoAndStop(2); cp_q3.cp_q3btn.gotoAndStop(1); cp_q4.cp_q4btn.gotoAndStop(1); cp_q5.cp_q5btn.gotoAndStop(1); } if (k==2) { cp_q1.cp_q1btn.gotoAndStop(1); cp_q2.cp_q2btn.gotoAndStop(1); cp_q3.cp_q3btn.gotoAndStop(2); cp_q4.cp_q4btn.gotoAndStop(1); cp_q5.cp_q5btn.gotoAndStop(1); } if (k==3) { cp_q1.cp_q1btn.gotoAndStop(1); cp_q2.cp_q2btn.gotoAndStop(1); cp_q3.cp_q3btn.gotoAndStop(1); cp_q4.cp_q4btn.gotoAndStop(2); cp_q5.cp_q5btn.gotoAndStop(1); } if (k==4) { cp_q1.cp_q1btn.gotoAndStop(1); cp_q2.cp_q2btn.gotoAndStop(1); cp_q3.cp_q3btn.gotoAndStop(1); cp_q4.cp_q4btn.gotoAndStop(1); cp_q5.cp_q5btn.gotoAndStop(2); } if (k>= 5) { k=0; trace ("Reset to zero"); trace (k); cp_q1.cp_q1btn.gotoAndStop(2); cp_q2.cp_q2btn.gotoAndStop(1); cp_q3.cp_q3btn.gotoAndStop(1); cp_q4.cp_q4btn.gotoAndStop(1); cp_q5.cp_q5btn.gotoAndStop(1); } Vid.play(myvideoarray[k]); } cp_q2.addEventListener(MouseEvent.CLICK, PlayMovie2); function PlayMovie2(event:MouseEvent):void { trace (k); cp_q1.cp_q1btn.gotoAndStop(1); cp_q2.cp_q2btn.gotoAndStop(2); cp_q3.cp_q3btn.gotoAndStop(1); cp_q4.cp_q4btn.gotoAndStop(1); cp_q5.cp_q5btn.gotoAndStop(1); var k = 1; Vid.play(myvideoarray[k]); trace (k); } // Your help would be appreciated!
VIEWS ON THIS POST

77

Posted on:

Thursday 25th October 2012
View Replies!

passing Variable through function and error 1034

HI .. I have a proble withError #1034: Type Coercion failed: cannot convert @2a8bb231 to flash.events.Event. I think the error is int he variable I am passing through the function, because I tried the function code in an addeventlistener calling the function and it worked, also it works by it self but using it as I really want in the following code, it gives me this error.. Cbtn.addEventListener(MouseEvent.CLICK, gotoletterC); function gotoletterC(event:MouseEvent):void { gotoAndStop("letterC"); remove_B_Images(BImagesGroup) } function remove_B_Images (e:Event) { var numberOfImage = B_ImagesGroup.length; for (var i:uint= 0; i < numberOfImage; i++) { if (stage.contains(B_ImagesGroup[i])) { removeChild(B_ImagesGroup[i]); } } } any ideas\t
VIEWS ON THIS POST

96

Posted on:

Thursday 25th October 2012
View Replies!

Var not passing from custom class

I have created a custom class. It seems to work (at least no errors), but when I create a button in the actual FLA that calls on the class, it doesn't change what I want it to change. Here is the class: package visuals{ import flash.display.MovieClip; import flash.events.Event; import flash.display.Loader; import flash.display.LoaderInfo; import flash.net.navigateToURL; import flash.net.URLRequest; public class Icons extends MovieClip{ private var _myIcon:String; public function Icons(myIcon:String = "images/default.png") { _myIcon = myIcon; // constructor code //trace ("icons class"); buttonMode = true; mouseChildren = false; draw(); } private function draw():void{ loadImage(); } private function loadImage():void { var imgRequest:URLRequest = new URLRequest(_myIcon); var imgLoader:Loader = new Loader(); imgLoader.load(imgRequest); imgLoader.contentLoaderInfo.addEventListener(Event .OPEN, imgLoaderOpen); imgLoader.contentLoaderInfo.addEventListener(Event .COMPLETE, imgLoaderComplete); this.addChild (imgLoader); //trace ("load image"); } private function imgLoaderOpen(e:Event):void { //trace("imgLoader load started"); } private function imgLoaderComplete(e:Event):void { //trace("imgLoader load completed"); } } } ======================== And here is the code in the FLA that calls the class: import visuals.Icons; var icon_retrofit:Square = new Square(); icon_retrofit.myIcon = "images/b.png"; addChild(icon_retrofit); ========================= When I call for the class to make the button, it works. It also successfull calls the default.png from the class, but in the FLA the icon_retrofit.myIcon doesn't change the image to 'images/b.png'. what have I done wrong , update: I added public function set myIcon(value:String) :void{ _myIcon = value; draw(); } under the imgLoaderComplete function. It now brings in the right graphic, but the old graphic default graphic still remains. Thoughts , HAHA. Never mind, I got it. I just removed draw() function from the Icons function, and place draw() inside of the myIcon().
VIEWS ON THIS POST

160

Posted on:

Thursday 25th October 2012
View Replies!

passing keystrokes from air browser to flash game

Here's my situation - I am accessing some games that my company built using a AIR browser (allowing us to sell an installable product on a CD, but keeping the content online for ease of maintenance). I can get the games to load, but i cant get them to accept keystrokes, ie: we have a tetris-like game that isnt getting any of the arrow key inputs. I'm fairly certain this has something to do with a focus issue, but I have no idea how to fix it. Any suggestions would be welcome.
VIEWS ON THIS POST

137

Posted on:

Thursday 25th October 2012
View Replies!

passing variables problem

Hi all, I try to make a simple login. I use the code Code: function sendVars_login(event:MouseEvent):void { var scriptRequest_login:URLRequest = new URLRequest("http://******.aspx"); var scriptLoader_login:URLLoader = new URLLoader(); var scriptVars_login:URLVariables = new URLVariables(); scriptLoader_login.addEventListener(Event.COMPLETE, handleLoadSuccessful_login); scriptLoader_login.addEventListener(IOErrorEvent.IO_ERROR, handleLoadError_login); scriptLoader_login.dataFormat = URLLoaderDataFormat.TEXT; var email:String = email_txt.text; var pass:String = pass_txt.text; scriptVars_login.u_pass = pass scriptVars_login.u_email =email scriptRequest_login.method = URLRequestMethod.POST; scriptRequest_login.data = scriptVars_login; scriptLoader_login.load(scriptRequest_login); } when i send the vars i get back that user doesn't exists although i have checked that it exists. A funny thing is that when i change the following Code: scriptVars_login.u_pass = "somePass" scriptVars_login.u_email ="someEmail" I get correct results. So the .aspx script works and the way i'm sending the variable works. when i trace scriptRequest_login.data i get a url encoded string, so i tried to unescape the value Code: var unescapedString = unescape(String(scriptVars_login)); scriptRequest_login.data = unescapedString; scriptLoader_login.load(scriptRequest_login); now when i trace(scriptRequest_login.data) i get an unescaped value but it still doesn't work Any suggestions would be very helpfull. Thanx in advance
VIEWS ON THIS POST

79

Posted on:

Thursday 25th October 2012
View Replies!

passing vars to document class

I am trying to pass variables from key frames to my document class but I am not having much success. This is my package which starts by playing a voice over and when the voice over is done, it moves to the next frame in the movie. Code: package { import flash.display.MovieClip; import flash.net.URLRequest; import flash.media.*; import flash.events.*; public class PlayVoiceOvers extends MovieClip { private var VSound:Sound = new Sound(); private var channel:SoundChannel = new SoundChannel(); private var voiceToPlay:String="Voices/v001.mp3"; private var frameToPlay:String="v2"; private var req:URLRequest=new URLRequest(voiceToPlay); private var context:SoundLoaderContext=new SoundLoaderContext(500,true); private var newreq:URLRequest = new URLRequest(voiceToPlay); public function PlayVoiceOvers() { trace(voiceToPlay); VSound.load(req, context); channel=VSound.play(); channel.addEventListener(Event.SOUND_COMPLETE, soundCompleteHandler, false, 0, true); } public function soundCompleteHandler(event:Event):void { //trace(frameToPlay);//"v2" gotoAndPlay(frameToPlay); trace(voiceToPlay); trace(frameToPlay); PlayMyNextSound(); } public function PlayMyNextSound(){ newreq=new URLRequest(voiceToPlay) VSound.load(newreq, context); channel=VSound.play(); channel.addEventListener(Event.SOUND_COMPLETE, soundCompleteHandler, false, 0, true);; } } } On the next frame of the movie I have this code. The idea is that once the voice over is done playing it advances to the next frame but it doesn't appear to be working. What am I doing wrong Code: stop(); voiceToPlay = "Voices/v002.mp3"; frameToPlay = "v3"; I get this error: Error: Error #2037: Functions called in incorrect sequence, or earlier call was unsuccessful. at flash.media::Sound/_load() at flash.media::Sound/load() at PlayVoiceOvers/PlayMyNextSound() at PlayVoiceOvers/soundCompleteHandler()
VIEWS ON THIS POST

87

Posted on:

Thursday 25th October 2012
View Replies!

Need help passing PHP variable through flash MC

Need to get a flash banner to carry through PHP session download. The PHP code is below;
VIEWS ON THIS POST

184

Posted on:

Thursday 25th October 2012
View Replies!

passing parameters to function and avoiding duplicate variable definitions

I have shortened this example to keep it simple, otherwise I wouldnt be doint this I need to pass different variables to function inForLoop each time. Code: function someFunction():void { for (var i:int = 0; i < columns; i++) { for (var j:int = 0; j < rows; j++) { inForLoop(i, j);//this is fine } } for (var m:int = 0; m < columns; m++) { for (var n:int = 0; n < rows; n++) { inForLoop(m, n);//ofcourse function inForLoop wouldnt accept this } } for (var p:int = 0; p < columns; p++) { for (var r:int = 0; r < rows; r++) { inForLoop(p, r);//nor this } } } function inForLoop(i:uint, j:uint):void { holder.x = i * IMAGE_PIECE_WIDTH; holder.y = j * IMAGE_PIECE_HEIGHT; } How could I make this work
VIEWS ON THIS POST

108

Posted on:

Thursday 25th October 2012
View Replies!