# Hi.. im a new member and new to AS3

**URL:** https://forum.kirupa.com/t/hi-im-a-new-member-and-new-to-as3/267925
**Category:** Uncategorized
**Created:** [August 7, 2008, 11:45am UTC](https://forum.kirupa.com/t/hi-im-a-new-member-and-new-to-as3/267925 "2008-08-07T11:45:54Z")
**Posts on this page:** 1
**Page:** 1

<div class="post-metadata">

### Author: ![wonsong82](https://avatars.discourse-cdn.com/v4/letter/w/22d042/32.png) [@wonsong82](https://forum.kirupa.com/u/wonsong82)
#### Post date: [August 7, 2008, 11:45am UTC](https://forum.kirupa.com/t/hi-im-a-new-member-and-new-to-as3/267925/1 "2008-08-07T11:45:54Z")

</div>

i am a graphic designer and trying to learn AS3.

my first project was to make a ROLLOVER / OUT button and  
load up the external jpg file into the flash when the buttons are clicked,  
with the loading % text for each pictures being loaded.

it works fine when i tested on my computer(local), but  
when i uploaded to website and try to view it thru, it wouldnt load up the .jpg into the flash.

what did i do wrong? plus, my codes are just all from my scratch, so they will be very bad and ineffective. please teach me if there is better way of coding(im sure there are :))

k here is my code… sorry about the forein languages here and there.

* * *

import fl.transitions.Tween;  
import fl.transitions.easing.\*;  
var box:Sprite = new Sprite();  
addChild(box);  
//////////////////////////////////////////////  
box.x = 100; // 이미지가 로딩될곳의 X  
box.y = 50; // 이미지가 로딩될곳의 y  
///////////이거 4개 너꺼에 맞게 바꾸세용//////////

// button1\_mc (첫번째 버튼) ///////////////////////////////////////////////////////////////////////////////  
// 너의 첫번째 버튼 이름을 button1\_mc 라고 정해주고… 시작해요…  
// 두번쨰 세번쨰는 각각 button2\_mc, button3\_mc … and so on…  
var btn1Height:Number = button1\_mc.height;  
var btn1Width:Number = button1\_mc.width;  
button1\_mc.height = 50; // \* 이거 첫번째 버튼의 크기 조절하는거야… 크기중 높이를 여기다가 적어줘.  
button1\_mc.width = 50; // \* 이건 첫번쨰 버튼의 폭…(width)…  
button1\_mc.buttonMode = true;  
stage.addEventListener(Event.ENTER\_FRAME, countProperty);  
button1\_mc.addEventListener(MouseEvent.ROLL\_OVER, btn1RollOver);  
button1\_mc.addEventListener(MouseEvent.ROLL\_OUT, btn1RollOut);  
function countProperty(event:Event):void{  
btn1Height = button1\_mc.height;  
btn1Width = button1\_mc.width;  
btn2Height = button2\_mc.height;  
btn2Width = button2\_mc.width;  
} // _여기다가 버튼 있는 계수만큼 써야돼.  
function btn1RollOver(event:MouseEvent):void{  
var button1TweenHeight:Tween = new Tween(button1\_mc, “height”, Regular.easeInOut, btn1Height, 70, 1, true);  
//_ 여기서 70 이라는 숫자를 바꿔야돼. 너의 버튼이 가장 커졌을떄의 크기 (높이)  
var button1TweenWidth:Tween = new Tween(button1\_mc, “width”, Regular.easeInOut, btn1Width, 70, 1, true);  
//\* 여기서도 똑같이. 이번엔 폭.  
}  
function btn1RollOut(event:MouseEvent):void{  
var button1TweenHeight:Tween = new Tween(button1\_mc, “height”, Regular.easeInOut, btn1Height, 50, 1, true);  
//\* 여기선 50 이라는 숫자를 너의 버튼의 원래 크기(커지지 않았을때 숫자를 적어줘) 높이. 그리고 밑에꺼엔 폭.  
var button1TweenWidth:Tween = new Tween(button1\_mc, “width”, Regular.easeInOut, btn1Width, 50, 1, true);  
}  
/////////////////첫번쨰 버튼 끝나는곳//////////////////////////////////////////////////////////////////////////////

// button2\_mc (2번째 버튼) !!!//////////////////////////////////////////////////////////////////////////////  
// \*두번쨰 버튼인데… 잘 보면 첫번쨰 버튼에서 1 이라고 써있던게 다 2 로 바껴있지?  
// 첫번쨰꺼 완성되면 두번째꺼 숫자 다 바꺼보고 두번쨰꺼도 완성되면 버튼 시작부분부터 끝부분까지 다 카피해서  
// 세번째, 네번째, 다섯번째 버튼들 다 각각 숫자만 변경해주면 돼…  
var btn2Height:Number = button2\_mc.height;  
var btn2Width:Number = button2\_mc.width;  
button2\_mc.height = 50;  
button2\_mc.width = 50;  
button2\_mc.buttonMode = true;  
button2\_mc.addEventListener(MouseEvent.ROLL\_OVER, btn2RollOver);  
button2\_mc.addEventListener(MouseEvent.ROLL\_OUT, btn2RollOut);

function btn2RollOver(event:MouseEvent):void{  
var button2TweenHeight:Tween = new Tween(button2\_mc, “height”, Regular.easeInOut, btn2Height, 70, 1, true);  
var button2TweenWidth:Tween = new Tween(button2\_mc, “width”, Regular.easeInOut, btn2Width, 70, 1, true);  
}  
function btn2RollOut(event:MouseEvent):void{  
var button2TweenHeight:Tween = new Tween(button2\_mc, “height”, Regular.easeInOut, btn2Height, 50, 1, true);  
var button2TweenWidth:Tween = new Tween(button2\_mc, “width”, Regular.easeInOut, btn2Width, 50, 1, true);  
}  
////////////////////////////////// 버튼2 끝나는 부분 ////////////////////////////////////////////////////////////////

///////////////////////////// 인제 버튼 눌르면 사진 바뀌게 //////////////////////////////  
function showLoadTxt(event:ProgressEvent):void{  
var loaded:int = event.bytesLoaded;  
var total:int = event.bytesTotal;  
var percent:int = loaded/total\*100;  
load\_txt.text = “Loading: “+String(percent)+”%”;  
}  
button1\_mc.addEventListener(MouseEvent.CLICK, button1Down);  
button2\_mc.addEventListener(MouseEvent.CLICK, button2Down);

function button1Down(event:MouseEvent):void{  
var pic1Req:URLRequest = new URLRequest(“1.jpg”);  
var pic1Loader:Loader = new Loader();  
pic1Loader.load(pic1Req);  
box.addChild(pic1Loader);  
pic1Loader.contentLoaderInfo.addEventListener(ProgressEvent.PROGRESS, showLoadTxt);

}

function button2Down(event:MouseEvent):void{  
var pic2Req:URLRequest = new URLRequest(“2.jpg”);  
var pic2Loader:Loader = new Loader();  
pic2Loader.load(pic2Req);  
box.addChild(pic2Loader);  
pic2Loader.contentLoaderInfo.addEventListener(ProgressEvent.PROGRESS, showLoadTxt);  
}

* * *
