AS3 Code problem
I wrote this code:
match = new Array();
matchHoriz = new Array();
row = 0;
while (row < gridRows)
col = 0;
while (col < gridCols)
match = getHorizMatch (row, col);
if (match.length > 1)
match.unshift(grid[row][col]);
matchHoriz.push(match);
// ***1
if (match.length == 0)
col++;
else
col = col + match.length;
match.length = 0;
row ++;
// ***2
If I place trace(matchHoriz) on position // ***1 it shows the correct result (an array with matched objects).
If I place trace(matchHoriz) on position // ***2 it doesn't show anything.
What is wrong about my code???
Before I clear the match array, the array is added to the array matchHoriz so the data should be there no matter what I do with match array data. I figured out what was happening: when I add the match array with push, the data in the matchHoriz array doesn't look as I expected. I changed push with concat and everything is going right now.
Thanks.
Similar Messages
-
Can someone pls help me to change AS3 code to AS2 code
Hello! Dear All,
I dont understand why with AS3 code my swf file is not working smooth at all. I would like to try it with AS2. In publish setting when I am selecting Flash Player 8, AS2 my swf is running good but showing lots of code errors.
I dont have much knowledge about AS2 so if someone can help me with this...it would be great.
Thanks,
Cheers!
Code1:
import flash.external.ExternalInterface;
ExternalInterface.addCallback("GetVars",GetVars);
ExternalInterface.addCallback("SetVariable1",SetVariable1);
function GetVars():Array {
return [
{VariableName:"SetVariable1",DefaultValue:"Variable1"}
function SetVariable1(variable:String):void {
for (var i:int = 0; i < numChildren; i++) {
var mc:MovieClip=getChildAt(i) as MovieClip;
if (mc!=null&&mc.name=='Audi_Cup') {
mc.variable1=variable;
mc.SetVariable1(variable);
Code 2
this.mask_mc.cacheAsBitmap=true;
this.mask_mc.cacheAsBitmap=true;
Text1.mask=(mask_mc);
function SetVariable1(variable:String):void {
if (variable!=null) {
for (var i:int = 0; i < numChildren; i++) {
var mc:MovieClip=getChildAt(i) as MovieClip;
if (mc!=null&&mc.name=='Text1') {
var object:TextField=mc.getChildByName('InputTextField1') as TextField;
if (object!=null) {
object.text=variable;
SetVariable1(this.variable1);it's possible, but unlikely, you'll fix anything by converting to as2. so, what problems are you having with as3?
-
Ok, I have a simple ComboBox with instance name of dragonCombo
A Lable with an instance name of dragonLabel
Using a an AS3 called Dragon.as
When the ComboBox is clicked, a picture should pull up. The problem is, there are no errors, but The ComboBox is not listing any of the Labels I loaded. This is my AS3 code, maybe someone can see the mistake I have made somewhere.
package
import flash.display.MovieClip;
import flash.display.Loader;
import fl.controls.ComboBox;
import fl.data.DataProvider;
import flash.events.Event;
import flash.text.TextFieldAutoSize;
import flash.net.URLRequest;
import flash.net.navigateToURL;
import fl.controls.Label;
public class Dragons extends MovieClip{
public var dragonCombo:ComboBox;
public var dragonLabel:Label;
var comboDP:DataProvider;
var dragonLoader:Loader;
public function Dragons() {
setupComboDP();
setupdDragonCombo();
setupLabels();
private function setupComboDP():void{
comboDP = new DataProvider();
comboDP.addItem({ Label:"Fire"});
comboDP.addItem({ Label:"IceNFire"});
comboDP.addItem({ Label:"Ghost"});
private function setupDragonCombo():void{
dragonCombo.width = 150;
dragonCombo.prompt = "Choose a Dragon";
dragonCombo.dataProvider = comboDP;
dragonLoader = new Loader();
dragonLoader.x = 200.00;
dragonLoader.y = 60.00;
addChild(dragonLoader);
dragonCombo.addEventListener(Event.CHANGE,loadData);
public function setupLabels():void{
dragonLabel.text="";
dragonLabel.autoSize = dragonLabel.autoSize = TextFieldAutoSize.LEFT;
public function loadData(e:Event):void{
dragonLoader.load(new URLRequest("dragons3/"+e.target.selectedItem.Label.toLowerCase()+".png"));Your Dragons class is creating its own dragonCombo (it is not the one on the stage)...
public var dragonCombo:ComboBox;
that has no association with the combobox you placed on the stage manually as far as I can see.
Assuming this is not your document class, if all you are doing is importing the Dragons class, then you are not implementing it at all. You would have to have a line...
var dragons:Dragons = new Dragons();
in you fla in order to instantiate the class. At that point you might start seeing error messages because in doing that your class is trying to target an object that doesn't exist because it only declared the combobox, it did not create an instance of it, as in...
dragonCombo = new ComboBox(); -
Creating AS3 code for C++ classes converted with Alchemy (a là Box2D)
So I've a collection of C++ classes which I now have converting fine with Alchemy to a swc file and can call the exposed functions fine from my AS3 code.
What I'd really like to do is recreate stuff like Box2D's b2Vec.as class,
public class b2Vec2 extends b2Base {
public function b2Vec2(p:int) {
_ptr = p;
public function get v2():V2 {
return new V2(x, y);
public function set v2(v:V2):void {
x = v.x;
y = v.y;
public function get x():Number { return mem._mrf(_ptr + 0); }
public function set x(v:Number):void { mem._mwf(_ptr + 0, v); }
public function get y():Number { return mem._mrf(_ptr + 4); }
public function set y(v:Number):void { mem._mwf(_ptr + 4, v); }
This is a simple example, but shows what I'd like to do. On the C side of things, b2Vec2 is a struct,
/// A 2D column vector.
struct b2Vec2
/// Default constructor does nothing (for performance).
b2Vec2() {}
float32 x, y;
So, for this struct, it's easy to calculate that the first variable of a b2Vec2 object is a float, which will be the value in x and can be read via Alchemy's MemUser classes _mrf (read a fload from a point in memory) with _mrf(pointerAddress) and you can read in the second float with _mrf(pointerAddress + 4).
My question is, if you're not a C++ expert (me), is there any way to get the definition of a class, as in the addresses of all the variables within and what they are? So, for the b2Vec2 one, I'd imaging it'd be something like, float32 x 0 float34 y 4 ...
The reason I'm asking is because one of the classes in particular has loads of variables and to try and get each and every one's information so I can access it directly from the AS3 code would be lots of work and I'm going to assume I'll introduce plenty of human error to it.Hi,
I am facing the similar issue. Can you please tell me how you solved this problem in more details?
which sample code and how u can find that in SE24 and where to copy that code.
Thanks in advance..
vamsi. -
I need to make a task with less as3 code and more timeline structure and event dispatcher !
I went to an interview in a big company. I had to make a task in which there is a wall with 3 lines and 5 columns filled with bombs.When you click on a bomb the bomb changes its scale, a robot enters, goes under the bomb and takes it, then goes to a smaller wall, makes the bomb smaller and place it at the same place it had been in the previous wall.I made the task with tween througout as3 code.The interviewer told me it was good but i need to make it with the less code possible and with more complex timeline structure and to use event dispatcher.What is the best way to do this ?
The immediate thing that comes to mind is they might want to see that you can balance work between design teams and development teams.
To do that, the robots movements (pick up bomb, bomb grows/shrinks, arms/treads/legs moving, sequences of 'doing things') can be timeline based so animators can work on those separate from code.
Developers would be working on the logic of keeping score, moving the robot around to the correct spot with path detection, collision detection, etc.
It's very similar to thinking in simple factories (which Flash is good at being automatically with timelines), and a bit of MVC (or just VC in some cases).
Big companies have lots of different types of employees so you'll probably be very specific in your role so you're efficient. -
Messy code problem while translating XString to String in OfficeControl
Hi Expert,
I have messy code problem while translating XString to String in XML-Format Word Doc in OfficeControl.
I upload an XML-Format template Word Doc to server as a MIME Object.
When OfficeControl is started in Web Dynpro, OfficeControl automatically open the XML-Format template.
For the first time, I get the XString-type Context attribute bind to the content of the Word Doc,
then translate it to string, I got the XML-format content, it's great!
However, after the first time, when I input any new contents in MS Word in Web Dynpro,
no matter I execute "Ctrl + S" or click the "savedocument" button,
when I translate the XString Context attribute to String, I got messy code. (but the first time, it is good plain text)
I use the function module: ECATT_CONV_XSTRING_TO_STRING (good for first time, dump after first time),
SCMS_XSTRING_TO_BINARY, SCMS_BINARY_TO_STRING (good for first time, messy code after first time).
My Demo source code is in: (system) SMV --> (local object) zhaode --> (Dynpro Component) ztest_office_control
core source code is as:
clear itab.
CALL FUNCTION 'SCMS_XSTRING_TO_BINARY'
EXPORTING
BUFFER = lv_datas
IMPORTING
OUTPUT_LENGTH = lv_length
TABLES
binary_tab = itab.
CALL FUNCTION 'SCMS_BINARY_TO_STRING'
EXPORTING
input_length = lv_length
mimetype = 'text/plain; charset=utf-8'
IMPORTING
text_buffer = lv_datas_string
output_length = lv_data_len
TABLES
binary_tab = itab.
Can you give me some advice?
Many thanks in advance.
Best Regards,You have already posted this same question several times (and some very similiar questions) within the forum. Please do NOT multiple post your questions. This is against the forum rules of engagement. SAP employee or not, you will find yourself banned from the forums if you don't follow the rules.
-
As I have been told, the following code is mixing as2 and as3.
picHolder[1].onPress = function() {
picHolder[1].width = card.width;
picHolder[1].height = card.height;
picHolder[1].x = 0;
picHolder[1].y = 0;
card.addChild(picHolder[1]);
I presume the AS3 code is whats inside the function (My addition), as the function code was there when following the as2 tutorial. Basically, when the user clicks the image in array element 1, this image should be set as the background of the movieclip card. How would I change the inside so that is was AS2 code?
cheersWell, what I have done is
picHolder[1].onPress = function() {
picHolder[1]._width = card._width;
picHolder[1]._height = card._height;
picHolder[1]._x = 0;
picHolder[1]._y = 0;
card.addChild(picHolder[1]);
Now it does slightly what I want, but it doesnt get placed into the movieclip how it should. Not sure if I am doing everything how i should be doing it. -
Load AS2 swf into AS3 swf problem
I have a flash with AS3 and inside this swf i load in a AS2 swf.
to load swf works just fine, but the problem is when i load this i want to go to
a specific part of it, for example i want to go to frame 3 in the loaded swf.
i must control this from the AS3 swf, does someone know if this is possible?
thanks in advanceso can i do like this then to go to frame 3 in my loaded swf?
MovieClip(ldr.content).gotoAndStop(3); ?
sorry for being such an airhead
thanks for helping me out =)
Date: Sun, 7 Jun 2009 10:25:09 -0600
From: [email protected]
To: [email protected]
Subject: load AS2 swf into AS3 swf problem
no.
if, in your loaded swf, you have a function f1() on the loaded swf's main timeline and you load that swf using a loader (say ldr), use:
MovieClip(ldr.content).f1(); // to call f1() in the loaded swf
> -
Hey,
I have an 2 animations that I need to syncronize. The first animation is a projector screen entering stage, the second is few text layers and images.
I timed the second animation 2.2 sec after the screen animation starts (using timer event) and it worked. When I tested it in other computers and on the internet the screen movment was much slower so the second animation entered the stage too fast.
I want to order the second animation to enter only when the projector screen reach it's destination on stage. The screen animations has 2 parts, in animation and out animation connected by a stop(); commend in the middle.
How can I do it without timer events?let say you want second_mc to play when first_mc is at frame 10.
get in first_mc and add actionscript keyframe at frame 10 (you can add another blank script layer for this keyframe)
to it's as3 code paset: (root as MovieClip).second_mc.play();
at frame one of second_mc add stop();
shuld work now....
אם אתה לא מסתדר שלח לי במייל את הבאנר ואת הפריים ממנו האנימציה צריכה להתחיל
[email protected] -
Hello All,
I have written a simple AS3 Code to load a SWF File on he Stage. The file is loading properly but the Within the stage. The Width and height of the SWF file change. Like LoaderInfo return file size 200X200 , but after adding child the Width and height changes to 150.23 X150.23. I'm accessing the length of the loader.content property. At what ratio the change is a happening? I have attached the code... Document property show content radio button clicked.
stage.scaleMode=StageScaleMode.EXACT_FIT;
//stage.scaleMode=StageScaleMode.NO_SCALE;
//stage.scaleMode=StageScaleMode.SHOW_ALL;
var Clip:Loader = new Loader();
var req:URLRequest=new URLRequest("1.swf");
Clip.contentLoaderInfo.addEventListener(Event.INIT,initListener);
Clip.contentLoaderInfo.addEventListener(Event.COMPLETE,LoadingDone);
Clip.load(req);
var info:LoaderInfo;
function initListener(event:Event):void {
var SwfClip:Loader=Loader(event.target.loader);
info=LoaderInfo(SwfClip.contentLoaderInfo);
trace("File properties :- \n" + "width :- " + info.width + "\nHeight :- " + info.height);
function LoadingDone(event:Event):void {
this.addChild(Clip);
trace(Clip.width + " " + Clip.height + " " + (event.target.content).width + " " +(event.target.content).height);You have stage.scaleMode set to EXACT_FIT which is causing the container to scale... and causing the loaded swf to scale as well. Remove that, or use No_SCALE and it will return the proper size.
-
my iTunes won't detect my iPhone that has to be restored via iTunes *because if pass code problems* and its running iOS 7.0.4
If itunes is comming up and saying it can't read the device because it's locked with a passcode, you may have to put your device into recovery mode first.
To put your device in recovery mode: (Following these steps will erase your device and reset everything to factory defaults)
1) press and hold the power button until you see the slide to power off option
2) swipe to power off
3) Press and hold the home button while the device is off and connect it to your computer. Continue holding the home button until you see a graphic with the iTunes logo with a picture of a USB cable below it.
4) iTunes should give you a message that it has detected a device in recovery mode. Click ok and then select Restore iPhone. iTunes will download a fresh copy of iOS and then wipe the device and restore it. Depending on the speed of your computer's internet connection this may take a while. Just leave the iphone connected to your computer until it's finished.
If itunes is not detecting it at all or is Not giving you the message that the phone is locked with a passcode, you may end up having to reinstall itunes. This seems to be a fairly common problem after the most recent itunes update (11.1.5)
If this is the case and you happen to be running a windows based computer you will have to uninstall itunes in this order from your programs and features option in control panel:
iTunes
Apple Software Update
Apple Mobile Device Support
Bonjour
Apple Application Support (iTunes 9 or later)
Then download and reinstall itunes from itunes.com try putting your device into recovery mode again and restore.
Hope this helps.
Cheers. -
Hello!
I want to use visual basic to build a htm which can control labview throght datasocket, i set the switch
as " Swithc until release " in visual basic, the code is
Private Sub CWButton1_Click()
CWDataSocket1.Data = CWButton1.Value
End Sub
but the led of labview can't light on.
is the code problem?
thanks!The problem is most likely because you have the code in the Click() event handler. The click event in VB is a left mouse down AND mouse up over the controls. If you are wanting it to send out the value when you press and hold the button down, change the event handler to the ValueChanged event.
Best Regards,
Chris Matthews
National Instruments -
Can AS1 code call AS3 code?
I was wondering if there was any way for AS1 code to call AS3
code.
I need to write a server extension for SmartFox Pro. I just
found out that the only version of action script that SmartFox
sever extensions can be written in is AS1. However, I have a bunch
of code already written in AS3 that I need to use. I have all of
the source for the AS3 code.
Is there a way for me to use my existing code, or am I out of
luck?
Thanks in advance
John Lawrieyou may be able to use swfbridge to do so, basically
implementing the LocalConnection class
http://www.gskinner.com/blog/archives/2007/07/swfbridge_easie.html -
Is it possible to write a as3 code that will search for particular file in the loacal disk
Is it possible to write a as3 code that will search for particular file in the loacal disk
Not for a web-based design
-
Would someone be willing to check as3 code for a guestbook
Would someone be willing to check out some as3 code for a guestbook? I'm an old person, and can't seem to get it working.
Thanks!Ned suggested that I post the code, so everyone could see it. The SWF works, but the code doesn't. Any help appreciated!
package com.mgraph\
//IMPORTS
import flash.display.Loader;
import flash.display.MovieClip;
import flash.display.Sprite;
import flash.display.StageAlign;
import flash.display.StageScaleMode;
import flash.events::EventDispatcher/dispatchEventFunction();
import flash.events::EventDispatcher/dispatchEvent();
import flash.events.MouseEvent;
import flash.events.TextEvent;
import flash.events.KeyboardEvent;
import flash.geom.Rectangle;
import flash.net::URLLoader/onComplete();
import flash.net.URLRequest;
import flash.net.URLRequestMethod;
import flash.net.URLVariables;
import flash.text.TextFieldAutoSize;
import flash.text.TextFormat;
import com.utils.StringUtils;
import com.caurina.transitions.Tweener;
import com.pageflip.Page;
import com.pageflip.PageEvent;
public class Guestbook extends MovieClip {
//PRIVATE VARS
private var myXML:XML;
private var frm:TextFormat;
private var popup_mc:MovieClip;
private var greySprite:Sprite;
private var initPosition:Number;
private var dy:Number;
private var initContentPos:Number;
private var moveVal:Number;
private var rectScroll:Rectangle;
private var stageWidth:Number;
private var stageHeight:Number;
public function Guestbook(){
addEventListener(Event.ADDED_TO_STAGE,init);
private function init(e:Event):void {
stage.showDefaultContextMenu = false;
stage.align = StageAlign.TOP_LEFT;
stage.scaleMode = StageScaleMode.NO_SCALE;
stageWidth = stage.stageWidth;
stageHeight = stage.stageHeight;
// LOAD THE XML
var xmlPath:String;
var xmlLoader:URLLoader = new URLLoader;
if (root.loaderInfo.parameters.myconfig) {
// XML PATH FROM HTML flashvars (myconfig)
xmlPath = root.loaderInfo.parameters.myconfig;
else {
// DEFAUL PATH OF XML
xmlPath = "config.xml";
xmlLoader.load(new URLRequest(xmlPath));
xmlLoader.addEventListener(Event.COMPLETE,xmlLoaded);
private function xmlLoaded(e:Event):void {
// XML LOADED COMPLETE
myXML = new XML(e.target.data);
// ADD EVENT LISENER TO FIELDS AND TO (send_btn)
form_mc.name_txt.addEventListener(TextEvent.TEXT_INPUT,clearAlert);
form_mc.email_txt.addEventListener(TextEvent.TEXT_INPUT,clearAlert);
form_mc.message_txt.addEventListener(TextEvent.TEXT_INPUT,clearAlert);
form_mc.email_txt.addEventListener(Event.CHANGE,checkMail);
addMouseEvent(form_mc.send_btn,sendEvent);
// CREATE TEXT FORMAT (frm)
frm = new TextFormat ;
frm.leading = 4;
form_mc.message_txt.defaultTextFormat = frm;
// LOAD BACKGROUND IMAGE
var backLoader:Loader = new Loader();
backLoader.contentLoaderInfo.addEventListener(Event.COMPLETE,backLoaded);
backLoader.load(new URLRequest(myXML.img_back));
// ADD KEYBOARD EVENT WHEN PRESSING ENTER KEY
stage.addEventListener(KeyboardEvent.KEY_DOWN,keyboardDown);
// CREATE THE GREY SPRITE
greySprite = new Sprite ;
greySprite.graphics.beginFill(0x000000,0.2);
greySprite.graphics.drawRect(0,0,stageWidth,stageHeight);
greySprite.graphics.endFill();
greySprite.useHandCursor = false;
// CREATE THE POPUP and ADD EVENTLISTENER TO (close_btn)
popup_mc = new popup_obj;
popup_mc.x = (stageWidth - popup_mc.width)/2;
popup_mc.y = (stageHeight - popup_mc.height)/2;
addMouseEvent(popup_mc.close_btn,closeEvent);
private function keyboardDown(e:KeyboardEvent):void{
if(e.keyCode == 13){
// STOP USING BREAK LINE IN message_txt
stage.focus = null;
private function backLoaded(e:Event):void{
// BACKGROUND LOADED COMPLETE
var back_mc:MovieClip = new MovieClip;
back_mc.addChild(e.target.content);
addChildAt(back_mc,0);
form_mc.wait_mc.visible = false;
startPageFlip();
// START LOADING GUEST MESSAGE FROM DATABASE
load_guestbook();
private function startPageFlip():void{
var flipedPage:Page = new Page(this, stageWidth, stageHeight, 0, 0);
flipedPage.turnPageForward();
private function load_guestbook():void {
// GET MESSAGES FROM DATABASE USING PHP
var guestLoad:URLLoader = new URLLoader ;
var guestReq:URLRequest = new URLRequest(myXML.phpURL);
guestReq.method = URLRequestMethod.POST;
guestReq.data = new URLVariables ;
guestReq.data["getMessage"] = 1;
guestLoad.addEventListener(Event.COMPLETE,bookLoaded);
guestLoad.load(guestReq);
private function bookLoaded(e:Event):void {
// MESSAGES LOADED SUCCESSFULLY FROM DATABASE
var bookXML:XML = new XML(e.target.data);
showMessages(bookXML);
private function showMessages(_xml:XML):void{
var guest_mc:MovieClip;
// CREATE (guest_mc) to SHOW EACH GUEST NAME & MESSSAGE
for (var u=0; u<_xml.guest.length(); u++) {
guest_mc = new messageObj ;
guest_mc.y = 95 * u;
//CAPITALIZE THE FIRST CHAR IN NAME
guest_mc._Name = StringUtils.capitalize(_xml.guest[u].name);
guest_mc._Msg = _xml.guest[u].msg;
guest_mc._Date = _xml.guest[u].sdate;
guest_mc.guestName_txt.htmlText = setHtmlFormat(14,myXML.name_color,guest_mc._Name);
//IF guestMessage_txt TEXT LENGTH > 110 substr guestMessage_txt AND ADD (...)
guest_mc.guestMessage_txt.htmlText = setHtmlFormat(12,myXML.message_color,StringUtils.capitalize(StringUtils.truncate(_xml.gue st[u].msg,110,"...")));
guest_mc.guestMessage_txt.setTextFormat(frm);
guest_mc.tabChildren = false;
guest_mc.tabEnabled = false;
// ADD EVENT LISTISTENER TO (readMore_btn) FOR EACH (guest_mc)
addMouseEvent(guest_mc.readMore_btn,readEvent);
msgContainer.addChild(guest_mc);
// SHOW/HIDE SCROLL
if (msgContainer.height < mask_mc.height) {
scroller.scroll_btn.visible = false;
else {
this.mouseChildren = false;
scroller.scroll_btn.y = 0;
if(msgContainer.y != 10){
Tweener.addTween(msgContainer,{y:10,time:1.5,onComplete:initScrollPos});
else{
initScrollPos();
scroller.scroll_btn.visible = true;
// ADD EVENT TO SCROLL
addMouseEvent(scroller.scroll_btn,scroll_Event);
scroller.scroll_btn.addEventListener(MouseEvent.MOUSE_UP,scroll_Event);
private function initScrollPos():void{
this.mouseChildren = true;
dy = 0;
initPosition = scroller.scroll_btn.y = scroller.bar_mc.y;
initContentPos = msgContainer.y;
moveVal = (msgContainer.height-mask_mc.height)/(scroller.bar_mc.height-scroller.scroll_btn.height);
rectScroll = new Rectangle(scroller.bar_mc.x + 4,scroller.bar_mc.y,0,scroller.bar_mc.height - scroller.scroll_btn.height);
private function readEvent(me:MouseEvent):void {
var _this = me.currentTarget;
switch (me.type) {
case "mouseOver" :
_this.alpha = 0.8;
break;
case "mouseOut" :
_this.alpha = 1;
break;
case "mouseDown" :
// SHOW POPUP WITH MORE INFORMATIONS ABOUT THE CURRENT MESSAGE
popup_mc.pop_nom.htmlText = setHtmlFormat(15,myXML.name_color,_this.parent._Name) + setHtmlFormat(13,myXML.datePosted_color," - Posted "+_this.parent._Date);
popup_mc.pop_message.htmlText = setHtmlFormat(13,myXML.message_color,StringUtils.capitalize(_this.parent._Msg));
popup_mc.pop_message.autoSize = TextFieldAutoSize.LEFT;
popup_mc.pop_message.setTextFormat(frm);
popup_mc.back_mc.height = popup_mc.pop_message.height + 50;
popup_mc.x = (stageWidth - popup_mc.width)/2;
popup_mc.y = (stageHeight - popup_mc.height)/2;
addChild(greySprite);
addChild(popup_mc);
popup_mc.alpha = 0;
greySprite.alpha = 0;
Tweener.addTween(popup_mc,{alpha:1,time:0.6});
Tweener.addTween(greySprite,{alpha:1,time:0.6});
break;
private function setHtmlFormat(_size:Number,_color,_txt:String):String{
var htmlFrm:String = "<font size='"+_size+"'color='"+_color+"'>"+_txt+"</font>";
return htmlFrm;
private function closeEvent(me:MouseEvent):void {
switch (me.type) {
case "mouseOver" :
popup_mc.close_btn.alpha = 0.8;
break;
case "mouseOut" :
popup_mc.close_btn.alpha = 1;
break;
case "mouseDown" :
if (stage.contains(popup_mc)) {
Tweener.addTween(greySprite,{alpha:0,time:0.6,onComplete:function(){removeChild(greySprit e)}});
Tweener.addTween(popup_mc,{alpha:0,time:0.6,onComplete:function(){removeChild(popup_mc)}} );
break;
private function scroll_Event(me:MouseEvent):void {
switch (me.type) {
case "mouseOver" :
scroller.scroll_btn.alpha = 0.7;
break;
case "mouseOut" :
scroller.scroll_btn.alpha = 1;
break;
case "mouseUP" :
scroller.scroll_btn.stopDrag();
scroller.scroll_btn.removeEventListener(Event.ENTER_FRAME, scrollMove);
break;
case "mouseDown" :
scroller.scroll_btn.startDrag(false, rectScroll);
scroller.scroll_btn.addEventListener(Event.ENTER_FRAME, scrollMove);
stage.addEventListener(MouseEvent.MOUSE_UP, releaseOut);
break;
private function scrollMove(event:Event):void {
dy = Math.abs(initPosition - scroller.scroll_btn.y);
msgContainer.y = Math.round(dy * -1 * moveVal + initContentPos);
private function releaseOut(me:MouseEvent):void {
scroller.scroll_btn.stopDrag();
scroller.scroll_btn.removeEventListener(Event.ENTER_FRAME, scrollMove);
stage.removeEventListener(MouseEvent.MOUSE_UP, releaseOut);
private function sendEvent(e:MouseEvent):void {
switch (e.type) {
case "mouseOver" :
form_mc.send_btn.alpha = 0.7;
break;
case "mouseOut" :
form_mc.send_btn.alpha = 1;
break;
case "mouseDown" :
// CHECK FIELDS AND EMAIL THEN SEND DATA TO PHP
if (form_mc.name_txt.text == "") {
stage.focus = form_mc.name_txt;
show_alert("You must enter the : « Name »");
else if (form_mc.email_txt.text == "") {
stage.focus = form_mc.email_txt;
show_alert("You must enter the : « E-mail »");
else if (form_mc.validating.currentFrame == 1) {
stage.focus = form_mc.email_txt;
form_mc.validating.alpha = 1;
form_mc.validating.gotoAndStop(1);
show_alert("« E-mail » address is incorrect");
else if (form_mc.message_txt.text == "") {
stage.focus = form_mc.message_txt;
show_alert("You must enter the : « Message »");
else {
sendData();
break;
private function checkMail(e:Event):void {
form_mc.validating.alpha = 1;
var mail_validation:RegExp = /^[a-z][\w.-]+@\w[\w.-]+\.[\w.-]*[a-z][a-z]$/i;
mail_validation.test(form_mc.email_txt.text);
if (mail_validation.test(form_mc.email_txt.text) == true) {
form_mc.validating.gotoAndStop(2);
form_mc.alert_txt.text = "";
else {
form_mc.validating.gotoAndStop(1);
private function clearAlert(te:TextEvent):void {
if (form_mc.alert_txt.text != "") {
form_mc.alert_txt.text = "";
private function show_alert(txt:String):void {
form_mc.alert_txt.htmlText = "<font color='" + myXML.alert_color + "'>" + txt + "</font>";
private function sendData():void {
// SEND NAME-EMAIL-MESSAGE TO PHP
this.mouseChildren = false;
form_mc.wait_mc.visible = true;
var phpLoad:URLLoader = new URLLoader ;
var phpReq:URLRequest = new URLRequest(myXML.phpURL);
phpReq.method = URLRequestMethod.POST;
phpReq.data = new URLVariables ;
phpReq.data["name"] = StringUtils.stripTags(form_mc.name_txt.text);
phpReq.data["email"] = form_mc.email_txt.text;
phpReq.data["message"] = StringUtils.stripTags(form_mc.message_txt.text);
phpLoad.addEventListener(Event.COMPLETE,insertPHP);
phpLoad.load(phpReq);
private function insertPHP(e:Event):void {
this.mouseChildren = true;
var phpXML:XML = new XML(e.target.data);
form_mc.send_btn.mouseEnabled = true;
form_mc.wait_mc.visible = false;
if (phpXML.inserted == 1) {
startPageFlip();
form_mc.alert_txt.htmlText = myXML.insert_ok;
form_mc.validating.alpha = 0;
form_mc.validating.gotoAndStop(1);
while (msgContainer.numChildren) {
msgContainer.removeChildAt(msgContainer.numChildren-1);
// SHOW THE CURRENT POSTED MESSAGE AND CLEAR FIELDS
showMessages(phpXML);
clearFields();
else {
form_mc.alert_txt.htmlText = myXML.insert_error;
private function clearFields():void {
form_mc.name_txt.text = "";
form_mc.email_txt.text = "";
form_mc.message_txt.text = "";
form_mc.validating.gotoAndStop(1);
form_mc.validating.alpha = 0;
private function addMouseEvent(_targ,_func):void {
_targ.buttonMode = true;
_targ.mouseChildren = false;
_targ.addEventListener(MouseEvent.MOUSE_OVER,_func);
_targ.addEventListener(MouseEvent.MOUSE_OUT,_func);
_targ.addEventListener(MouseEvent.MOUSE_DOWN,_func);
Maybe you are looking for
-
Can I connect an Audigy 2 front panel to an X-Fi?
I have an older Audigy 2 Platinum with the front panel and an X-Fi Titanium Fatalty Pro card. I'd like to connect the front panel if possible because I don't think Creative even makes the front panels for the X-Fi cards anymore and they were always k
-
BPM restar after synchronous message error
After an error during a synchronous message (external system not avaible) into a BPM, how I can restart the BPM and re-execute the synchronous message? By, Sergio
-
I am unable to get my decently new Imac to recognize or charge my brand new ipod nano.
I am unable to get my decently new Imac to recognize or charge my brand new ipod nano. I have tried to restart my computer and the ipod, neither have worked. Running itunes 10.7. Please help.
-
Can i use ipad air charge to charge iphone 5s
can i use ipad air charge to charge iphone 5s? same power output?
-
OLD ADOBE PHOTOSHOP...HELP!
Hi how can I get all of my pix out of the old ADOBE photoshop as they are no longer permitting usage. They say we need to upgrade. How do I do this and which is the best product to do? How do we get all of our pix out and into new software program