Textfield in a subclassed Movieclip
Hi,
I have a Movieclip which is abstract called ScreenItem. This
is extended by MenuObject which creates several MenuItem objects
which are a separate MovieClip class. I would like to display
textFields inside my MenuItems but when I add them they just don't
show up. If i set them as selectable then I get a text select
cursor when i run the swf but no visible text. The same code works
fine if i add the MenuItem directly to the main timeline.
Any ideas?
Matt
My first instinct is to say... IS there a mask involved
anywhere relative to the textfield? If so, you probably need to
embed the font for it.
Beyond that, try tracing the textfield.text value after it's
been filled to see if it holds anything.
Similar Messages
-
Error 1152 Subclass MovieClip has text field
Hi,
I have a movie clip "Obstacle" for a simple game. I have a class for it (Obstacle.as) that creates it, and moves it.
In this Obstacle there is a text field - i use it for testing right now.
The above works fine!
NOW
I want to make another Obstacle (HayBale) - with a subclass (HayBale.as). I have it mostly working. ACCEPT that text field.
It pitches this error:
1152: A conflict exists with inherited definition com.screenscape.game:Obstacle.myDisplay in namespace public.This probably means that super class already has property myDisplay and you attempt to declare it again in subclass. This is not allowed. In subclass you need to instantiate myDisplay - not to declare it.
-
Duplicating movieclips w/textfields on them & changing the text
Okay, there is a movie clip in the library. Has three layers. Each of the layers is also in the library. Layer 1 has a button symbol, layer 2 a text symbol with instance name 'item_label', layer 3 is color. instance name is 'flbutton'. To me, it looks like this was created into a symbol itself and given intance name of 'menu_item'.
An array is created with button label names. A loop is created based on the number of labels in the array. An instance of 'menu_item' is created each loop and placed on the stage/screen and the text on the button is changed to the item in the array.
My question....how do you do that in AS3?
var menu_label:Array = new Array("Introduction", "Templates", "Services", "Clients",
"Testimonials", "Support", "About Us", "Contact");
// *** menu label array length must be equal to number of
// *** total frames inside "menu button bg" Movie Clip in the library.
var total:Number = menu_label.length;
var tween_duration:Number = .85;// in seconds
var radius:Number = 185;
var angle:Number;
var i:Number = 0;
function create_menu():Void
angle = (i - 2) * Math.PI * 2 / total;
position_x = Math.cos(angle) * radius;
position_y = Math.sin(angle) * radius;
var fm = menu_item_group.menu_item.duplicateMovieClip("menu_item" + i, i);//** menu_item_group is instance name already on the
//** stage and is instance of symbol in library that has
//**instance name of menu_item
fm.stop();
fm.bg.gotoAndStop(i + 1);
fm.over = true;
fm.item_label = menu_label[i]; //** here is where the text of each newly created MovieClip's text is changed
fm.item_no = i;
more code.........
loop
Can someone tell me how to do this in AS3? I have learned how to duplicate a movieclip with DisplayObjects, but I have no way of knowing how to get to the text field in order to change it.
Regards,
Kevin
ps. new to Flash. Decent amount of VB programming experience.You are correct about the instance names etc... my apologies... I did not save my work and lost what I was doing. My Dev enviroment is a personal laptop with Flash. The company has yet to purchase Flash. My laptop did an auto Windows update. I lost my testing .fla.
You were right about the instance name. It was missing from my previous example. That has been correct. I now get no errors, but setting the autoSize property did not work.
I'm creating two MovieClips. One is the MovieClip of the actual TextField and the other is of a MovieClip with the TextField on it.
import flash.display.MovieClip;
import flash.text.TextField;
import flash.text.TextFieldAutoSize;
When I create the MovieClip of the TextField directly:
var mcTxt:MovieClip=new clsText(); //pardon me, but I just had to use some VB naming conventions to help myself out.
addChild(mcTxt);
mcTxt.item_Label.autoSize=TextFieldAutoSize.LEFT;
mcTxt.item_Label.text="Hello Willeeerrrrr";
When I add the field without changing the text, the text field defaults to "Hello World". When I attempt a change as in the code above, the text field looks as follows: Hello Willeee. If I add a fourth 'e', .text="Hello Willeeeerrrr", it will add it to the text field the next time I test. The final 'rrrrr's' get truncated. Wierd.
Now, when I do the above on the MovieClip with the child text field, the text just disappears.
var mc:MovieClip=new clsMenuItem();//MovieClip with the embedded/child textfield
addChild(mc);
mc.mcMenuItem.item_Label.autoSize=TextFieldAutoSize.LEFT;
mc.mcMenuItem.item_Label.text="Hello Willred";
The above code causes the text to display blank.
I'm close and hope it's just a property setting...ideas? -
Hi all,
I'm new to Flash and I'm new to OOP, and so I'm having a bit
of trouble writing ActionScript programs to do exactly what I want.
I am trying to create a simple application, in which a
MovieClip is dragged around the screen and a textbox gets updated
with the MovieClip's coordinates somewhere else on the screen. I
wanted to do this using custom classes, so I created a class called
MovieClipCoordinates that would contain a MovieClip and a
TextField. I am initializing the MovieClip as the output of a
this.createEmptyMovieClip() of the main movie, and the TextField
similarly.
My intention is to have the TextField updated whenever the
MovieClip is dragged. So, in the onRelease function of the
MovieClip, I need to update the TextField of the
MovieClipCoordinates object that the MovieClip is a property of.
The problem is, I have no idea how to find out the
MovieClipCoordinates that the MovieClip belongs to. I thought I
would create a method in the MovieClipCoordinates class that would
set the TextField, which would be called from the
MovieClip.onRelease. So I figured I would not have a MovieClip
inside the MovieClipCoordinates class, but instead another class
inherited from MovieClip which also contains a reference to the
MovieClipCoordinates class that it is a member of. However, the
problem now is that I can no longer create this subclass through a
call to createEmptyMovieClip. So how do I create it?
I'm getting a bit confused at this point of time. Could
someone please give me some idea of how to do this?
Thanks.
AjitLuigiL,
Thank you very much for your assistance. I truly appreciate
it.
Though the code works perfectly, I wonder if I may trouble
you to clarify a couple of questions that I have with your code.
Looking particularly at this section of the code:
private function setHandlers(target_mc:MovieClip):Void{
//use a reference to the current object
var thisObj:MovieClipCoordinates=this;
target_mc.onPress=function():Void{
this.startDrag();
target_mc.onRelease=function():Void{
this.stopDrag();
//get the new coordinates
var thisX=thisObj.box_mc._x;
var thisY=thisObj.box_mc._y;
//and refresh the text
thisObj.printCoordinates(thisX,thisY);
How is it legal to use thisObj inside the onRelease function?
I was under the impression that the onRelease function is a
separate function altogether, that is called in the context of the
MovieClip that it is associated with. How does it have knowledge of
thisObj, which was defined in scope above it?
Would it be even possible to define the onPress and onRelease
functions above as two separate functions (CoordinatesPress and
CoordinatesRelease, for example) and rewrite the above code as
follows?:
private function setHandlers(target_mc:MovieClip):Void{
//use a reference to the current object
var thisObj:MovieClipCoordinates=this;
target_mc.onPress=CoordinatesPress;
target_mc.onRelease=CoordinatesRelease;
defining the handler functions separately. If I chose to do
this, how would I possibly pass the thisObj to the handlers?
I seem to be missing something fundamental in ActionScript
functions, or perhaps just in the event-handlers. I would
appreciate it if you could help me clear this up.
Thanks again,
Ajit -
AS3 plays all Movieclips in timeline before a given frame?!?
Ok, I am going to try to explain this problem as best I can,
but it is kind of hard to put into words... It seems like a bug to
me, but I could be wrong, maybe this is the way AS 3 supposed to
work.
I have 4 movieClips in my library named
"MC1","MC2,"MC3","MC4" Each with 2 layers and 2 frames, on Layer 2
is just a textfield that says what movieclip it is, Like "MC1"
which spans 2 frames, on layer 1 I have trace commands...
On frame 1
trace("MC1 Start") //this obviously changes to MC2
Start...etc with whatever movieclip i am in
on Frame 2
trace("MC1 Stop")
On the Stage timeline here is what I have
Frames 1-4 -- Blank
Frames 5-10 -- MC1
Frames 10-14 -- MC2
Frames 15-19 -- MC3
Frames 20-24 -- MC4
If in frame one I say--
gotoAndStop(15)
which is where MC3 resides, here's what I get in the output
window:
MC1 Play Start
MC2 Play Start
MC3 Play Start
MC3 Play Stop
If I put:
gotoAndStop(20)
Which is where MC4 resides, heres what output says:
MC1 Play Start
MC2 Play Start
MC3 Play Start
MC4 Play Start
MC4 Play Stop
So in AS3 if you go to a frame number each and every
movieclip before that given frame is loaded into memory and the
first frame plays?!? Is this how it is supposed to work?
The reason I even started examining this, is because if you
have an embedded sound in any of those movieclips and you go to
frame 20, all embeded sounds before that clip will play as well. Am
I missing something here, or is this a bug? Please let me know. If
there are any questions about the problem, I will be happy to
provide an .fla.
ThanksThanks for the reply, but this makes no difference. The
results are still the same. -
How to access MC's textfield created in a custom class?
I have a custom class which creates a new MC using a library MC. The library MC contains a dynamic textfield called productName.
The custom class object gets created fine and is displaying on the stage. It's also holding custom properties I set as well.
How do I control the dynamic textfield inside the MC, which is inside the custom class object?
My Product.as:
package {
import flash.display.MovieClip;
public class Product extends MovieClip {
public var prodName:String;
public var prodCategory:String;
public var prodQuality:String;
public function Product():void {
var productMC:MovieClip = new cellMC();
addChild(productMC);
My .FLA first frame:
var myProd1:Product = new Product();
myProd1.prodCategory = "Heaters";
myProd1.x = 150;
myProd1.y = 140;
addChild(myProd1);
// THE FOLLOWING DOES NOT WORK
myProd1.productMC.productName.text = "ABC 123";
I figure something like this would work, but with lots of variations, still nothing works
I get errors telling me it can't find productMC.
UPDATE:
Using GetByChildName it seems I can access productMC. For example this works:
myProd1.getChildByName("productMC").visible = false;
But this does not work:
myProd1.getChildByName("productMC").getChildByName("productName").text = "dgdhdhdhrgh";
If I take the textfield out of the library MC, and create it in the class, then this works:
myProd1.getChildByName("productName").visible = false;
BUT this does not work:
myProd1.getChildByName("productName").text = "sdgsgdfsg";Hi Otto,
If I well understood your situation, the solution might be quite simple.
Since your Product class is a MovieClip (and not a Sprite), you could solve your problem many ways knowing that a MovieClip is a dynamic class.
But first, the thing is that you created your productMC object on the fly inside your Product class.
So either you correct it like this:
package {
import flash.display.MovieClip;
public class Product extends MovieClip {
public var prodName:String;
public var prodCategory:String;
public var prodQuality:String;
public var productMC:MovieClip; // *****
public function Product():void {
productMC = new cellMC(); // *********
addChild(productMC);
Or use this cheap trick (a MovieClip is a dynamic class):
package {
import flash.display.MovieClip;
public class Product extends MovieClip {
public var prodName:String;
public var prodCategory:String;
public var prodQuality:String;
public function Product():void {
var productMC:MovieClip = new cellMC();
this.productMC = productMC; // **************
addChild(productMC);
Although it is possible that, for this one, you need to reforce the dynamic property:
package {
import flash.display.MovieClip;
dynamic public class Product extends MovieClip {
I am not sure, but anyway, you will see for yourself.
Plus, you try to change text to a MovieClip object? Either there is already a TextField in you cellMC object and you are not targeting it, or productMC should be instanciated as a TextField and not a MovieClip. I think you know the answer to that.
Design Cyboïde
Designer web Montreal -
Error #1009: Help needed
Hello everyone,
I'm looking for some help with an error I'm getting:
Error #1009: Cannot access a property or method of a null object reference
Now, I know approximately what it means, I just can't find where exactly the problem is or how to fix it.
I must warn tho, my code is a bit chaotic, had a rough start and now I'm just trying to finish before the deadline, and with my time left I'm gonna clean up the code.
I think it's best if I send the entire flash project in a zip so if you are willing to help just let me know how to reach you
Thanks in advance.
DaveyI fixed the errors, not getting any anymore, think the problem was adding an event listener to a button on stage in the subclass constructor. Seeing as I first call the function and then pass the button from main class to sub class, the button wasn't set yet ( I think ). However, the errors are gone, but my event listeners don't seem to be doing anything. I'll paste all my code
Main.as, the classes used for this are:addClasses(), removeEvents(), addEvents(), addButtonEvents(), menuKeuzeNext(it just calls addClasses when input control is finished)
[AS]
package
import flash.display.MovieClip;
import flash.display.Shape;
import flash.display.DisplayObject;
import flash.geom.ColorTransform;
import flash.events.MouseEvent;
import flash.events.Event;
import flash.display.*;
import flash.net.*;
public class Main extends MovieClip
//XML wordt ingeladen en geprocessed in aparte klasse
//private var xmlLoad = new XMLLoad;
//Variabelen om XML in te laden
private static var url:String = "drawings.xml";
private var contentXML:XML;
private var contentXMLURL:URLRequest;
private var contentXMLLoader:URLLoader;
//Arrays om data van XML in op te slaan
private var titles:Array = new Array;
private var authors:Array = new Array;
private var locations:Array = new Array;
private var currentChoice:uint = 0;
public var naam:String = new String;
public var bedragString:String = new String;
public var bedrag:uint = new uint;
//swf loader variabelen
private var drawRequest:URLRequest;
private var drawLoader:Loader = new Loader();
//Alle objecten die in de movieclip inputMenu zitten beschikbaar maken
private var naamInput:TextField;
private var bedragInput:TextField;
private var naamLeegmc:MovieClip
private var naamLeeg:TextField;
private var bedragLeegmc:MovieClip;
private var bedragLeeg:TextField;
//Klassen voor draw en erase laden in frame 2
public var eraserClass:Eraser;
public var spraycanClass:Spraycan;
//Welke tool is momenteel actief?
public static var activeEvents:Array;
public function Main():void
stop();
/*Event listeners worden toegevoegd in de Action layer, per frame.
Als je ze niet inlaadt bij de bijbehorende frame krijg je errors
omdat de buttons waar je de event listener aan hangt, zogezegt nog niet bestaat)*/
//addEventListeners();
XMLLoad();
private function addClasses():void
eraserClass = new Eraser();
eraserClass.setDrawBoard(drawBoard);
eraserClass.setButton(eraser);
eraserClass.setDrawSize(drawSize);
trace("if");
spraycanClass = new Spraycan();
spraycanClass.setDrawBoard(drawBoard);
spraycanClass.setButton(spraycan);
spraycanClass.setDrawSize(drawSize);
spraycanClass.setColorsMC(colors);
spraycanClass.setSizePanel(sizePanel);
addButtonEvents();
//removeEventListeners voor van actieve tool te wisselen
public static function removeEvents():void
if(activeEvents != null)
for(var i = 0; i < activeEvents.length; i++)
if(activeEvents[i].movieclip.hasEventListener(activeEvents[i].type))
activeEvents[i].movieclip.removeEventListener(activeEvents[i].type, activeEvents[i].listener);
activeEvents = new Array();
trace("niet leeg");
} else {
trace("leeg");
//addEventListeners voor actieve tool te starten
public static function addEvents(movieclip:MovieClip,type:String, listener:Function):void
activeEvents = new Array();
movieclip.addEventListener(type,listener);
activeEvents.push({movieclip:movieclip, type:type, listener:listener});
public function addButtonEvents():void
eraser.addEventListener(MouseEvent.MOUSE_DOWN, eraserClass.eraserTool);
spraycan.addEventListener(MouseEvent.MOUSE_UP, spraycanClass.spraycanTool);
colors.addEventListener(MouseEvent.MOUSE_UP, spraycanClass.chooseColor);
sizePanel.addEventListener(MouseEvent.MOUSE_UP, spraycanClass.changeDrawSize);
private function menuKeuzeBack(event:MouseEvent):void
inputMenu.visible = false;
public function callMenu(event:MouseEvent):void
inputMenu.visible = true;
MovieClip(inputMenu).keuzeStart.addEventListener(MouseEvent.MOUSE_UP, menuKeuzeNext);
MovieClip(inputMenu).keuzeAnnuleer.addEventListener(MouseEvent.MOUSE_UP, menuKeuzeBack);
hideAlerts();
private function hideAlerts():void
MovieClip(inputMenu).naamLeegmc.visible = false;
MovieClip(inputMenu).naamLeeg.visible = false;
MovieClip(inputMenu).bedragLeegmc.visible = false;
MovieClip(inputMenu).bedragLeeg.visible = false;
private function menuKeuzeNext(event:MouseEvent):void
hideAlerts();
naam = MovieClip(inputMenu).naamInput1.text;
bedragString = MovieClip(inputMenu).bedragInput1.text;
bedrag = int(bedragString);
//alle invoer alerts terug op onzichtbaar zetten voor als men bv naam verbeterd heeft maar bedrag nog steeds incorrect is, anders blijft alert van naam ook staan.
//invoercontrole
if(naam == "")
showAlert("leeg", "naam")
} else if(naam.length > 30)
showAlert("te lang", "naam");
if(bedrag == 0)
showAlert("Bedrag is leeg", "bedrag");
} else if(bedrag < 2.5)
showAlert("Bedrag moet minstens 2,5 euro zijn", "bedrag");
if(naam.length < 30 && bedrag > 2.5 && naam !="")
gotoAndStop(2);
inputMenu.visible = false;
newImageMC.visible = false;
addClasses();
private function showAlert(error, input):void
if (input=="naam")
MovieClip(inputMenu).naamLeeg.text = "Naam is " + error;
MovieClip(inputMenu).naamLeegmc.visible = true;
MovieClip(inputMenu).naamLeeg.visible = true;
if (input=="bedrag")
MovieClip(inputMenu).bedragLeeg.text = error;
MovieClip(inputMenu).bedragLeegmc.visible = true;
MovieClip(inputMenu).bedragLeeg.visible = true;
private function prevDrawing(event:MouseEvent):void
//Als je bij de eerste foto bent en je drukt op vorige afbeelding kom je op de laatste, anders ga je eentje terug
if(currentChoice == 0)
currentChoice = titles.length-1;
} else {
currentChoice -= 1;
processXML();
private function nxtDrawing(event:MouseEvent):void
//Als je bij de laatste foto bent en je drukt op volgende afbeelding kom je op de eerste, anders ga je eentje vooruit
if(currentChoice == titles.length-1)
currentChoice = 0;
} else {
currentChoice += 1;
processXML();
private function newUserF(event:MouseEvent):void
newImageMC.visible=true;
MovieClip(inputMenu).naamInput1.text = "";
MovieClip(inputMenu).bedragInput1.text = "";
MovieClip(newImageMC).newImageB.addEventListener(MouseEvent.MOUSE_UP, newImage);
MovieClip(newImageMC).currentImageB.addEventListener(MouseEvent.MOUSE_UP,currentImage);
private function newImage(event:MouseEvent):void
gotoAndStop(1);
//addEventListeners();
processXML();
private function currentImage(event:MouseEvent):void
MovieClip(newImageMC).newImageB.removeEventListener(MouseEvent.MOUSE_UP, newImage);
MovieClip(newImageMC).currentImageB.removeEventListener(MouseEvent.MOUSE_UP,currentImage) ;
newImageMC.visible = false;
inputMenu.visible = true;
public function XMLLoad():void
//XML inladen en naar functie xmlLoaded gaan wanneer deze ingeladen is
contentXMLURL = new URLRequest(url);
contentXMLLoader = new URLLoader(contentXMLURL);
contentXMLLoader.addEventListener(Event.COMPLETE, xmlLoaded);
private function xmlLoaded(event:Event):void {
//XML in variabele steken
contentXML = new XML(event.target.data);
contentXML.ignoreWhite = true;
for (var i = 0; i < contentXML.DRAWING.length(); i++)
titles[i] = contentXML.DRAWING[i].TITLE;
authors[i] = contentXML.DRAWING[i].AUTHOR;
locations[i] = contentXML.DRAWING[i].LOCATION;
processXML();
private function processXML():void
titleText.text = titles[currentChoice];
authorText.text = authors[currentChoice];
if (drawLoader.stage)
choiceBoard.removeChild(drawLoader);
if (currentChoice == 0)
} else {
drawRequest = new URLRequest(locations[currentChoice]);
drawLoader.load(drawRequest);
drawLoader.contentLoaderInfo.addEventListener(Event.COMPLETE, loadComplete);
private function loadComplete(event:Event):void
choiceBoard.addChild(drawLoader);
drawLoader.x= -421/2;
drawLoader.y= -297/2;
drawLoader.content.height = 297;
drawLoader.content.width = 421;
[/AS]
Spraycan.as, class for drawing
[AS]
package
import flash.display.MovieClip;
import flash.display.Shape;
import flash.display.DisplayObject;
import flash.display.BitmapData;
import flash.events.MouseEvent;
public class Spraycan extends MovieClip
private var sprayCan:Shape;
private var spraycan:MovieClip;
//Ik gebruik de bitmapdata om de RGB waarde te krijgen
private var colorsBmd:BitmapData;
//Vars voor kleur te kiezen.
private var pixelValue:uint;
private var activeColor:uint = 0x663399;
private var drawSize:MovieClip;
private var colors:MovieClip;
private var sizePanel:MovieClip;
private var drawBoardmc:MovieClip;
public function Spraycan():void
/*public function eventLists():void
spraycan.addEventListener(MouseEvent.MOUSE_UP, spraycanTool);
colors.addEventListener(MouseEvent.MOUSE_UP, chooseColor);
sizePanel.addEventListener(MouseEvent.MOUSE_UP, changeDrawSize);
Main.addButtonEvents(spraycan, MouseEvent.MOUSE_DOWN, spraycanTool);
Main.addButtonEvents(colors, MouseEvent.MOUSE_DOWN, chooseColor);
Main.addButtonEvents(sizePanel
public function spraycanTool(e:MouseEvent):void
//convert movieclip 'colors' naar bitmapdata
convertToBMD();
//Actieve tool stoppen
Main.removeEvents();
//Listeners toevoegen aan het 'board' MovieClip, om er in te tekenen
Main.addEvents(drawBoardmc, MouseEvent.MOUSE_DOWN, startSpraycan);
Main.addEvents(drawBoardmc, MouseEvent.MOUSE_DOWN, stopSpraycan);
private function startSpraycan(e:MouseEvent):void
sprayCan = new Shape(); // nieuwe shape zodat die altyd vanboven ligt (in geval van vorige tekenen, ...)
drawBoardmc.addChild(sprayCan); // shape toevoegen aan het 'board' movieclip
sprayCan.graphics.moveTo(mouseX, mouseY); //verplaatst de tekenpositie naar de muis positie
sprayCan.graphics.lineStyle(drawSize.width, activeColor); // zet de dikte van het penseel naar de lijndikte van de shapeSize movieclip
drawBoardmc.addEventListener(MouseEvent.MOUSE_MOVE, drawSpraycan); // voegt een listener toe aan de volgende functie
private function drawSpraycan(e:MouseEvent):void
sprayCan.graphics.lineTo(mouseX,mouseY); //tekent een lijn van de huidige muis positie naar de verplaatste muispositie
private function stopSpraycan(e:MouseEvent):void
drawBoardmc.removeEventListener(MouseEvent.MOUSE_MOVE, drawSpraycan); //stopt het tekenen
private function convertToBMD():void
colorsBmd = new BitmapData(colors.width, colors.height);
colorsBmd.draw(colors);
public function chooseColor(e:MouseEvent):void
pixelValue = colorsBmd.getPixel(colors.mouseX, colors.mouseY); //slaagt de geklikte RGB waarde op in de variabele pixelValue
activeColor = pixelValue
public function changeDrawSize(e:MouseEvent):void
if (drawSize.width >=50)
drawSize.width = 1;
drawSize.height = 1;
else
drawSize.width += 5;
drawSize.height = drawSize.width;
public function setDrawBoard(board):void
drawBoardmc = board;
public function setButton(toolButton):void
spraycan = toolButton;
/*public function setActive(activeTool):void
active = activeTool;
public function setDrawSize(drawsize):void
drawSize = drawsize;
public function setColorsMC(colorsmc):void
colors = colorsmc;
public function setSizePanel(sizepanel):void
sizePanel = sizepanel;
[/AS]
Eraser.as, class to erase
[AS]
package
import flash.display.MovieClip;
import flash.display.Shape;
import flash.display.DisplayObject;
import flash.display.BitmapData;
import flash.events.MouseEvent;
public class Eraser extends MovieClip
private var eraser:Shape;
private var drawBoardmc:MovieClip;
private var eraserB:MovieClip;
//private var active:String;
private var drawSize:MovieClip;
//private var spraycan:Spraycan;
public function Eraser():void
/*public function eventLists():void
eraserB.addEventListener(MouseEvent.MOUSE_UP, eraserTool);
eraserB.addEventListener(MouseEvent.MOUSE_OVER, function(){gotoAndStop(2);}) ;
eraserB.addEventListener(MouseEvent.MOUSE_OUT, function(){gotoAndStop(1);});
public function eraserTool(e:MouseEvent):void
//actieve tool afsluiten
Main.removeEvents();
//eraserB.addEventListener(MouseEvent.MOUSE_UP, function(){gotoAndStop(2);});
//listeners
Main.addEvents(drawBoardmc, MouseEvent.MOUSE_DOWN, startEraser);
Main.addEvents(drawBoardmc, MouseEvent.MOUSE_DOWN, stopEraser);
private function startEraser(e:MouseEvent):void
eraser = new Shape();
drawBoardmc.addChild(eraser);
eraser.graphics.moveTo(mouseX, mouseY);
eraser.graphics.lineStyle(drawSize.width, 0x000000);
drawBoardmc.addEventListener(MouseEvent.MOUSE_MOVE, drawEraser);
private function drawEraser(e:MouseEvent):void
//if (board.width > mouseX && board.height > mouseY) {
eraser.graphics.lineTo(mouseX, mouseY);
function stopEraser(e:MouseEvent):void
drawBoardmc.removeEventListener(MouseEvent.MOUSE_MOVE, drawEraser);
/*private function quitActiveTool():void
switch (active)
case "Spraycan" :
drawBoardmc.removeEventListener(MouseEvent.MOUSE_DOWN, spraycan.startSpraycan);
drawBoardmc.removeEventListener(MouseEvent.MOUSE_UP, spraycan.stopSpraycan);
case "Eraser" :
drawBoardmc.removeEventListener(MouseEvent.MOUSE_DOWN, startEraser);
drawBoardmc.removeEventListener(MouseEvent.MOUSE_UP, stopEraser);
default:
public function setDrawBoard(board):void
drawBoardmc = board;
public function setButton(toolButton):void
eraserB = toolButton;
/*public function setActive(activeTool):void
active = activeTool;
public function setDrawSize(drawsize):void
drawSize = drawsize;
[/AS] -
I am using a class called DrawingUtilities.as and the file is
placed at the same root level as my .fla file, but I get an error
when testing the movie. The error is:
**Error** Scene=Scene 1, layer=Layer 1, frame=1:Line 20: The
class or interface 'actionscriptbible.drawing.DrawingUtilities'
could not be loaded.
var duDrawer
rawingUtilities = new DrawingUtilities(mButton);
Total ActionScript Errors: 1 Reported Errors: 1
why can't it find the damn class!?
here is the entire AS code I am using if that helps...
import actionscriptbible.drawing.DrawingUtilities;
var mLoginButton:MovieClip;
var mSaveButton:MovieClip;
makeLoginScreen();
//the drawButton() function makes a new MovieClip object with
a nested
//label TextField object.
function drawButton(mParent:MovieClip, sLabel:String,
nWidth:Number, nHeight:Number):MovieClip {
//Make a movieclip object nested in the parent object. Use a
unique
// instance name and depth.
var nDepth:Number = mParent.getNextHighestDepth();
var mButton:MovieClip =
mParent.createEmptyMovieClip("mButton" + nDepth, nDepth);
//Draw a rectangle in the MovieClip object
var duDrawer
rawingUtilities = new DrawingUtilities(mButton);
duDrawer.beginFill(0xFFFFCC, 100);
duDrawer.drawRectangle(nWidth, nHeight, nWidth/2, nHeight/2);
duDrawer.endFill();
// Add a TextField object to the MovieClip. Apply the label.
var tLabel:TextField = mButton.createTextField("tLabel",
mButton.getNextHighestDepth(),0,0, nWidth, nHeight);
tLabel.Selectable = false;
tLabel.text = sLabel;
return mButton;
function makeLoginScreen():Void {
//Create the TextField and MovieClip Objects.
this.createTextField("tUsername", this.getNextHighestDepth(),
100, 100, 200, 20);
this.createTextField("tPassword", this.getNextHighestDepth(),
100, 140, 200, 20);
this.createTextField("tMessage", this.getNextHighestDepth(),
100, 60, 200, 20);
mLoginButton = drawButton(this, "Login", 100, 25);
//Set the properties of the TextField Objects.
tUsername.border = true;
tPassword.border = true;
tUserName.type = "input";
tPassword.type = "input";
tPassword.password = true;
tMessage.textColor = 0xFF0000;
//Place the button
mLoginButton._x = 100;
mLoginButton._y = 180;
mLoginButton.onRelease = function():Void {
//Check to see if the user has entered the correct username
//and password. If so, call the login() function.
//otherwise, display
//a message to the user and clear the values from the login
//TextField objects.
if(tUserName.text =="admin" && tPassword.text
=="admin") {
login();
else {
tMessage.text = "Try again.";
tUsername.text = "";
tPassword.text = "";
function login(): Void {
//Remove the TextField and MovieClip objects that made up
the
//login screen.
tUsername.removeTextField();
tPassword.removeTextField();
mLoginButton.removeMovieClip();
//Create the TextField and MovieClip for the notes screen.
this.createTextField("tNotes", this.getNextHighestDepth(),
100, 100, 350, 200);
mSaveButton = drawButton(this, "Save", 100, 25);
//Set the properties of the TextField Object.
tNotes.border = true;
tNotes.type = "input";
//Place the button
mSaveButton._x = 100;
mSaveButton._y = 320;
//Open a local shared object.
var lsoNotes:SharedObject = SharedObject.getLocal("notes");
// Assign the stored text, if any.
tNotes.text = (lsoNotes.data.notes == undefined) ? "" :
lsoNotes.data.notes;
//When the user clicks and releases the button store the
current
//current notes. in the shared object
mSaveButton.onRelease = function():Void {
lsoNotes.data.notes = tNotes.text;
lsoNotes.flush();thanks,
I can get my form to dispay now, but the first input isn't
alowing any text input
here is tha code
import DrawingUtilities;
var mLoginButton:MovieClip;
var mSaveButton:MovieClip;
makeLoginScreen();
//the drawButton() function makes a new MovieClip object with
a nested
//label TextField object.
function drawButton(mParent:MovieClip, sLabel:String,
nWidth:Number, nHeight:Number):MovieClip {
//Make a movieclip object nested in the parent object. Use a
unique
// instance name and depth.
var nDepth:Number = mParent.getNextHighestDepth();
var mButton:MovieClip =
mParent.createEmptyMovieClip("mButton" + nDepth, nDepth);
//Draw a rectangle in the MovieClip object
var duDrawer
rawingUtilities = new DrawingUtilities(mButton);
duDrawer.beginFill(0xFFFFCC, 100);
duDrawer.drawRectangle(nWidth, nHeight, nWidth/2, nHeight/2);
duDrawer.endFill();
// Add a TextField object to the MovieClip. Apply the label.
var tLabel:TextField = mButton.createTextField("tLabel",
mButton.getNextHighestDepth(),0,0, nWidth, nHeight);
tLabel.Selectable = false;
tLabel.text = sLabel;
return mButton;
function makeLoginScreen():Void {
//Create the TextField and MovieClip Objects.
this.createTextField("tUsername", this.getNextHighestDepth(),
100, 100, 200, 20);
this.createTextField("tPassword", this.getNextHighestDepth(),
100, 140, 200, 20);
this.createTextField("tMessage", this.getNextHighestDepth(),
100, 60, 200, 20);
mLoginButton = drawButton(this, "Login", 100, 25);
//Set the properties of the TextField Objects.
tUsername.border = true;
tPassword.border = true;
tUserName.type = "input";
tPassword.type = "input";
tPassword.password = true;
tMessage.textColor = 0xFF0000;
//Place the button
mLoginButton._x = 100;
mLoginButton._y = 180;
mLoginButton.onRelease = function():Void {
//Check to see if the user has entered the correct username
//and password. If so, call the login() function.
//otherwise, display
//a message to the user and clear the values from the login
//TextField objects.
if(tUserName.text =="admin" && tPassword.text
=="admin") {
login();
else {
tMessage.text = "Try again.";
tUsername.text = "";
tPassword.text = "";
function login(): Void {
//Remove the TextField and MovieClip objects that made up
the
//login screen.
tUsername.removeTextField();
tPassword.removeTextField();
mLoginButton.removeMovieClip();
//Create the TextField and MovieClip for the notes screen.
this.createTextField("tNotes", this.getNextHighestDepth(),
100, 100, 350, 200);
mSaveButton = drawButton(this, "Save", 100, 25);
//Set the properties of the TextField Object.
tNotes.border = true;
tNotes.type = "input";
//Place the button
mSaveButton._x = 100;
mSaveButton._y = 320;
//Open a local shared object.
var lsoNotes:SharedObject = SharedObject.getLocal("notes");
// Assign the stored text, if any.
tNotes.text = (lsoNotes.data.notes == undefined) ? "" :
lsoNotes.data.notes;
//When the user clicks and releases the button store the
current
//current notes. in the shared object
mSaveButton.onRelease = function():Void {
lsoNotes.data.notes = tNotes.text;
lsoNotes.flush(); -
How to preload using AS 3.0?
Hi!
I am using ActionScript 3.0 with Flash 9.
I have asked this in many diferent places without any answer
yet.Hopefully I will get my ansewers here.
I have this code to preload external swf files :
var request:URLRequest = new URLRequest("content.swf");
var loader:Loader = new Loader();
loader.contentLoaderInfo.addEventListener(ProgressEvent.PROGRESS,
loadProgress);
loader.contentLoaderInfo.addEventListener(Event.COMPLETE,
loadComplete);
function loadProgress(event:ProgressEvent):void {
var percentLoaded:Number =
event.bytesLoaded/event.bytesTotal;
percentLoaded = Math.round(percentLoaded * 100);
trace("Loading: "+percentLoaded+"%");
function loadComplete(event:Event):void {
trace("Complete");
loader.load(request);
addChild(loader);
I want to make a class so I can use it for many swf
files(although I can put it in a function and still use it many
times) and I came up with this code which I dont know if it is
right:
package
import flash.display.MovieClip;
import flash.display.*;
import flash.text.TextField;
import flash.net.URLRequest;
import flash.events.Event;
import flash.events.ProgressEvent;
public class Carregador extends MovieClip
public var _Barra : MovieClip = new MovieClip();
public var _Texto : TextField = new TextField();
public var _Palco : MovieClip = new MovieClip();
public var _Movie : String;
public var loader:Loader = new Loader();
public function set Palco(value:MovieClip):void
_Palco = value;
public function set Barra(value:MovieClip):void
_Barra = value;
public function set Texto(value:TextField):void
_Texto = value;
public function set Movie(value:String):void
_Movie = value;
public function loadSwf():void
var request:URLRequest = new URLRequest(_Movie);
loader.contentLoaderInfo.addEventListener(Event.OPEN,showPreloader);
loader.contentLoaderInfo.addEventListener(ProgressEvent.PROGRESS,
loadProgress);
loader.contentLoaderInfo.addEventListener(Event.COMPLETE,
loadComplete);
loader.load(request);
addChild(loader);
private function showPreloader(evt:Event):void
addChild(_Barra);
private function loadProgress(event:ProgressEvent):void
var percentLoaded:Number =
event.bytesLoaded/event.bytesTotal;
percentLoaded = Math.round(percentLoaded * 100);
_Barra.width = percentLoaded;
private function loadComplete(event:Event):void
removeChild(_Barra);
_Palco.addChild(_Movie);
Can You guys guide me throught the steps to make a class to
preload swf files into an empty movie clip in my movie?
thank youThe following package and class are in use on my site so you
can see what it does....
http://www.sd-dezign.com
I am using this exact code to preload a jpeg file (could be
any jpg, progressive jpg, gif, png or swf). I just wrote it like 2
days ago. Hope this helps you out.
This is the most basic of preloaders coded in AS3 and part of
an external package.
To use the package, it will need to be inside a folder called
cloader in the same area as the FLA file that uses it.
The second part is importing the package into the FLA and
then calling it with the necessary arguement which is the file you
want to load.
The third and final part is to add the preloader to the
display list.
Putting it all together, it would look something like
this.... -
Access document stage instead of object stage
Hi AS3 community,
I've run into a brick wall and was hoping I could use your help. I have the following class set up:
package
import flash.events.MouseEvent;
import flash.text.TextField;
import flash.display.MovieClip;
import flash.text.TextFormat;
public class NPC extends MovieClip
public function NPC(varX:Number,varY:Number,varName:String)
// constructor code
this.x=varX;
this.y=varY;
this.addEventListener(MouseEvent.CLICK,actionWindow);
public function actionWindow(event:MouseEvent):void
var format:TextFormat= new TextFormat();
format.size=15;
var dialogue:TextField=new TextField();
dialogue.defaultTextFormat=format;
dialogue.text="Welcome to Russ's Test Environment!";
dialogue.border=true;
dialogue.background=true;
dialogue.backgroundColor=0xE8F2FA;
dialogue.wordWrap=true;
dialogue.width=650;
dialogue.x=25;
dialogue.y=25;
addChild(dialogue);
And have the following on the timeline:
var compy:NPC = new NPC(400,200,"Joe");
addChild(compy);
This correctly creates my object on the stage, however when I click on it the dialogue box appears in relation to the object and not the stage itself (in this instance, x 425 y 225). What would I want to do in order to place the text box at x 25 y 25?You can do:
dialogue.x = 25 - x;
dialogue.y = 25 - y;
However perhaps the better approach is to create the text field in the Document class (or the main timeline.)
Kenneth Kawamoto
http://www.materiaprima.co.uk/ -
Access of undefined property (dynamic text box)
Hi guys,
I have a movie clip working as a button that is disabled after click. I need to add a scoring option, so that on click it also adds to the score. When I add the scoreGame function, it says the text box is undefined. Ideas?
Here's the code:
package
import flash.display.MovieClip;
import flash.events.MouseEvent;
public class DisablingButtons extends MovieClip
var labels:Array;
var thisParent:*;
var score:Number = 0;
var goalScore:Number = 8;
public function DisablingButtons()
trace("it's working!");
labels = this.currentLabels;
this.addEventListener(MouseEvent.CLICK, scoreGame);
this.addEventListener(MouseEvent.CLICK, disableButton);
this.addEventListener(MouseEvent.ROLL_OVER, over);
this.addEventListener(MouseEvent.ROLL_OUT, out);
function scoreGame(myEvent:MouseEvent):void
score++;
score1.text = String(score);
if (score == goalScore)
gotoAndStop(201);
function disableButton(event:MouseEvent):void
for (var i:int = 0; i < labels.length; i++)
if (labels[i].name == "disable")
this.gotoAndPlay("disable");
this.removeEventListener(MouseEvent.CLICK, disableButton);
this.removeEventListener(MouseEvent.ROLL_OVER, over);
this.removeEventListener(MouseEvent.ROLL_OUT, out);
function over(event:MouseEvent):void
for (var j:int = 0; j < labels.length; j++)
if (labels[j].name == "over")
this.gotoAndPlay("over");
function out(event:MouseEvent):void
for (var k:int = 0; k < labels.length; k++)
if (labels[k].name == "out")
this.gotoAndPlay("out");When you instantiate the class in your fla, you would pass the textfield to the class...
import DisablingButtons;
var btn:DisablingButtons = new DisablingButtons(score1);
addChild(btn);
And in your class file you would need to adjust it to accept the textfield such as what I show below. Just realize that I have manipulated the naming to preserve your score1 name at both ends of your code by naming the argument that the class sees differently (txt). Otherwise I would have normally used a differewnt variable name within the class than score1
package
import flash.text.TextField;
import flash.display.MovieClip;
import flash.events.MouseEvent;
public class DisablingButtons extends MovieClip
var labels:Array;
var thisParent:*;
var score:Number = 0;
var goalScore:Number = 8;
var score1:TextField;
public function DisablingButtons(txt:TextField)
trace("it's working!");
score1 = txt;
labels = this.currentLabels;
this.addEventListener(MouseEvent.CLICK, scoreGame);
this.addEventListener(MouseEvent.CLICK, disableButton);
this.addEventListener(MouseEvent.ROLL_OVER, over);
this.addEventListener(MouseEvent.ROLL_OUT, out);
etc... -
I'm trying to develop a simple as3 flash program that passes a collection a variables and returns a result based on the filtered results of a mysql table. Here is my as3 file:
import flash.text.TextField;
import flash.display.MovieClip;
import flash.events.MouseEvent;
XML.ignoreComments = true;
XML.ignoreProcessingInstructions = true;
import flash.events.Event;
import flash.net.URLLoader;
import flash.net.URLRequest;
var dummy:int = 2;
var dummy1:int = 1;
var dummy2:int = 1;
var dummy3:int = 2;
var test:int = 10;
var dum1:int = 1;
var dowstart:String;
var season:String;
var dowstop:String;
var questions:TextField = new TextField();
addChild(questions);
questions.textColor = 0xff0000;
questions.x = 30;
questions.y = 20;
questions.autoSize = TextFieldAutoSize.LEFT ;
questions.text=("\t\t\t" + "PLEASE ENTER OR SELECT YOUR FACILITY'S" + "\n\n\n" + "PEAK LOAD:" + "\t\t\t\t" + "kilowatts" + "\n\n" + "HOURS OF OPERATION:" + "\n\n" + "DAY'S OF OPERATION:" + "\n\n" + "SEASONS OF HIGHEST CONSUMPTION:" + "\n\n\n\t\t\t" + "GIVEN 10 MINUTE NOTICE, YOUR FACILITY COULD" + "\n\n\n" + "COMFORTABLY CURTAIL:" + "\t\t\t\t\t" + "kilowatts" + "\n\n" + "FOR:" + "\t\t" + "hours" + "\n\n\n\t\t" + "GIVEN 30 MINUTE NOTICE, YOUR FACILITY COULD" + "\n\n\n" + "COMFORTABLY CURTAIL:"+ "\t\t\t\t\t" + "kilowatts" + "\n\n" + "FOR:" + "\t\t" + "hours" );
var peak:TextField = new TextField();
peak.type = TextFieldType.INPUT;
peak.border = true;
peak.x = 115;
peak.y = 52;
peak.height = 18;
peak.width = 60;
peak.textColor = 0xff0000;
peak.backgroundColor = 0xCCCCCC;
peak.alpha = .1;
peak.background = true;
peak.wordWrap = true;
addChild(peak);
peak.addEventListener(MouseEvent.ROLL_OVER, over1)
function over1(e:MouseEvent) {
peak.alpha = .4;
peak.background = true;
peak.addEventListener(MouseEvent.ROLL_OUT, out1)
function out1(e:MouseEvent) {
peak.background = false;
var starttime:TextField = new TextField();
starttime.type = TextFieldType.INPUT;
starttime.border = true;
starttime.x = 175;
starttime.y = 78;
starttime.height = 18;
starttime.width = 20;
starttime.textColor = 0xff0000;
starttime.backgroundColor = 0xCCCCCC;
starttime.alpha = .1;
starttime.text = "9"
starttime.background = true;
starttime.wordWrap = true;
addChild(starttime);
starttime.addEventListener(MouseEvent.ROLL_OVER, over2)
function over2(e:MouseEvent) {
starttime.alpha = .4;
starttime.background = true;
starttime.addEventListener(MouseEvent.ROLL_OUT, out2)
function out2(e:MouseEvent) {
starttime.background = false;
var stoptime:TextField = new TextField();
stoptime.type = TextFieldType.INPUT;
stoptime.border = true;
stoptime.x = 250;
stoptime.y = 78;
stoptime.height = 18;
stoptime.width = 20;
stoptime.textColor = 0xff0000;
stoptime.backgroundColor = 0xCCCCCC;
stoptime.alpha = .1;
stoptime.text = "5"
stoptime.background = true;
stoptime.wordWrap = true;
addChild(stoptime);
stoptime.addEventListener(MouseEvent.ROLL_OVER, over3)
function over3(e:MouseEvent) {
stoptime.alpha = .4;
stoptime.background = true;
stoptime.addEventListener(MouseEvent.ROLL_OUT, out3)
function out3(e:MouseEvent) {
stoptime.background = false;
import flash.events.MouseEvent;
var am1:TextField = new TextField();
am1.border = true;
am1.x = 196;
am1.y = 80;
am1.height = 18;
am1.width = 40;
am1.textColor = 0x00ff00;
am1.alpha = .4;
am1.text = "AM";
am1.wordWrap = true;
addChild(am1);
am1.addEventListener(MouseEvent.MOUSE_OVER, over4)
am1.addEventListener(MouseEvent.MOUSE_OUT, out4)
am1.addEventListener(MouseEvent.CLICK, click4)
function over4(e:MouseEvent) {
am1.alpha = .7;
function out4(e:MouseEvent) {
if (dummy == 2) {
am1.alpha = .8
else
am1.alpha = .4
function click4(e:MouseEvent) {
if (dummy == 1){
am1.alpha = .9
am1.textColor = 0x00ff00;
pm1.textColor = 0xff0000;
pm1.alpha = .4;
dummy = 2
else if (dummy == 2){
am1.textColor = 0xff0000;
am1.alpha = .4;
dummy = 1
var pm1:TextField = new TextField();
pm1.border = true;
pm1.x = 220;
pm1.y = 80;
pm1.height = 18;
pm1.width = 40;
pm1.textColor = 0xff0000;
pm1.alpha = .4;
pm1.text = "PM";
pm1.wordWrap = true;
addChild(pm1);
pm1.addEventListener(MouseEvent.MOUSE_OVER, over5)
pm1.addEventListener(MouseEvent.MOUSE_OUT, out5)
pm1.addEventListener(MouseEvent.CLICK, click5)
function over5(e:MouseEvent) {
pm1.alpha = .7;
function out5(e:MouseEvent) {
if (dummy1 == 2) {
pm1.alpha = .8
else
pm1.alpha = .4
function click5(e:MouseEvent) {
if (dummy1 == 1){
pm1.alpha = .9
pm1.textColor = 0x00ff00;
am1.textColor = 0xff0000;
am1.alpha = .4;
dummy1 = 2
else if (dummy1 == 2){
pm1.textColor = 0xff0000;
pm1.alpha = .4;
dummy1 = 1
var am2:TextField = new TextField();
am2.border = true;
am2.x = 272;
am2.y = 80;
am2.height = 18;
am2.width = 40;
am2.textColor = 0xff0000;
am2.alpha = .4;
am2.text = "AM";
am2.wordWrap = true;
addChild(am2);
am2.addEventListener(MouseEvent.MOUSE_OVER, over6)
am2.addEventListener(MouseEvent.MOUSE_OUT, out6)
am2.addEventListener(MouseEvent.CLICK, click6)
function over6(e:MouseEvent) {
am2.alpha = .7;
function out6(e:MouseEvent) {
if (dummy2 == 2) {
am2.alpha = .8
else
am2.alpha = .4
function click6(e:MouseEvent) {
if (dummy2 == 1){
am2.alpha = .9
am2.textColor = 0x00ff00;
pm2.textColor = 0xff0000;
pm2.alpha = .4;
dummy2 = 2
else if (dummy2 == 2){
am2.textColor = 0xff0000;
am2.alpha = .4;
dummy2 = 1
var pm2:TextField = new TextField();
pm2.border = true;
pm2.x = 296;
pm2.y = 80;
pm2.height = 18;
pm2.width = 40;
pm2.textColor = 0x00ff00;
pm2.alpha = .4;
pm2.text = "PM";
pm2.wordWrap = true;
addChild(pm2);
pm2.addEventListener(MouseEvent.MOUSE_OVER, over7)
pm2.addEventListener(MouseEvent.MOUSE_OUT, out7)
pm2.addEventListener(MouseEvent.CLICK, click7)
function over7(e:MouseEvent) {
pm2.alpha = .7;
function out7(e:MouseEvent) {
if (dummy3 == 2) {
pm2.alpha = .8
else
pm2.alpha = .4
function click7(e:MouseEvent) {
if (dummy3 == 1){
pm2.alpha = .9
pm2.textColor = 0x00ff00;
am2.textColor = 0xff0000;
am2.alpha = .4;
dummy3 = 2
else if (dummy3 == 2){
pm2.textColor = 0xff0000;
pm2.alpha = .4;
dummy3 = 1
var to1:TextField = new TextField();
addChild(to1);
to1.text = "to";
to1.textColor = 0xff0000;
to1.y = 105;
to1.x = 290;
var myArray:Array = new Array();
for (var i:int = 0; i<10; i++){
var mc:TextField = new TextField();
addChild(mc);
mc.x = 160 + 16 * i;
mc.y = 105;
mc.textColor = 0xff0000;
// then add a reference to it to the array.
myArray.push(mc);
myArray[1].text = "S";
myArray[2].text = "M";
myArray[3].text = "T";
myArray[4].text = "W";
myArray[5].text = "T";
myArray[6].text = "F";
myArray[7].text = "S";
var myArray1:Array = new Array();
for (var J:int = 0; J<10; J++){
var mc1:TextField = new TextField();
addChild(mc1);
mc1.x = 300 + 16 * J;
mc1.y = 105;
mc1.textColor = 0xff0000;
// then add a reference to it to the array.
myArray1.push(mc1);
myArray1[1].text = "S";
myArray1[2].text = "M";
myArray1[3].text = "T";
myArray1[4].text = "W";
myArray1[5].text = "T";
myArray1[6].text = "F";
myArray1[7].text = "S";
myArray[1].addEventListener(MouseEvent.CLICK, clicker)
function clicker(e:MouseEvent) {
dowstart = "S";
myArray[1].textColor = 0x00ff00;
myArray[2].addEventListener(MouseEvent.CLICK, clicker1)
function clicker1(e:MouseEvent) {
dowstart = "M";
myArray[2].textColor = 0x00ff00;
myArray[3].addEventListener(MouseEvent.CLICK, clicker2)
function clicker2(e:MouseEvent) {
dowstart = "T";
myArray[3].textColor = 0x00ff00;
myArray[4].addEventListener(MouseEvent.CLICK, clicker3)
function clicker3(e:MouseEvent) {
dowstart = "W";
myArray[4].textColor = 0x00ff00;
myArray[5].addEventListener(MouseEvent.CLICK, clicker4)
function clicker4(e:MouseEvent) {
dowstart = "TH";
myArray[5].textColor = 0x00ff00;
myArray[6].addEventListener(MouseEvent.CLICK, clicker5)
function clicker5(e:MouseEvent) {
dowstart = "F";
myArray[6].textColor = 0x00ff00;
myArray[7].addEventListener(MouseEvent.CLICK, clicker6)
function clicker6(e:MouseEvent) {
dowstart = "SA";
myArray[7].textColor = 0x00ff00;
myArray1[1].addEventListener(MouseEvent.CLICK, clickera)
function clickera(e:MouseEvent) {
dowstop = "S";
myArray1[1].textColor = 0x00ff00;
myArray1[2].addEventListener(MouseEvent.CLICK, clickera1)
function clickera1(e:MouseEvent) {
dowstop = "M";
myArray1[2].textColor = 0x00ff00;
myArray1[3].addEventListener(MouseEvent.CLICK, clickera2)
function clickera2(e:MouseEvent) {
dowstop = "T";
myArray1[3].textColor = 0x00ff00;
myArray1[4].addEventListener(MouseEvent.CLICK, clickera3)
function clickera3(e:MouseEvent) {
dowstop = "W";
myArray1[4].textColor = 0x00ff00;
myArray1[5].addEventListener(MouseEvent.CLICK, clickera4)
function clickera4(e:MouseEvent) {
dowstop = "TH";
myArray1[5].textColor = 0x00ff00;
myArray1[6].addEventListener(MouseEvent.CLICK, clickera5)
function clickera5(e:MouseEvent) {
dowstop = "F";
myArray1[6].textColor = 0x00ff00;
myArray1[7].addEventListener(MouseEvent.CLICK, clickera6)
function clickera6(e:MouseEvent) {
dowstop = "SA";
myArray1[7].textColor = 0x00ff00;
var myArray4:Array = new Array();
for (var M:int = 0; M<4; M++){
var textli:TextField = new TextField();
addChild(textli);
textli.x = 280 + 60 * M;
textli.y = 128;
textli.textColor = 0xff0000;
// then add a reference to it to the array.
myArray4.push(textli);
myArray4[0].text = "Winter";
myArray4[1].text = "Spring";
myArray4[2].text = "Summer";
myArray4[3].text = "Fall";
myArray4[0].addEventListener(MouseEvent.CLICK, clickerab3)
function clickerab3(e:MouseEvent) {
season = "Winter" + ' ' + season;
myArray4[0].textColor = 0x00ff00;
myArray4[1].addEventListener(MouseEvent.CLICK, clickerab4)
function clickerab4(e:MouseEvent) {
season = "Spring" + ' '+ season;
myArray4[1].textColor = 0x00ff00;
myArray4[2].addEventListener(MouseEvent.CLICK, clickerab5)
function clickerab5(e:MouseEvent) {
season = "Summer" + ' '+ season;
myArray4[2].textColor = 0x00ff00;
myArray4[3].addEventListener(MouseEvent.CLICK, clickerab6)
function clickerab6(e:MouseEvent) {
season = "Fall"+ ' ' + season;
myArray4[3].textColor = 0x00ff00;
var curt:TextField = new TextField();
curt.type = TextFieldType.INPUT;
curt.border = true;
curt.x = 200;
curt.y = 198;
curt.height = 18;
curt.width = 60;
curt.textColor = 0xff0000;
curt.backgroundColor = 0xCCCCCC;
curt.alpha = .1;
curt.background = true;
curt.wordWrap = true;
addChild(curt);
curt.addEventListener(MouseEvent.ROLL_OVER, onter)
function onter(e:MouseEvent) {
curt.alpha = .4;
curt.background = true;
curt.addEventListener(MouseEvent.ROLL_OUT, outterr)
function outterr(e:MouseEvent) {
curt.background = false;
var mincurt:TextField = new TextField();
mincurt.type = TextFieldType.INPUT;
mincurt.border = true;
mincurt.x = 65;
mincurt.y = 223;
mincurt.height = 18;
mincurt.width = 20;
mincurt.textColor = 0xff0000;
mincurt.backgroundColor = 0xCCCCCC;
mincurt.alpha = .1;
mincurt.background = true;
mincurt.wordWrap = true;
addChild(mincurt);
mincurt.addEventListener(MouseEvent.ROLL_OVER, oveeee2)
function oveeee2(e:MouseEvent) {
mincurt.alpha = .4;
mincurt.background = true;
mincurt.addEventListener(MouseEvent.ROLL_OUT, outtttt)
function outtttt(e:MouseEvent) {
mincurt.background = false;
var curter:TextField = new TextField();
curter.type = TextFieldType.INPUT;
curter.border = true;
curter.x = 200;
curter.y = 298;
curter.height = 18;
curter.width = 60;
curter.textColor = 0xff0000;
curter.backgroundColor = 0xCCCCCC;
curter.alpha = .1;
curter.background = true;
curter.wordWrap = true;
addChild(curter);
curter.addEventListener(MouseEvent.ROLL_OVER, onter1)
function onter1(e:MouseEvent) {
curter.alpha = .4;
curter.background = true;
curter.addEventListener(MouseEvent.ROLL_OUT, outterr1)
function outterr1(e:MouseEvent) {
curter.background = false;
var mincurter:TextField = new TextField();
mincurter.type = TextFieldType.INPUT;
mincurter.border = true;
mincurter.x = 65;
mincurter.y = 323;
mincurter.height = 18;
mincurter.width = 20;
mincurter.textColor = 0xff0000;
mincurter.backgroundColor = 0xCCCCCC;
mincurter.alpha = .1;
mincurter.background = true;
mincurter.wordWrap = true;
addChild(mincurter);
mincurter.addEventListener(MouseEvent.ROLL_OVER, oveeeeeeee2)
function oveeeeeeee2(e:MouseEvent) {
mincurter.alpha = .4;
mincurter.background = true;
mincurter.addEventListener(MouseEvent.ROLL_OUT, outtterert)
function outtterert(e:MouseEvent) {
mincurter.background = false;
submit_button.addEventListener(MouseEvent.CLICK, doButton);
function doButton(anEvent:MouseEvent):void
var myData1:URLRequest = new URLRequest("/phptest.php");
myData1.method = URLRequestMethod.POST;
var vars1:URLVariables = new URLVariables();
vars1.peak = test;
vars1.starttime = starttime.text;
vars1.stoptime = stoptime.text;
vars1.ampm1 = dummy;
vars1.ampm2 = dummy3;
vars1.dowstart = dowstart;
vars1.dowstop = dowstop;
vars1.curt1 = curt.text;
vars1.mincurt = mincurt.text;
vars1.curter = curter.text;
vars1.mincurter = mincurter.text;
myData1.data = vars1;
var loader1:URLLoader = new URLLoader();
loader1.dataFormat = URLLoaderDataFormat.VARIABLES;
loader1.load(myData1);
var externalXML:XML;
var loader2:URLLoader = new URLLoader();
var request:URLRequest = new URLRequest("/phptest.php");
loader2.load(request);
loader2.addEventListener(Event.COMPLETE, onComplete);
function onComplete(event:Event):void
var loader2:URLLoader = event.target as URLLoader;
if (loader2 != null)
externalXML = new XML(loader2.data);
trace(externalXML.toXMLString());
jon.text = (externalXML.toXMLString());
else
trace("loader is not a URLLoader!");
My phptest.php file is:
<?PHP
$test = $_POST['peak'];
$test2 = $_POST['starttime'];
$test3 = $_POST['stoptime'];
$test4 = $_POST['ampm1'];
$test5 = $_POST['ampm2'];
$test6 = $_POST['dowstart'];
$test7 = $_POST['dowstop'];
$test8 = $_POST['curt1'];
$test9 = $_POST['mincurt'];
$test10 = $_POST['curter'];
$test11 = $_POST['mincurter'];
$wow = 1;
$wow1 = 17;
$link = mysql_connect("brimelowstore.db.7009460.hostedresource.com","brimelowstore","listeriusA1" );
mysql_select_db("brimelowstore");
$query = "SELECT * FROM pjm WHERE hour > $wow AND '$test4' < '$test5'";
$results = mysql_query($query);
echo "<?xml version=\"1.0\"?>\n";
$line = mysql_fetch_assoc($results);
echo "expected value:" . array_sum($line)*20/count($line) ;
mysql_close($link);
?>
No value is returned. If I replace with '$test4' and '$test5' with numbers such as 1 and 17, a value is returned. Where am I making a mistake?i didn't go through all your code (and i'm not sure anyone will go through all that in a forum) but at the end i see two calls to a php file. which is the problematic call and where are you adding the variables that need to be sent to your urlloader?
-
Record from webcam to f4v on FMS
I'm trying to build / modify an application to record from webcam and microphone, in a web browser and save it to an FMS 5.4.2 server to stream via web and iOS
recording as a flv file works fine and it plays back just fine in firefox / any browser
I can steam f4v files over http as filename.f4v.m3u8 and that works fine with the samples that come with FMS from my record folder (/opt/adobe/fms/applications/record/streams/)
My flash web application can record to the FMS server, the file it records has the .f4v file extension, has content (i see the file size), and has time in quicktime (4 or 5 seconds - just a test) but it doesn't play - the screen is black and never starts.
I know i'm right on the edge of figuring this out, I just don't know what I'm missing or whats wrong (i'm a php programmer, not action script)
any ideas ?
here is the code i'm working with:
package com
import fl.controls.ProgressBar;
import fl.controls.ProgressBarMode;
import flash.display.MovieClip;
import flash.events.Event;
import com.NetConnector
import flash.events.MouseEvent;
import flash.events.TimerEvent;
import flash.media.Camera;
import flash.media.Microphone;
import flash.media.Video;
import flash.net.navigateToURL;
import flash.net.NetConnection;
import flash.net.NetStream;
import flash.net.URLLoader;
import flash.net.URLLoaderDataFormat;
import flash.net.URLRequest;
import flash.net.URLRequestMethod;
import flash.net.URLVariables;
import flash.text.TextField;
import flash.utils.setTimeout;
import flash.utils.Timer;
import flash.media.H264Level;
import flash.media.H264Profile;
import flash.media.H264VideoStreamSettings;
import flash.media.VideoCodec;
* @author Alexander (flash2you) < >
public class Recorder extends MovieClip
private var dataHolder:DataHolder = DataHolder.getInstance()
public var layer:MovieClip
public var activityLevel_pb:ProgressBar
public var aguja:MovieClip
public var aguja2:MovieClip
public var publishButton:MovieClip
public var timer_txt:TextField
public var recordStatus:MovieClip
public var recordBtn:MovieClip
private var netStream:NetStream
private var microphone:Microphone = Microphone.getMicrophone()
private var camera:Camera = Camera.getCamera()
public var video:Video
private var timer:Timer = new Timer(100)
private var clockTimer:Timer = new Timer(1000)
public var published:Boolean = false
private var isRecording:Boolean = false
private var minutero = 0;
private var crono = 0;
private var records = 0;
public var settings_mc:MovieClip
public static var recorder:Recorder
public var settings_icon:MovieClip
private var limitTimer:Timer
public function Recorder()
Recorder.recorder = this;
timer.addEventListener(TimerEvent.TIMER, on$timer)
clockTimer.addEventListener(TimerEvent.TIMER, on$clockTimer)
//visible = false
recordBtn.buttonMode = true
recordBtn.addEventListener(MouseEvent.CLICK , recordBtn$click)
recordBtn.addEventListener(MouseEvent.MOUSE_OVER, recordBtn$over)
recordBtn.addEventListener(MouseEvent.MOUSE_OUT, recordBtn$out)
addEventListener(Event.ADDED_TO_STAGE, onAddedToStage)
limitTimer = new Timer(dataHolder.timelimit * 1000);
limitTimer.addEventListener(TimerEvent.TIMER, onLimitTimerHandler)
private function onLimitTimerHandler(e:TimerEvent):void
stopPublish()
* when we comes to second frame
private function onAddedToStage(e:Event):void
removeEventListener(Event.ADDED_TO_STAGE, onAddedToStage);
init()
* function for set up camera from settings module
public function setCamera(_camera:Camera) {
camera = _camera
addCameraSettings()
video.width = 1280;
video.height = 720;
video.attachCamera(camera)
if (netStream){
netStream.attachCamera(camera)
public function setMicrophone(mic:Microphone) {
microphone = mic;
if (netStream){
netStream.attachAudio(microphone)
addMicSettings()
private function addMicSettings() {
microphone.setUseEchoSuppression(true);
microphone.setSilenceLevel(1)
private function addCameraSettings():void
camera.setMode(1280, 720, 25);
camera.setLoopback(true);
camera.setQuality(0, 100);
public function init() {
startConnect()
* main function for connection
private function startConnect() {
visible = true
timer_txt.htmlText = "<b>00:00</b>";
initCamera()
initMicropone()
var nc:NetConnection = new NetConnection()
nc.connect(null)
netStream = new NetStream(nc)
netStream.attachAudio(microphone)
video.attachCamera(camera)
layer.visible = false
publishButton.gotoAndStop(1);
activityLevel_pb.mode = ProgressBarMode.MANUAL;
recordStatus.gotoAndStop("noRecord")
timer.start()
connection.addEventListener(NetConnector.CONNECTED, connectionComplete)
connection.startConnection()
public function get connection():NetConnector {
return dataHolder.connection
private function on$timer(e:TimerEvent) {
activityLevel_pb.setProgress(microphone.activityLevel, 100)
* when connection to your stream server done
private function connectionComplete(e:Event = null) {
netStream = new NetStream(connection)
netStream.attachAudio(microphone)
netStream.attachCamera(camera)
* add 0 if less then 10secs
private function addLeading(nbr) {
if (nbr<10) {
return ("0"+Math.floor(nbr));
} else {
return (Math.floor(nbr).toString());
* update visible clock, rotate arrows
private function updateTimer() {
timer_txt.htmlText = "<b>"+addLeading(crono/60)+":"+addLeading(crono%60)+"</b>";
aguja.rotation = aguja.rotation+6;
if (addLeading(crono/60)>minutero) {
aguja2.rotation = aguja2.rotation+6;
++minutero;
// end if
++crono;
private function on$clockTimer(e:TimerEvent):void
updateTimer()
private function startClockTimer() {
clockTimer.start()
* update graphics and start recording
private function recordBtn$click(e:MouseEvent):void
if (!isRecording) {
startRecording()
recordStatus.gotoAndStop("record")
recordBtn.visible = false
private function recordBtn$over(e:MouseEvent):void
if (!isRecording) {
this.gotoAndPlay(65);
private function recordBtn$out(e:MouseEvent):void
if (!isRecording) {
this.gotoAndPlay(61);
private function startRecording() {
if (connection.connected){
netStream.publish("mp4:" + dataHolder.filename + ".f4v", "record");
isRecording = true
startClockTimer()
publishButton.gotoAndPlay(2)
publishButton.buttonMode = true
publishButton.addEventListener(MouseEvent.CLICK, publishButton$click);
limitTimer.start()
* redirect to finishURL that was passed via flashvars
private function publishButton$click(e:MouseEvent):void
stopPublish()
var request:URLRequest = new URLRequest(dataHolder.finishURL)
navigateToURL(request, "_self")
private function stopPublish():void
netStream.close();
connection.close();
limitTimer.stop();
clockTimer.stop();
isRecording = false
recordStatus.gotoAndStop("recordEnd")
updateTimer();
* init microphone
private function initMicropone():void
microphone = Microphone.getMicrophone()
addMicSettings()
* init camera
private function initCamera():void
camera = Camera.getCamera()
addCameraSettings()Hi,
Thanks for the details
First, the quality of the feed we get to the flash player and FMS is highly limited by the capabilities of the webcam that the users have beyond which we cannot improve the quality.
Next, flash player can encode good quality and hence you should probably find more stuff related to how best you can ingest video from a webcam on to the flash player.
- Does recording from server side with asc script will increase the quality ?
No, FMS does not do any type of transcoding/re-encoding stuff. All it does is to 'transmit' and in your case, to flush bits to the disk. So, unless FMS recieves 'Quality', it cannot do much.
- what configurations files on the server can i adjust to increase the recording quality ?
From above, it flows that, there are no configurations on the server that can make your quality grow. The configurations are more to do with delivery. It can be tweaked to improve streaming, reduce latency, quick start and more.
- is there a way to cache locally the stream if the bandwith is not high enough, and when the user stops recording, upload it to the server (it doesn't have to be live or broadcast).
I don't think flash player can do this.
Thank you ! -
Keywords zooming in and out on different places
Well guys, I have an great idea that I can't fix.
The idea is quite simple. I have 23 keywords in an XML file.
In an area of 1600px by 500px there should be zooming in and out (for about 5,6,7 sec which depends on the number of letters) 10 keywords, randomly chosen from the XML file. Each keyword may appear in different spots in the area, it doesn't matter.
Can someone show me how to fix this zooming in and out keywords?
Thanks in advance!create a movieclip that contains a textfield and assign the movieclip a class. load your xml and chose 10 nodes to use to assign text to 10 movieclip instance textfields, add them to the display list, assign their x and y properties and use a loop to assign scaleX and scaleY properties.
-
Error #1010: a term is undefined
Error #1010: Een term is ongedefinieerd ....
TypeError: Error #1010: a term is undefined and has no properties.
at portfolio_fla::guestbook_MC_113/serverScoreFeedback()
at flash.events::EventDispatcher/dispatchEventFunction()
at flash.events::EventDispatcher/dispatchEvent()
at flash.net::URLLoader/onComplete()
Hi, i have this fully working fla, wich sends and gets info out of a database
its a frame and a actionframe
when i put these in a mc on the mainstage of another fla, its not working anymore
ive been searching like hell, but cant find the error
probably something thats not imported in the maintimeline.as????
this is the code
maintimeline.as
ActionScript 3 Code:
package portfolio_fla
import flash.display.*;
import flash.events.*;
import flash.net.*;
import flash.text.*;
dynamic public class MainTimeline extends MovieClip
public var knop_cv:SimpleButton;
public var knop_about:SimpleButton;
public var knop_webdesign:SimpleButton;
public var knop_photography:SimpleButton;
public var knop_contact:SimpleButton;
public var diafragma:MovieClip;
public var geklikt:String;
public var knop_home:SimpleButton;
public var knop_guestbook:SimpleButton;
public var home_text:TextField;
public var about_text:TextField;
public var contactform:MovieClip;
public var guestbookform:MovieClip;
var txtFile:String = "home.txt";
var urlRequest:URLRequest = new URLRequest (txtFile);
var loader:URLLoader = new URLLoader();
var txtFile2:String = "about.txt";
var urlRequest2:URLRequest = new URLRequest (txtFile2);
var loader2:URLLoader = new URLLoader();
function loadHandler(e:Event):void
var loader:URLLoader = URLLoader(e.target);
home_text.text = loader.data;
contactform.visible = false;
guestbookform.visible = false;
about_text.visible = false;
function loadHandler2(e:Event):void
var loader2:URLLoader = URLLoader(e.target);
about_text.text = loader2.data;
public function MainTimeline()
loader.addEventListener(Event.COMPLETE, loadHandler);
loader.load(urlRequest);
loader2.addEventListener(Event.COMPLETE, loadHandler2);
loader2.load(urlRequest2);
addFrameScript(0, frame1, 19, frame20);
return;
}// end function
function frame1()
knop_home.addEventListener(MouseEvent.CLICK, home);
knop_about.addEventListener(MouseEvent.CLICK, about);
knop_cv.addEventListener(MouseEvent.CLICK, cv);
knop_webdesign.addEventListener(MouseEvent.CLICK, webdesign);
knop_photography.addEventListener(MouseEvent.CLICK, photography);
knop_guestbook.addEventListener(MouseEvent.CLICK, guestbook);
knop_contact.addEventListener(MouseEvent.CLICK, contact);
stop();
return;
}// end function
function frame20()
stop();
return;
}// end function
function frame40()
stop();
return;
}// end function
function frame60()
stop();
return;
}// end function
function frame80()
stop();
return;
}// end function
function frame100()
stop();
return;
}// end function
function frame120()
stop();
return;
}// end function
function frame140()
stop();
return;
}// end function
public function contact(event:MouseEvent)
geklikt = "Contact";
this.diafragma.lamel1.gotoAndPlay(2);
this.diafragma.lamel2.gotoAndPlay(2);
this.diafragma.lamel3.gotoAndPlay(2);
this.diafragma.lamel4.gotoAndPlay(2);
this.diafragma.lamel5.gotoAndPlay(2);
this.diafragma.lamel6.gotoAndPlay(2);
this.diafragma.lamel7.gotoAndPlay(2);
this.diafragma.lamel8.gotoAndPlay(2);
this.diafragma.lamel9.gotoAndPlay(2);
this.diafragma.lamel10.gotoAndPlay(2);
return;
}// end function
public function guestbook(event:MouseEvent)
geklikt = "Guestbook";
this.diafragma.lamel1.gotoAndPlay(2);
this.diafragma.lamel2.gotoAndPlay(2);
this.diafragma.lamel3.gotoAndPlay(2);
this.diafragma.lamel4.gotoAndPlay(2);
this.diafragma.lamel5.gotoAndPlay(2);
this.diafragma.lamel6.gotoAndPlay(2);
this.diafragma.lamel7.gotoAndPlay(2);
this.diafragma.lamel8.gotoAndPlay(2);
this.diafragma.lamel9.gotoAndPlay(2);
this.diafragma.lamel10.gotoAndPlay(2);
return;
}// end function
public function photography(event:MouseEvent)
geklikt = "Photography";
this.diafragma.lamel1.gotoAndPlay(2);
this.diafragma.lamel2.gotoAndPlay(2);
this.diafragma.lamel3.gotoAndPlay(2);
this.diafragma.lamel4.gotoAndPlay(2);
this.diafragma.lamel5.gotoAndPlay(2);
this.diafragma.lamel6.gotoAndPlay(2);
this.diafragma.lamel7.gotoAndPlay(2);
this.diafragma.lamel8.gotoAndPlay(2);
this.diafragma.lamel9.gotoAndPlay(2);
this.diafragma.lamel10.gotoAndPlay(2);
return;
}// end function
public function webdesign(event:MouseEvent)
geklikt = "Webdesign";
this.diafragma.lamel1.gotoAndPlay(2);
this.diafragma.lamel2.gotoAndPlay(2);
this.diafragma.lamel3.gotoAndPlay(2);
this.diafragma.lamel4.gotoAndPlay(2);
this.diafragma.lamel5.gotoAndPlay(2);
this.diafragma.lamel6.gotoAndPlay(2);
this.diafragma.lamel7.gotoAndPlay(2);
this.diafragma.lamel8.gotoAndPlay(2);
this.diafragma.lamel9.gotoAndPlay(2);
this.diafragma.lamel10.gotoAndPlay(2);
return;
}// end function
public function cv(event:MouseEvent)
geklikt = "Cv";
this.diafragma.lamel1.gotoAndPlay(2);
this.diafragma.lamel2.gotoAndPlay(2);
this.diafragma.lamel3.gotoAndPlay(2);
this.diafragma.lamel4.gotoAndPlay(2);
this.diafragma.lamel5.gotoAndPlay(2);
this.diafragma.lamel6.gotoAndPlay(2);
this.diafragma.lamel7.gotoAndPlay(2);
this.diafragma.lamel8.gotoAndPlay(2);
this.diafragma.lamel9.gotoAndPlay(2);
this.diafragma.lamel10.gotoAndPlay(2);
return;
}// end function
public function about(event:MouseEvent)
geklikt = "About";
this.diafragma.lamel1.gotoAndPlay(2);
this.diafragma.lamel2.gotoAndPlay(2);
this.diafragma.lamel3.gotoAndPlay(2);
this.diafragma.lamel4.gotoAndPlay(2);
this.diafragma.lamel5.gotoAndPlay(2);
this.diafragma.lamel6.gotoAndPlay(2);
this.diafragma.lamel7.gotoAndPlay(2);
this.diafragma.lamel8.gotoAndPlay(2);
this.diafragma.lamel9.gotoAndPlay(2);
this.diafragma.lamel10.well, ive tried on putting the frames not in the MC, but on the mainstage
and the actionscript i put it into my other maintimeline.as
all works good, untill i paste the piece of
name_txt.text = "";
score_txt.text = "";
feedback_txt.text = "";
then i get
ReferenceError: Error #1065: Variabele name_txt is not defined
at portfolio_fla::MainTimeline$cinit()
at global$init()
why is this?
the code works on its own, then i didnt need to define name_txt
this is how maintimeline.as looks like now
package portfolio_fla
import flash.display.*;
import flash.events.*;
import flash.net.*;
import flash.text.*;
dynamic public class MainTimeline extends MovieClip
public var knop_cv:SimpleButton;
public var knop_about:SimpleButton;
public var knop_webdesign:SimpleButton;
public var knop_photography:SimpleButton;
public var knop_contact:SimpleButton;
public var diafragma:MovieClip;
public var geklikt:String;
public var knop_home:SimpleButton;
public var knop_guestbook:SimpleButton;
public var home_text:TextField;
public var about_text:TextField;
public var contactform:MovieClip;
public var guestbookform:MovieClip;
var txtFile:String = "home.txt";
var urlRequest:URLRequest = new URLRequest (txtFile);
var loader:URLLoader = new URLLoader();
var txtFile2:String = "about.txt";
var urlRequest2:URLRequest = new URLRequest (txtFile2);
var loader2:URLLoader = new URLLoader();
const SERVER_FILE:String = "http://localhost/portfolio/highscore_board.php";
const SENT_SUCCESS:String = "Successful";
const SENT_FAILED:String = "Unsuccessful";
const NUM_OF_SCORES:int = 8;
function submitScoreToServer(evt:MouseEvent):void {
var passChecks:Boolean = true;
if(score_txt.text.length < 1) {
feedback_txt.text = "Please fill in a score.";
passChecks = false;
if(name_txt.text.length < 1) {
feedback_txt.text = "Please fill in a name.";
passChecks = false;
if(passChecks) {
submit_btn.enabled = false;
feedback_txt.text = "Submitting score...";
var urlVars:URLVariables = new URLVariables();
var urlReq:URLRequest = new URLRequest(SERVER_FILE);
var ldr:URLLoader = new URLLoader();
urlVars.todo = "insert";
urlVars.name = name_txt.text;
urlVars.score = score_txt.text;
urlReq.data = urlVars;
urlReq.method = URLRequestMethod.POST;
ldr.addEventListener(Event.COMPLETE, serverInsertFeedback);
ldr.load(urlReq);
function serverInsertFeedback(evt:Event):void {
var ldr:URLLoader = evt.target as URLLoader;
var urlVars:URLVariables = new URLVariables(ldr.data);
if(urlVars.result == SENT_SUCCESS) {
feedback_txt.text = "Score sent successfully.";
getScoreFromServer();
} else if(urlVars.result == SENT_FAILED) {
feedback_txt.text = "Problem submitting score to server.";
submit_btn.enabled = true;
function serverScoreFeedback(evt:Event):void {
var ldr:URLLoader = evt.target as URLLoader;
var urlVars:URLVariables = new URLVariables(ldr.data);
if(urlVars.result == SENT_SUCCESS) {
for(var i:int = 1; i <= NUM_OF_SCORES; i++) {
root["boardName0" + i + "_txt"].text = "Unoccupied";
root["boardScore0" + i + "_txt"].text = "-";
if(urlVars["name0" + i] != null) {
root["boardName0" + i + "_txt"].text = urlVars["name0" + i];
root["boardScore0" + i + "_txt"].text = urlVars["score0" + i];
feedback_txt.text = "Score board has been updated.";
} else if(urlVars.result == SENT_FAILED) {
feedback_txt.text = "There was a problem retrieving the scores.";
function getScoreFromServer():void {
feedback_txt.text = "Retrieving scores...";
var urlVars:URLVariables = new URLVariables();
var urlReq:URLRequest = new URLRequest(SERVER_FILE);
var ldr:URLLoader = new URLLoader();
urlVars.todo = "score";
urlReq.data = urlVars;
urlReq.method = URLRequestMethod.POST;
ldr.addEventListener(Event.COMPLETE, serverScoreFeedback);
ldr.load(urlReq);
name_txt.text = "";
score_txt.text = "";
feedback_txt.text = "";
submit_btn.addEventListener(MouseEvent.CLICK, submitScoreToServer);
getScoreFromServer();
function loadHandler(e:Event):void
var loader:URLLoader = URLLoader(e.target);
home_text.text = loader.data;
contactform.visible = false;
about_text.visible = false;
function loadHandler2(e:Event):void
var loader2:URLLoader = URLLoader(e.target);
about_text.text = loader2.data;
public function MainTimeline()
loader.addEventListener(Event.COMPLETE, loadHandler);
loader.load(urlRequest);
loader2.addEventListener(Event.COMPLETE, loadHandler2);
loader2.load(urlRequest2);
addFrameScript(0, frame1, 19, frame20);
return;
}// end function
function frame1()
knop_home.addEventListener(MouseEvent.CLICK, home);
knop_about.addEventListener(MouseEvent.CLICK, about);
knop_cv.addEventListener(MouseEvent.CLICK, cv);
knop_webdesign.addEventListener(MouseEvent.CLICK, webdesign);
knop_photography.addEventListener(MouseEvent.CLICK, photography);
knop_guestbook.addEventListener(MouseEvent.CLICK, guestbook);
knop_contact.addEventListener(MouseEvent.CLICK, contact);
stop();
return;
}// end function
function frame20()
stop();
return;
}// end function
function frame40()
stop();
return;
}// end function
function frame60()
stop();
return;
}// end function
function frame80()
stop();
return;
}// end function
function frame100()
stop();
return;
}// end function
function frame120()
stop();
return;
}// end function
function frame140()
stop();
return;
}// end function
public function contact(event:MouseEvent)
geklikt = "Contact";
this.diafragma.lamel1.gotoAndPlay(2);
this.diafragma.lamel2.gotoAndPlay(2);
this.diafragma.lamel3.gotoAndPlay(2);
this.diafragma.lamel4.gotoAndPlay(2);
this.diafragma.lamel5.gotoAndPlay(2);
this.diafragma.lamel6.gotoAndPlay(2);
this.diafragma.lamel7.gotoAndPlay(2);
this.diafragma.lamel8.gotoAndPlay(2);
this.diafragma.lamel9.gotoAndPlay(2);
this.diafragma.lamel10.gotoAndPlay(2);
return;
}// end function
public function guestbook(event:MouseEvent)
geklikt = "Guestbook";
this.diafragma.lamel1.gotoAndPlay(2);
this.diafragma.lamel2.gotoAndPlay(2);
this.diafragma.lamel3.gotoAndPlay(2);
this.diafragma.lamel4.gotoAndPlay(2);
this.diafragma.lamel5.gotoAndPlay(2);
this.diafragma.lamel6.gotoAndPlay(2);
this.diafragma.lamel7.gotoAndPlay(2);
this.diafragma.lamel8.gotoAndPlay(2);
this.diafragma.lamel9.gotoAndPlay(2);
this.diafragma.lamel10.gotoAndPlay(2);
return;
}// end function
public function photography(event:MouseEvent)
geklikt = "Photography";
this.diafragma.lamel1.gotoAndPlay(2);
this.diafragma.lamel2.gotoAndPlay(2);
this.diafragma.lamel3.gotoAndPlay(2);
this.diafragma.lamel4.gotoAndPlay(2);
this.diafragma.lamel5.gotoAndPlay(2);
this.diafragma.lamel6.gotoAndPlay(2);
this.diafragma.lamel7.gotoAndPlay(2);
this.diafragma.lamel8.gotoAndPlay(2);
this.diafragma.lamel9.gotoAndPlay(2);
this.diafragma.lamel10.gotoAndPlay(2);
return;
}// end function
public function webdesign(event:MouseEvent)
geklikt = "Webdesign";
this.diafragma.lamel1.gotoAndPlay(2);
this.diafragma.lamel2.gotoAndPlay(2);
this.diafragma.lamel3.gotoAndPlay(2);
this.diafragma.lamel4.gotoAndPlay(2);
this.diafragma.lamel5.gotoAndPlay(2);
this.diafragma.lamel6.gotoAndPlay(2);
this.diafragma.lamel7.gotoAndPlay(2);
this.diafragma.lamel8.gotoAndPlay(2);
this.diafragma.lamel9.gotoAndPlay(2);
this.diafragma.lamel10.gotoAndPlay(2);
return;
}// end function
public function cv(event:MouseEvent)
geklikt = "Cv";
this.diafragma.lamel1.gotoAndPlay(2);
this.diafragma.lamel2.gotoAndPlay(2);
this.diafragma.lamel3.gotoAndPlay(2);
this.diafragma.lamel4.gotoAndPlay(2);
this.diafragma.lamel5.gotoAndPlay(2);
this.diafragma.lamel6.gotoAndPlay(2);
this.diafragma.lamel7.gotoAndPlay(2);
this.diafragma.lamel8.gotoAndPlay(2);
this.diafragma.lamel9.gotoAndPlay(2);
this.diafragma.lamel10.gotoAndPlay(2);
return;
}// end function
public function about(event:MouseEvent)
geklikt = "About";
this.diafragma.lamel1.gotoAndPlay(2);
this.diafragma.lamel2.gotoAndPlay(2);
this.diafragma.lamel3.gotoAndPlay(2);
this.diafragma.lamel4.gotoAndPlay(2);
this.diafragma.lamel5.gotoAndPlay(2);
this.diafragma.lamel6.gotoAndPlay(2);
this.diafragma.lamel7.gotoAndPlay(2);
this.diafragma.lamel8.gotoAndPlay(2);
this.diafragma.lamel9.gotoAndPlay(2);
this.diafragma.lamel10.gotoAndPlay(2);
return;
}// end function
public function home(event:MouseEvent)
geklikt = "Home";
this.diafragma.lamel1.gotoAndPlay(2);
this.diafragma.lamel2.gotoAndPlay(2);
this.diafragma.lamel3.gotoAndPlay(2);
this.diafragma.lamel4.gotoAndPlay(2);
this.diafragma.lamel5.gotoAndPlay(2);
this.diafragma.lamel6.gotoAndPlay(2);
this.diafragma.lamel7.gotoAndPlay(2);
this.diafragma.lamel8.gotoAndPlay(2);
this.diafragma.lamel9.gotoAndPlay(2);
this.diafragma.lamel10.gotoAndPlay(2);
return;
}// end function
Maybe you are looking for
-
No images in portlets, directly or using PTHTTPRequest
The basic problem is that I cannot see images in a portlet. Even if I create a simple html page with an image tag! If I create a remote web server with the spec, http://www.google.comand a web service with the spec http://www.google.com/search, I can
-
Can't add java script to Adobe 7.0 PDF document
Hi, ran into a small problem using Adobe Pro 7.0. Created a interactive form in Adobe Designer 7.0. Want to add Java script to run when a user selects certain fields on the forms. However, when I try and use the advanced editing tools to gain access
-
How do i recover files after being trashed?
how do i recover files after being trashed?
-
Writing or modifying text files in java
Dear all, I have the next text file: goods: 5 bids: 4 % num, price, good, good, ..., good, # 0 2075 1 4 # 1 3000 1 2 3 4 # 2 520 3 # 3 3000 2 3 4 # I have to modify or create the file above, using output data from one java program. For example, The o
-
Z22 will hotsync with Desktop but not Outlook ???why???
No device Added Microsoft Outlook to my PC, so would be ready for potential iphone purchase - my first smartphone. Was so excited that I would be able to port over my calendar and address book information from my Palm Z22 to the new smartphone. unin