Hi i am trying to code a new portfolio website of mine in FLASH CS3 using Actionscript 3 and i want the content to appear gradually when the user presses one of the buttons. I wanted to do this by changes the aplha gradually to all the content to slowly emerge, however when i am trying to run a test on the first button i keep getting this error"1046: Type was not found or was not a compile-time constant: Void." and that appears 3 time in the error window one error for the 3 different parts of the code. I have posted my code below and hopw you can help.
Also i was wondering if any one new how to make it so when the user clicks on another button the site would 1st slowly make the current content disapear and then make the new content slowly appear. thanks.
ERRORS:
1046: Type was not found or was not a compile-time constant: Void.
1046: Type was not found or was not a compile-time constant: Void.
1046: Type was not found or was not a compile-time constant: Void.
hi i have solved that issue it was my own stupid fault for not spotting the capital “V” in void lol! However i am now getting the error message saying:
TypeError: Error #2007: Parameter type must be non-null.
at flash.events::EventDispatcher/addEventListener()
at portfolio3_fla::MainTimeline/frame1()
stop();
webCent.alpha = 0;
var targetAlpha:Number = 1;
var easing:Number = 0.1;
bttn1.addEventListener(Event.CLICK, bttn1Click);
function bttn1Click(evt:MouseEvent):void{
addEventListener(Event.ENTER_FRAME, fading);
function fading(evt:Event):void{
webCent.alpha += ( targetAlpha - webCent.alpha) * easing;
}
}
put it in the root, next to the other function (you can’t nest functions). The function will only run when the button is clicked because that is where you are setting up the eventListener and timer. When you want the fade to stop then just remove the eventlistener.
function bttn1Click(evt:MouseEvent):void{
addEventListener(Event.ENTER_FRAME, fading);
}
function fading(evt:Event):void{
webCent.alpha += ( targetAlpha - webCent.alpha) * easing;
}
Hi thanks for all the quick replies guys you have all been very helpful. i have not got another issue tho if you wouldn’t mind helping me, i want to allow the user to click on a button then have the current content disappear and have the new content fade in however i cant seem to get the logic down lol! i think i almost have it but when the user selects the home page after selecting the web page the home page only displays at about half transparency and i think it has something to do with the IF statement but im not sure what else to use because i have tried removing the event listener and turning the alpha back to 0 with no success. The code i have up to now is below thanks for the help.
with your easing the alpha will never reach 1. make it something like 0.98 in the if statements instead, and when it is 0.98 or higher make it 1 and then remove the listener.
however i am still having the same problem, i am just not sure why this is doing this i thought it would allow the user to click on a section and then have that section load in and then when they click on another section have the current section disappear and the new section load in. But after the first section is loaded in properly and you click on the second section it only partially loads and then it seems to freeze and it doesnt matter what button you press, its doin my head in now lol!
I first of all would like to really thanks everyone who has helped me on this (Iamthejuggler, sekasi and Fidodo) and even tho the suggestions didnt seem to work they were all greatly appreciated. I did find a solution but i had to re-write the code, the problem seems to have been performing the reset of the alpha’s and the deletion of the event listeners in the wrong place, anyway the fully working code is now below encase you guys wanted to look, thanks!:party::party: